Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Xeda112358

Pages: 1 ... 91 92 [93] 94 95 ... 317
1381
Other Calc-Related Projects and Ideas / Re: OmniRPG - Coding
« on: December 09, 2012, 12:18:24 pm »
Yeah, that might actually be a good idea Matrefeytontias. Otherwise, animation ideas will get lost in the sprite/coding sections.

1382
Other Calc-Related Projects and Ideas / Re: OmniRPG - Coding
« on: December 09, 2012, 11:54:26 am »
@stevon8ter: I couldn't run it .__.
@Yeong: I think we shouldn't have background sound, but we could incorporate sound/music as a non-crucial part of the game. For example, we could have a "radio"  in the game that plays from a random playlist.
@Matrefeytontias: That looks nice o.o If you could make it so that it can start of a position (x1,y1) and stop at position (x2,y2), that would be great o.o (This would be so that we can have the laser be fired from the player and have it hit the opponent, or miss and shoot off the edge of the screen.)

1383
TI Z80 / Re: PROGRAM: Polynomial Math Utility
« on: December 09, 2012, 09:30:36 am »
Hmm, I can't remember, but I know it can find derivatives and do some symbolic math among other things.

EDIT: If you are going to make a symbolic parser, you will probably need some arbitrary precision routines, or you can just use the OSes FP routines.

1384
TI Z80 / Re: PROGRAM: Polynomial Math Utility
« on: December 09, 2012, 09:20:53 am »
So it will be like Symbolic, but maybe more stuff?

1385
Other Calc-Related Projects and Ideas / Re: OmniRPG - Coding
« on: December 09, 2012, 09:06:26 am »
Cool, what ideas do you have?

1386
Other Calc-Related Projects and Ideas / Re: OmniRPG - Coding
« on: December 09, 2012, 08:53:41 am »
@aeTIos: He means using the compression algorithm I gave. '.' corresponds to the two-nibble value $F0

1387
Other Calc-Related Projects and Ideas / Re: OmniRPG - Coding
« on: December 09, 2012, 08:51:21 am »
@stevon8ter: yep :)
@aeTIos: I dunno, I just started experimenting with stuff. I don't think we even have a plan of what there is to do .__. We should keep the first post edited with a To Do list as well as the people working on the different parts.

1388
Other Calc-Related Projects and Ideas / Re: OmniRPG - Coding
« on: December 09, 2012, 08:21:06 am »
I'll describe it here, since I don;t think I ever released the idea, just the code. Basically, it works like this (there are two methods)

I first designed this algorithm using Celtic3+BASIC, using the idea of how common certain letters were in the English alphabet. I arranged them in order and threw in some numbers and punctuation, so I could compress my most common messages:
Code: [Select]
ETAOINSHRDLCUMFGYPBVKWXJQZ,?!.0123456789/-:'
Note that the first character is a space. Now, in the actual message, any time one of the first 14 characters appear, it will be assigned a nibble 0~D. If anything after that is used, (say the 23 character in the list), it will be a two-nibble value, starting with E or F. You can subtract 14 and add $E0 to it (essentially, add $D2 to the original value). In this way, text will take at the worst 100% the original size and at the best 50%. However, because the first 14 characters are the most common to appear in an English message, it averages around 60% compression. For example, here is the message, "HELLO!" (this works best with larger messages):
NOTE: We start counting at zero.
H is the 9th character, so it is one nibble, $8
E is the 2nd character, so it is one nibble, $1
L is the 12th character, so it is one nibble, $B
O is the 5th character, so it is one nibble, $4
! is 30th character, so it is two nibbles: $EF
Combining the nibbles, we get 81BB4EF, but we need to store bytes, and this is an odd number of nibbles, so we pad it with a 0. This is why a space is the first character, because decompressed, it would put a space at the end in cases like this.

Anyways, that is 4 bytes, compared to 6, so compression was about 67% In BatLib, to make sure the extra space at the end wasn't in the output for decompression, I compress data and store the original size as a two byte value in the beginning.

