|
Post by socram8888 on Mar 2, 2011 10:01:43 GMT -5
Long time without asking anything.
Well, some people at a Spanish forum tought about creating a videogame using BasiEgaXorz, and I'm working as a "coprogrammer", doing some coding
Well, in order to make the game smaller, I'm trying to build a compression/decompression function in Assembler, using a RLE-4 (Run Length Encode with 4 bits of data). A real uncompressed tile looks like this: 11 11 11 12 11 11 11 14 11 11 11 14 11 11 11 14 11 11 11 16 11 11 11 12 11 11 11 12 11 11 11 12 And RLE-4 compressed is: 71 12 71 14 71 14 71 14 71 16 71 12 71 12 71 42
That is: 7 times 1 2 once 7 times 1 4 once and so on
Here's the decompressing routine:
lea.l DummyTestData, a0 move.l #$FFFF00, a1 move.b #4, d4 clr.b d3 GetNext: move.b (a0)+, d0 move.b d0, d1 lsr.b #4, d1 cmp.b #0, d1 bne.b NotZero rts NotZero: move.b d0, d2 and.b #15, d2 Loop: move.b d2, d5 lsl.b d4, d5 or.b d5, d3 cmp.b #0, d4 bne.b DoNotSave move.b d3, (a1)+ clr.b d3 move.b #8, d4 DoNotSave: subq.b #4, d4 subq.b #1, d1 cmp.b #0, d1 bne.b Loop beq.b GetNext
DummyTestData: dc.b $55, $11, $89, $98, $01 On EASy68K it works perfectly, but in Gens KMod it does strange things like adding 2 instead of 1 in "(a1)+", or setting a1 to the start value, etc...
I tried disabling the interruptions and so on, but i'm unable to get it working
PS: Of course I'm using "@label" on BEX instead of "label" and I'm loading the DummyTestData from a data file
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Mar 2, 2011 13:00:47 GMT -5
That sounds weird. Try another address instead of $FFFF000, like $FFF000 (or declare a variable and extract the address using &varptr) because the stack may overwrite. And uhm, I also hope you have an RTS after "beq.b GetNext"
|
|
|
Post by socram8888 on Mar 2, 2011 13:47:44 GMT -5
Well, I have a BNE and a BEQ, so it must branch anyway (because if it's not different - BNE, then it must have the same value - BEQ)
I'll try with another location...
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Mar 2, 2011 16:34:30 GMT -5
I dunno if this will help either, but maybe try doing "lea.l DummyTestData(PC), a0", as in fetch the location relative to PC. I would also look at the hex output of the assembled program to see if the asmx didn't do anything funny
|
|
|
Post by Mairtrus on Mar 2, 2011 17:33:13 GMT -5
You are using it as a User Defined subroutine? Because remember that BEX doesn't pass an offset as a parameter, unless you use VarPtr&, LblPtr&, etc... I don't remember right, but I think I too had problems trying to pass an offset directly to a An register (I had to move it to a Dn register, the to an An register) Aditionally, are you using the RAM viewer to check the status of the decompressed data? Because maybe this is what is confusing you: sometimes, when accesing a large amount of contiguous bytes, seems that KMod swap the odd and even bytes in a same word, but only in the RAM viewer, not in the real RAM (you can check this with a peek+print loop).
|
|
|
Post by socram8888 on Mar 3, 2011 8:27:49 GMT -5
I'm using A6 as input data offset, because this is set to the data block after doing a "reload". And yes, that part works and it's really set to the dummy data
|
|
|
Post by socram8888 on Mar 3, 2011 13:18:36 GMT -5
Well, I tried using another location (FFF000) and it's still glitchy :/
/offtopic: Does anyone how does the Gens KMod debugging works? I want to send to Messages some debugging info, but writting data to VDP register 30 does not work :S move.w #$9E35, d0 move.l #$C00004, a6 move.w d0, (a6) unl: bra unl
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Mar 3, 2011 14:34:58 GMT -5
I'm using A6 as input data offset, because this is set to the data block after doing a "reload". And yes, that part works and it's really set to the dummy data Oh, try using another address register. I don't remember what A6 does - I think this stores a pointer to the heap, but BasiEgaXorz loves to change this variable on the fly . I think address registers A3-A7 are taken by the compiler, so you only have A0-A2 to play with
|
|
|
Post by socram8888 on Mar 3, 2011 16:41:43 GMT -5
A6 is used as data pointer. Anyway, I'm copying it before doing anything to A0
I'll try tomorrow using a loop of peek/prints :/
|
|
|
Post by socram8888 on Mar 4, 2011 14:22:20 GMT -5
Finally got it working. It was that byte-swapping error, but using Peek/prints shows everything ok
|
|