0 Members and 8 Guests are viewing this topic.
I'm sure you can make it at least twice faster with ASM, because if I had to make the drawing code in C it would be (direct translation from Axe) :Code: [Select]for(y = 0; y < 64; y++) for(x = 0; x < 96; x++) plotSScreen[y * 96 + x] = texture[ (ylut[y * 96 + x] & 7) * 8 + xlut[y * 96 + x] ];Lemme get on my PC and I'll attach the source.
for(y = 0; y < 64; y++) for(x = 0; x < 96; x++) plotSScreen[y * 96 + x] = texture[ (ylut[y * 96 + x] & 7) * 8 + xlut[y * 96 + x] ];
;°xlut -> A;°ylut -> BRender: ld hl, plotsScreen push hlRenderLoop: ld c, 8 xor aByteLoop: ld hl, (A) ld b, (hl) ld hl, (B) ld e, (hl) ld d, 0 ld hl, texture add hl, de ld d, (hl) inc bTexelLoop: sra d djnz TexelLoop set 0, a jr c, TexelEnd res 0, aTexelEnd: ld hl, (A) inc hl ld (A), hl ld hl, (B) inc hl ld (B), hl sla a dec c jr nz, ByteLoop rr a pop hl ld (hl), a inc hl push hl ld de, Plotsscreen+768 or a sbc hl, de jr z, RenderLoop pop hl ret
You don't need to unpack anything. Just store a number from 1-64 which corresponds with the index of each pixel in the texture as if it was a 1-D array.
Quote from: Matrefeytontias on January 26, 2014, 11:03:00 amI'm sure you can make it at least twice faster with ASM, because if I had to make the drawing code in C it would be (direct translation from Axe) :Code: [Select]for(y = 0; y < 64; y++) for(x = 0; x < 96; x++) plotSScreen[y * 96 + x] = texture[ (ylut[y * 96 + x] & 7) * 8 + xlut[y * 96 + x] ];Lemme get on my PC and I'll attach the source.I hope this code is slightely faster, but I haven't been able to test it, so I'm not sure if it even works.Code: [Select];°xlut -> A;°ylut -> BRender: ld hl, plotsScreen push hlRenderLoop: ld c, 8 xor aByteLoop: ld hl, (A) ld b, (hl) ld hl, (B) ld e, (hl) ld d, 0 ld hl, texture add hl, de ld d, (hl) inc bTexelLoop: sra d djnz TexelLoop set 0, a jr c, TexelEnd res 0, aTexelEnd: ld hl, (A) inc hl ld (A), hl ld hl, (B) inc hl ld (B), hl sla a dec c jr nz, ByteLoop rr a pop hl ld (hl), a inc hl push hl ld de, Plotsscreen+768 or a sbc hl, de jr z, RenderLoop pop hl ret
// usual for loops, x, yplotSScreen[y * 96 + x] = texture[ tlut[y * 96 + x] ];
:for(A,0,6144):plotsScreen[A] = texture[tlut[A]]:End
Asm(214093E50E08AF2A02805E160021(°Texture)1946CBC7CB402802CB872A028023220280CB270D20E1CB1FE17723E5114096B7ED5220D0E1)
Render: ld hl, plotsScreen push hlRenderLoop: ld c, 8 xor aByteLoop: ld hl, ($8002) ld e, (hl) ld d, 0 ld hl, texture add hl, de ld b, (hl) set 0, a bit 0, b jr z, TexelEnd res 0, aTexelEnd: ld hl, ($8002) inc hl ld ($8002), hl sla a ;optimization: add a, a dec c jr nz, ByteLoop rr a pop hl ld (hl), a inc hl push hl ld de, Plotsscreen+768 or a sbc hl, de jr nz, RenderLoop pop hl ret#commentHEX:214093E5 -> 4 bytesRenderLoop:0E08AF -> 3 bytesByteLoop:2A02805E1600 -> 6 bytes21(°Texture) -> 3 bytes ld hl, texture1946CBC7CB40 -> 6 bytes2802 -> 2 bytes jr z, TexelEndCB87 -> 2 bytesTexelEnd:2A028023220280CB270D -> 10 bytes20E1 -> 2 bytes jr nz, ByteLoopCB1FE17723E5114096B7ED52 -> 12 bytes20D0 -> 2 bytes jr nz, renderLoopE1 -> 1 byteTOTAL COMMAND:Asm(214093E50E08AF2A02805E160021(°Texture)1946CBC7CB402802CB872A028023220280CB270D20E1CB1FE17723E5114096B7ED5220D0E1)#endcomment