Now, why did we use 46 chars? The first 14 are used as 1-nibble values. A nibble can be 16 different values, so this leaves two extra nibbles for our "extended" chars. So 2*16=32, which means we can have 32 two-nibble values and 14 nibble values, totaling 46. Indexing at 0, we have chars numbered 0 to 45, which in hex is 00h~2Dh. If you look at what we add to find the value of 2-nibble chars ($D2), it is actually not a coincidence that it is the value 2D with its nibbles swapped :D

So what if we want to compress something other than text? What if it is arbitrary data? Basically, you need to scan the data to figure out which byte values are used, then you need to arrange them in descending popularity (I call this a "compression key"). Find your cut-off value (the number you add to get the two -nibble values) and this will also tell you your cut-off for one-nibble/two-nibble values. Because this will use a unique set of chars in some order, you will also need to include the "compression key" so that you can decompress. If the data isn't large enough, the compression key plus the compressed data will take up more space than the original.

I used this in BatLib to compress some internal data, like the main menu (the bitmap was compressed a few hundred bytes, including the compression key). You can also apply this algorithm several times in some cases to further compress the data. I got one tilemap to compress down to 12% of its original size, with each of the compression keys included!

EDIT: This is the relevant code in BatLib for most of the compression/decompression functions:
Spoiler For Spoiler:
Code: [Select]
CompressStr:
     call LoadInc
     ld hl,Codec1
     dec a
     jr nz,$+5
     ld hl,Codec2
     jr $+5
CompData:
     call CustCodec
     ld (TempWord2),hl
     call StringOrName
     ld (TempWord1),hl
     push bc
     push af
     push hl
     inc bc
     inc bc
     call MakeAnsStrX
     pop hl
     pop af
     pop bc
     ex de,hl
     ld (hl),c
     inc hl
     ld (hl),b
     inc hl
     ex de,hl
     push bc
     push de
     call ReadArc
     pop hl
     pop bc
     push hl
     push de
     ld de,(TempWord1)
     ld ix,(TempWord2)
     call TextComp
     pop de
     inc hl
;HL points to the end of where it was converted
     ex de,hl
     or a
     sbc hl,de
     ex de,hl
;DE is the size of the data to delete
;HL points to where to delete the data
     push hl
     bcall(4357h)
     pop hl
     pop de
     dec de
     dec de
     or a
     sbc hl,de
     ex de,hl
     dec hl
     ld (hl),d
     dec hl
     ld (hl),e
     ret

TextComp:
;Inputs:
;     DE points to the text to convert
;     HL points to where to convert to
;     BC is the size of the string
;     IX points to the codec
     call CodecStats
     ld (8478h),bc
     ld b,0
     ld (hl),0
TextCompLoop:
     push hl
     push bc
     ld bc,(8478h)
     ld a,b \ or c
     jr nz,$+11
       pop bc
       pop hl
       bit 0,b
       ret z
       xor a
       rld
       ret
     dec bc
     ld (8478h),bc
     ld a,(de)
     inc de
     ld c,(ix)
     push ix
     pop hl
     inc hl
     cpir

     push hl
     push af
     ld a,(ix)
     dec a
     ld h,a
     pop af
     ld a,h
     pop hl
     
     jr z,$+3
       ld c,a
     sub c
     pop bc
     pop hl
     exx
     cp c
     exx
     jr c,$+23
     exx
     sub b
     exx
     rlca \ rlca \ rlca \ rlca
     rld
     rlca \ rlca \ rlca \ rlca
     inc b
     bit 0,b
     jr nz,$+4
       inc hl
       ld (hl),0
     rld
     inc b
     bit 0,b
     jr nz,TextCompLoop
     inc hl
     jr TextCompLoop-2
Codec1:
;46 chars
; ETAOINSHRDLCUMFGYPBVKWXJQZ,?!.0123456789/-:'
 .db Codec1End-Codec1
 .db 29h,"ETAOINSHRDLCUMFGYPBVKWXJQZ",2Bh
 .db $AF,2Dh,3Ah,"0123456789",83h,71h,3Eh,$AE
Codec1End:
Codec2:
;Includes lowercase tokens
 .db Codec2End-Codec2
 .db $29,$BB,$45,$B4,$54,$C4,$41,$B0,$4F,$BF,$49,$B8,$4E,$BE,$53,$C3,$48,$B7,$52,$C2,$44,$B3,$4C,$BC
 .db $43,$B2,$55,$C5,$4D,$BD,$46,$B5,$47,$B6,$59,$C9,$50,$C0,$42,$B1,$56,$C6,$4B,$BA,$57,$C7,$58,$C8
 .db $4A,$B9,$51,$C1,$5A,$CA,$2B,$AF,$2D,$3A,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$83,$71,$3E,$AE
;need 4 more bytes
 .db 3Fh,82h,70h,$B0
Codec2End:
CustCodec:
     call StringOrName
     ld de,86ECh
     push de
     call ReadArc
     pop hl
     ret
DeCompStr:
     call LoadInc
     ld hl,Codec1
     dec a
     jr nz,$+5
     ld hl,Codec2
     jr $+5
DeCompData:
     call CustCodec
     ld (TempWord2),hl
     call StringOrName
     or a
     jp nz,ARCH
     dec bc
     dec bc
     push bc
     ld c,(hl)
     inc hl
     ld b,(hl)
     inc hl
     push hl
     inc bc
     call MakeAnsStrX
     ld (TempWord1),bc
     pop hl
     pop bc
     push de
     ld ix,(TempWord2)
     call TextDeComp
;DE is the size of the data to delete
;HL points to where to delete the data
     ex de,hl
     ld de,1
     bcall(4357h)
     pop hl
     dec hl
     dec hl
     ld a,(hl)
     dec a
     ld (hl),a
     inc a
     ret nz
     inc hl
     dec (hl)
     ret
CodecStats:
;     IX points to the codec
;        codec format is the first byte is the size, followed by the bytes allowed
;Output:
;     B' is the adjusting value for one-byte values
;     C' is the cut-off for half-byte values
;     A is the same as B'
     di
     exx
     ld a,(ix)
     rlca
     rlca
     rlca
     rlca
     and 15
     ld b,a
   ld a,(ix)
   and 15
   add a,b
   and 240
   jr z,$+3
   inc b
     ld a,16
     sub b       ;
     ld c,a      ;number of half nibbles
     ld a,b
     rlca
     rlca
     rlca
     rlca
     or c
     ld b,a
     exx
     ret
TextDeComp:
;Inputs:
;     HL points to the text to decompress
;     DE points to where to convert to
;     BC is the size of the string
;     IX points to the codec
     call CodecStats
     ld (8478h),bc
     ld b,0
TextDeCompLoop:
     call GetNextNibble
     ld a,c
     exx
     cp c
     exx
     jr c,$+15
       ld (de),a
       call GetNextNibble
       ld a,(de)
       rlca \ rlca \ rlca \ rlca
       or c
       exx
       add a,b
       exx
     push hl
     push ix
     pop hl
     inc hl
     add a,l
     jr nc,$+3
     inc h
     ld l,a
     ld a,(hl)
     pop hl
     ld (de),a
     inc de
     push bc
     ld bc,(8478h)
     ld a,b \ or c
     pop bc
     jr nz,TextDeCompLoop
     ret
GetNextNibble:
; z flag set if the last
     xor a
     inc b
     bit 0,b
     jr z,$+8
     rld
     ld c,a
     rrd
     ret
     rrd
     ld c,a
     rld
     push bc
     ld bc,(8478h)
     dec bc
     ld (8478h),bc
     pop bc
     inc hl
     ret     
GetCodec:
     call StringOrName
     or a
     ret nz
     or b
     or c
     jp z,NO_DATA
     call CountBytes
     call MakeAnsStrX
     dec bc
     ld a,c
     ld (de),a
     inc de
     ld hl,88ECh
     ldir
     ret
CountBytes:
     push hl
     push bc
     xor a
     ld hl,86ECh
     ld (hl),a
     ld d,h
     ld e,l
     inc de
     ld bc,2FFh
     ldir
     pop bc
     pop hl
GetCodecLoop:
     push bc
     ld e,(hl)
     ld d,0
     ex de,hl
     add hl,hl
     ld bc,86ECh
     add hl,bc
     inc (hl)
     jr nz,$+4
     inc hl
     inc (hl)
     ex de,hl
     pop bc
     cpi
     jp pe,GetCodecLoop
     call Order
     ld b,0
     inc bc
     ret
Order:
     di
     ld hl,86ECh     ;points to the density list (512 bytes)
     ld de,88ECh     ;points to where the output is
     ld bc,0
     ld (TempWord1),hl
     exx
     ld hl,0         ;MaxVal
     exx
OrderLoop:
     push bc
     ld c,(hl)
     inc hl
     ld b,(hl)
     inc hl
     push bc
     exx
     pop de
     or a
     sbc hl,de
     add hl,de
     jr nc,$+3
       ex de,hl
     exx
     pop bc
     djnz OrderLoop
     ld hl,(TempWord1)
     exx
     ld a,h
     or l
     exx
     ret z
     xor a
OrderLoop1:
     push bc
     ld c,(hl)
     inc hl
     ld b,(hl)
     push bc
     exx
     pop de
     or a
     sbc hl,de
     add hl,de
     exx
     pop bc
     jr nz,$+12
       ld (de),a
       inc de
       ld (hl),0
       dec hl
       ld (hl),0
       inc hl
       inc c
       ret z
     inc hl
     inc a
     djnz OrderLoop1
     ld hl,(TempWord1)
     jr OrderLoop-5

1389
Other Calc-Related Projects and Ideas / Re: OmniRPG - Coding
« on: December 09, 2012, 07:43:20 am »
I started working on scrolling in the up/down direction, and it is a pain o.o I have to keep track of how far up/down it is scrolled and left/right so that I can shift in new content appropriately .__. I rewrote the right/left shifting, too and I believe it is faster, but I'm not suree (I had a better idea last night, so I don't need the IX register). Also, I have a bug somewhere in the code, apparently, because the program is doing weird stuff to my calculator every so often. On the plus side, I fixed the scrolling bug for left/right >.>

On another note, if we decided to do text compression, I have a nice algorithm for that. I was thinking this morning that I could make a Python program to read a .txt file and spit out the compressed data in assembly format.

EDIT: It is still about 60FPS at 6MHz, a few extra frames per second for shifting up/down.

1390
Other Calc-Related Projects and Ideas / Re: OmniRPG - Coding
« on: December 08, 2012, 08:20:47 pm »
Well, I figure that if we use an app, we can have more code space (16KB and an 8KB program). We can still use axioms and use an app :P

1391
Other Calc-Related Projects and Ideas / Re: OmniRPG - Coding
« on: December 08, 2012, 07:48:42 pm »
Axioms don't make it so you need another app or program to run, it only means that you need them to compile the source.

Also, @stevon8ter: The program starts off with a Pause 100 at 6MHz. keep watching and I remove the Pause 100 and show its speed, then I show it at 15MHz. At 15MHz, WabbitEmu tells me I am getting 80 FPS and 60FPS at 6MHz.  I think we should keep it at 6MHz for the main engine and routines so that it stays nicely compatible with the 83+

1392
Other Calc-Related Projects and Ideas / Re: OmniRPG - Main Topic
« on: December 08, 2012, 07:06:50 pm »
I'll take this conversation over to the Coding topic, since it will be important for others.

1393
Other Calc-Related Projects and Ideas / Re: OmniRPG - Main Topic
« on: December 08, 2012, 07:04:21 pm »
If I have 16KB to work with, I could make routines that can work directly with archive and do it quickly >.> It would technically be slower, but it probably wouldn't be noticeable.

1394
Other Calc-Related Projects and Ideas / Re: OmniRPG - Main Topic
« on: December 08, 2012, 07:00:03 pm »
Oh, okay. And I was thinking that using an app, I could write routines to directly access the data in archived appvars. This would help quite a bit with map data, tile data, and sprite data. I could maybe make a command to copy a sprite from archive to a location in RAM (that way it can be accessed by the main program).

1395
Other Calc-Related Projects and Ideas / Re: OmniRPG - Main Topic
« on: December 08, 2012, 06:54:24 pm »
You mean loading the appvars as programs? I did that with Grammer, so it is quite doable :)

Pages: 1 ... 91 92 [93] 94 95 ... 317