.equ PDRAW_PLANE_HI_PRIO, (1<<6)\r
.equ PDRAW_SHHI_DONE, (1<<7)\r
\r
-@ helper\r
+@ helpers\r
+.macro add_c24 d s c\r
+ add \d, \s, #(\c & 0x00ff00)\r
+.if \c & 0x0000ff\r
+ add \d, \d, #(\c & 0x0000ff)\r
+.endif\r
+.if \c & 0xff0000\r
+ add \d, \d, #(\c & 0xff0000)\r
+.endif\r
+.endm\r
+\r
.macro TilePixel pat lsrr offs\r
.if !\lsrr\r
ands r4, \pat, r2\r
@ int cells; // 0x14\r
@ };\r
\r
-@ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,\r
+@ void DrawLayer(int lflags, int *hcache, int cellskip, int maxcells,\r
@ struct PicoEState *est)\r
\r
.global DrawLayer\r
ldr r12, [sp] @ est\r
stmfd sp!, {r4-r11,lr}\r
\r
- ldr r11, [r12, #OFS_Pico_video]\r
+ ldr r11, [r12, #OFS_EST_Pico]\r
mov r8, #1\r
\r
- ldrb r7, [r11, #16] @ ??vv??hh\r
+ ldrb r7, [r11, #OFS_Pico_video_reg+16] @ ??vv??hh\r
\r
mov r6, r1 @ hcache\r
- orr r9, r3, r0, lsl #30\r
- orr r9, r9, r2, lsl #8 @ r9=sh[31]|cellskip[15:8]|maxcells[7:0] (tmp)\r
+ orr r9, r3, r0, lsl #29 @ r9=force[31]|sh[30]|plane[29]\r
+ orr r9, r9, r2, lsl #8 @ |cellskip[15:8]|maxcells[7:0] (tmp)\r
\r
mov r1, r7, lsl #4\r
orr r1, r1, #0x00ff\r
cmp r10, #1\r
biclt r1, r1, #0xfc00\r
biceq r1, r1, #0xfe00\r
- bicgt r1, r1, #0xff00 @ r1=ymask=(height<<8)|0xff; ...; // Y Mask in pixels\r
+ cmp r10, #2\r
+ moveq r1, #0x0007\r
+ movgt r1, #0x00ff @ r1=ymask=(height<<8)|0xff; ...; // Y Mask in pixels\r
\r
add r10, r10, #5\r
cmp r10, #7\r
subge r10, r10, #1 @ r10=shift[width] (5,6,6,7)\r
\r
- ldr r2, [r12, #OFS_DrawScanline]\r
- ldr lr, [r12, #OFS_Pico_vram]\r
+ ldr r2, [r12, #OFS_EST_DrawScanline]\r
+ ldr lr, [r12, #OFS_EST_PicoMem_vram]\r
\r
@ Find name table:\r
ands r0, r0, #1\r
- ldreqb r12, [r11, #2]\r
- ldrneb r12, [r11, #4]\r
+ ldreqb r12, [r11, #OFS_Pico_video_reg+2]\r
+ ldrneb r12, [r11, #OFS_Pico_video_reg+4]\r
\r
@ calculate xmask:\r
mov r5, r8, lsl r10\r
movne r12, r12, lsl #13\r
and r12, r12, #(7<<13) @ r12=(ts->nametab<<1) (halfword compliant)\r
\r
- ldrh r8, [r11, #12]\r
- ldrb r7, [r11, #11]\r
+ ldrh r8, [r11, #OFS_Pico_video_reg+12]\r
+ ldrb r7, [r11, #OFS_Pico_video_reg+11]\r
\r
mov r4, r8, lsr #8 @ pvid->reg[13]\r
mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords)\r
bne .DrawStrip_vsscroll\r
\r
@ Get vertical scroll value:\r
- add r7, lr, #0x012000\r
- add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)\r
+ add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)\r
ldr r7, [r7]\r
\r
tst r8, #2\r
and r1, r1, #7\r
add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1\r
\r
- tst r9, #1<<31\r
+ movs r3, r9, lsl #1 @ (force[31]|sh[30]) << 1\r
mov r3, #0\r
- orrne r10,r10, #1<<23 @ r10=(cells<<24|sh<<23|hi_not_empty<<22|had_output<<21|ty)\r
- movne r3, #0x40 @ default to shadowed pal on sh mode\r
+ orrmi r10,r10, #1<<23 @ r10=cells[31:24]|sh[23]|hi_not_empty[22]\r
+ orrcs r10,r10, #1<<20 @ |had_output[21]|force[20]|ty[15:0]\r
+ movmi r3, #0x40 @ default to shadowed pal on sh mode\r
\r
cmp r7, #8\r
addne r10,r10, #0x01000000 @ we will loop cells+1 times if there is scroll\r
@ cache some stuff to avoid mem access\r
ldr r11,[sp, #9*4] @ est\r
mov r0, #0xf\r
- ldr r11,[r11, #OFS_HighCol]\r
+ ldr r11,[r11, #OFS_EST_HighCol]\r
\r
mvn r9, #0 @ r9=prevcode=-1\r
add r1, r11, r7 @ r1=pdest\r
add r8, r8, #1\r
\r
tst r7, #0x8000\r
+ tsteq r10, #1<<20 @ force?\r
bne .DrawStrip_hiprio\r
\r
cmp r7, r9\r
orr r10, r10, #1<<22\r
\r
.DrawStrip_hiprio:\r
- tst r10, #0x00c00000\r
+ tst r10, #0x00d00000 @ sh[23]|hi_not_empty[22]|force[20]\r
beq .DrawStrip_hiprio_maybempt\r
sub r0, r1, r11\r
orr r7, r7, r0, lsl #16\r
tst r10, #1<<21 @ seen non hi-prio tile\r
ldr r1, [sp, #9*4] @ est\r
mov r0, #0\r
- ldreq r2, [r1, #OFS_rendstatus]\r
+ ldreq r2, [r1, #OFS_EST_rendstatus]\r
str r0, [r6] @ terminate the cache list\r
orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles\r
- streq r2, [r1, #OFS_rendstatus]\r
+ streq r2, [r1, #OFS_EST_rendstatus]\r
\r
ldmfd sp!, {r4-r11,lr}\r
bx lr\r
\r
ldr r11, [sp, #9*4] @ est\r
orr r5, r1, r10, lsl #24\r
- ldr r4, [r11, #OFS_DrawScanline]\r
+ ldr r4, [r11, #OFS_EST_DrawScanline]\r
sub r1, r3, #1\r
orr r5, r5, r4, lsl #16 @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0])\r
and r1, r1, #7\r
add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1\r
\r
mov r10,r9, lsl #16\r
+ orr r10,r10, #0xff000000 @ will be adjusted on entering loop\r
tst r0, #1\r
orrne r10,r10, #0x8000\r
+ tst r3, #0x0f @ hscroll & 0x0f?\r
+ beq 0f\r
+ eor r3, r3, r7\r
+ sub r10,r10, #1<<24 @ cell-- // start from negative for hscroll\r
+ tst r3, #0x08\r
+ subne r10,r10, #1<<16 @ cells--\r
+ subne r10,r10, #1<<24 @ cell-- // even more negative\r
+0:\r
tst r9, #1<<31\r
mov r3, #0\r
- orr r10,r10, #0xff000000 @ will be adjusted on entering loop\r
orrne r10,r10, #1<<23 @ r10=(cell[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0])\r
movne r3, #0x40 @ default to shadowed pal on sh mode\r
\r
- cmp r7, #8\r
- subne r10,r10, #0x01000000 @ have hscroll, start with negative cell\r
-\r
and r9, r9, #0xff00\r
add r8, r8, r9, lsr #8 @ tilex+=cellskip\r
add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;\r
@ cache some stuff to avoid mem access\r
ldr r11,[sp, #9*4] @ est\r
mov r0, #0xf\r
- ldr r11,[r11, #OFS_HighCol]\r
+ ldr r11,[r11, #OFS_EST_HighCol]\r
\r
mvn r9, #0 @ r9=prevcode=-1\r
add r1, r11, r7 @ r1=pdest\r
ble .dsloop_vs_exit\r
\r
@ calc offset and read tileline code to r7, also calc ty\r
- add r7, lr, #0x012000\r
- add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)\r
+ add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)\r
add r7, r7, r10,asr #23 @ vsram + ((cell&~1)<<1)\r
bic r7, r7, #3\r
tst r10,#0x8000 @ plane1?\r
mov r4, r4, lsl r7 @ nametabadd\r
\r
and r7, r8, r8, lsr #25\r
- add r7, lr, r7, lsl #1 @ Pico.vram+((tilex&ts->xmask) as halfwords)\r
+ add r7, lr, r7, lsl #1 @ PicoMem.vram+((tilex&ts->xmask) as halfwords)\r
add r7, r7, r4, lsl #1\r
ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)\r
\r
mov r2, r2, lsr #17\r
eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;\r
\r
- ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+ ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
\r
bic r7, r3, #0x3f\r
and r3, r9, #0x6000\r
add r2, r2, r10, lsl #17\r
mov r2, r2, lsr #17\r
eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;\r
- ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+ ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
mov r9, r7 @ remember code\r
tst r2, r2\r
orrne r10, r10, #1<<22\r
tst r8, #(1<<24) @ seen non hi-prio tile\r
ldr r1, [sp, #9*4] @ est\r
mov r0, #0\r
- ldreq r2, [r1, #OFS_rendstatus]\r
+ ldreq r2, [r1, #OFS_EST_rendstatus]\r
str r0, [r6] @ terminate the cache list\r
orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles\r
- streq r2, [r1, #OFS_rendstatus]\r
+ streq r2, [r1, #OFS_EST_rendstatus]\r
\r
ldmfd sp!, {r4-r11,lr}\r
bx lr\r
stmfd sp!, {r4-r9,lr}\r
\r
mov r0, r0, lsl #26\r
- ldr lr, [r2, #OFS_HighCol]\r
+ ldr lr, [r2, #OFS_EST_HighCol]\r
mov r0, r0, lsr #26\r
add lr, lr, #8\r
\r
stmfd sp!, {r4-r9,r11,lr}\r
\r
@ cache some stuff to avoid mem access\r
- ldr r11,[r3, #OFS_HighCol]\r
+ ldr r11,[r3, #OFS_EST_HighCol]\r
mov r12,#0xf\r
- ldr lr, [r3, #OFS_Pico_vram]\r
+ ldr lr, [r3, #OFS_EST_PicoMem_vram]\r
mov r9, r3 @ est\r
\r
mvn r5, #0 @ r5=prevcode=-1\r
bic r4, r1, #0xfe00\r
add r1, r11, r4 @ r1=pdest\r
\r
- mov r7, r6, lsl #16\r
+ movs r7, r6, lsl #16\r
+ bpl .dtfc_loop @ !(code & 0x8000)\r
cmp r5, r7, lsr #16\r
beq .dtfc_samecode @ if (code==prevcode)\r
\r
\r
@ check if we have detected layer covered with hi-prio tiles:\r
.dtfc_check_rendflags:\r
- ldr r2, [r9, #OFS_rendstatus]\r
+ ldr r2, [r9, #OFS_EST_rendstatus]\r
tst r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE)\r
beq .dtfc_loop\r
bic r8, r8, #1 @ sh/hi mode off\r
tst r2, #PDRAW_SHHI_DONE\r
bne .dtfc_loop @ already processed\r
orr r2, r2, #PDRAW_SHHI_DONE\r
- str r2, [r9, #OFS_rendstatus]\r
+ str r2, [r9, #OFS_EST_rendstatus]\r
\r
add r1, r11,#8\r
mov r3, #320/4/4\r
add r10,r0, #3 @ r10=HighLnSpr end\r
add r10,r10,r3 @ r10=HighLnSpr end\r
\r
- ldr r11,[r1, #OFS_HighCol]\r
+ ldr r11,[r1, #OFS_EST_HighCol]\r
mov r12,#0xf\r
- ldr lr, [r1, #OFS_Pico_vram]\r
+ ldr lr, [r1, #OFS_EST_PicoMem_vram]\r
\r
\r
DrawSpriteSHi:\r
@ draw next sprite\r
ldrb r0, [r10,#-1]!\r
ldr r7, [sp] @ est\r
- ldr r1, [r7, #OFS_HighPreSpr]\r
+ ldr r1, [r7, #OFS_EST_HighPreSpr]\r
cmp r0, #0xff\r
ldmeqfd sp!, {r1,r4-r11,pc} @ end of list\r
and r0, r0, #0x7f\r
mov r5, r3, lsr #24\r
and r5, r5, #7 @ r5=height\r
\r
- ldr r7, [r7, #OFS_DrawScanline]\r
+ ldr r7, [r7, #OFS_EST_DrawScanline]\r
mov r0, r3, lsl #16 @ r4=sy<<16 (tmp)\r
\r
sub r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy\r
mov r8, r8, lsl #17\r
mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address\r
\r
- ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+ ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
add r1, r11, r0 @ r1=pdest\r
tst r2, r2\r
beq .dsprShi_loop\r
\r
DrawAllSprites:\r
orr r1, r2, r1, lsl #1\r
- ldr r12,[r3, #OFS_rendstatus]\r
- tst r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)\r
- beq das_no_prep\r
- stmfd sp!, {r0,r1,r3,lr}\r
- and r0, r12,#PDRAW_DIRTY_SPRITES\r
- bic r12,r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)\r
- str r12,[r3, #OFS_rendstatus]\r
- bl PrepareSprites\r
- ldmfd sp!, {r0,r1,r3,lr}\r
-\r
-das_no_prep:\r
ldr r2, [r0]\r
ands r2, r2, #0x7f\r
bxeq lr\r
add r10,r0, #3\r
add r10,r10,r2 @ r10=HighLnSpr end\r
\r
- ldr r11,[r3, #OFS_HighCol]\r
+ ldr r11,[r3, #OFS_EST_HighCol]\r
mov r12,#0xf\r
- ldr lr, [r3, #OFS_Pico_vram]\r
+ ldr lr, [r3, #OFS_EST_PicoMem_vram]\r
\r
@ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size\r
@ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8\r
ldmeqfd sp!, {r1,r3-r11,pc} @ end of list\r
cmp r2, r8, lsr #1\r
bne DrawSprite @ wrong priority\r
- ldr r1, [r7, #OFS_HighPreSpr]\r
+ ldr r1, [r7, #OFS_EST_HighPreSpr]\r
and r0, r0, #0x7f\r
add r0, r1, r0, lsl #3\r
\r
ldr r3, [r0] @ sprite[0]\r
- ldr r7, [r7, #OFS_DrawScanline]\r
+ ldr r7, [r7, #OFS_EST_DrawScanline]\r
mov r6, r3, lsr #28\r
sub r6, r6, #1 @ r6=width-1 (inc later)\r
mov r5, r3, lsr #24\r
mov r8, r8, lsl #17\r
mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address\r
\r
- ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+ ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
add r1, r11, r0 @ r1=pdest\r
tst r2, r2\r
beq .dspr_loop\r
ldr r12, [sp] @ est\r
stmfd sp!, {r4-r11,lr}\r
\r
- ldr r6, [r12, #OFS_Pico_video]\r
- ldr r10, [r12, #OFS_DrawScanline]\r
+ ldr r6, [r12, #OFS_EST_Pico]\r
+ ldr r10, [r12, #OFS_EST_DrawScanline]\r
mov r11, r12 @ est\r
- ldrb r12, [r6, #3] @ pvid->reg[3]\r
+ ldrb r12, [r6, #OFS_Pico_video_reg+3] @ pvid->reg[3]\r
\r
- ldr r4, [r6, #12]\r
+ ldr r4, [r6, #OFS_Pico_video_reg+12]\r
mov r5, r10, lsr #3\r
and r10, r10, #7\r
mov r10, r10, lsl #1 @ r10=ty\r
addeq r12, r12, r5, lsl #6 @ nametab\r
add r12, r12, r0, lsl #2 @ +starttile\r
\r
- ldr lr, [r11, #OFS_Pico_vram]\r
- ldr r6, [r11, #OFS_rendstatus]\r
+ ldr lr, [r11, #OFS_EST_PicoMem_vram]\r
+ ldr r6, [r11, #OFS_EST_rendstatus]\r
\r
@ fetch the first code now\r
ldrh r7, [lr, r12]\r
sub r8, r1, r0\r
\r
@ cache some stuff to avoid mem access\r
- ldr r11, [r11, #OFS_HighCol]\r
+ ldr r11, [r11, #OFS_EST_HighCol]\r
mov r8, r8, lsl #1 @ cells\r
add r11,r11,#8\r
mvn r9, #0 @ r9=prevcode=-1\r
and r2, r6, #PDRAW_WND_DIFF_PRIO\r
ldmfd sp!, {r4-r11,lr}\r
ldr r0, [sp]\r
- ldr r1, [r0, #OFS_rendstatus]\r
+ ldr r1, [r0, #OFS_EST_rendstatus]\r
orr r1, r1, r2\r
- str r1, [r0, #OFS_rendstatus]\r
+ str r1, [r0, #OFS_EST_rendstatus]\r
\r
bx lr\r
\r
stmfd sp!, {r4-r10,lr}\r
mov r10,r2 @ est\r
mov r1, #0\r
- ldr r8, [r10, #OFS_Pico_video]\r
+ ldr r8, [r10, #OFS_EST_Pico]\r
\r
PicoDoHighPal555_nopush:\r
orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h\r
\r
- add r0, r10, #OFS_HighPal\r
+ add r0, r10, #OFS_EST_HighPal\r
\r
mov r1, #0\r
- strb r1, [r8, #-0x1a] @ 0x2220e ~ dirtyPal\r
+ strb r1, [r8, #OFS_Pico_m_dirtyPal]\r
\r
- sub r1, r8, #0x128 @ r1=Pico.cram\r
+ ldr r1, [r10, #OFS_EST_PicoMem_cram]\r
mov r2, #0x40\r
mov r8, #0x0061\r
orr r8, r8, #0x0800\r
tst r9, #(1<<31)\r
beq PicoDoHighPal555_end\r
\r
- add r3, r10, #OFS_HighPal\r
+ add r3, r10, #OFS_EST_HighPal\r
\r
@ shadowed pixels:\r
mov r12, #0x008e\r
tst r9, #1\r
ldmeqfd sp!, {r4-r10,pc}\r
\r
- ldr r8, [r10, #OFS_Pico_video]\r
+ ldr r8, [r10, #OFS_EST_Pico]\r
b FinalizeLineRGB555_pal_done\r
\r
\r
FinalizeLine555:\r
stmfd sp!, {r4-r10,lr}\r
mov r10,r2 @ est\r
- ldr r8, [r10, #OFS_Pico_video]\r
+ ldr r8, [r10, #OFS_EST_Pico]\r
\r
- ldrb r2, [r8, #-0x1a] @ 0x2220e ~ dirtyPal\r
+ ldrb r2, [r8, #OFS_Pico_m_dirtyPal]\r
mov r1, #1\r
tst r2, r2\r
bne PicoDoHighPal555_nopush\r
\r
FinalizeLineRGB555_pal_done:\r
- add r3, r10, #OFS_HighPal\r
+ add r3, r10, #OFS_EST_HighPal\r
\r
- ldr r12, [r10, #OFS_rendstatus]\r
+ ldr r12, [r10, #OFS_EST_rendstatus]\r
eors r0, r0, #1 @ sh is 0\r
mov lr, #0xff\r
tstne r12,#PDRAW_ACC_SPRITES\r
movne lr, #0x3f\r
\r
- ldr r1, [r10, #OFS_HighCol]\r
- ldr r0, [r10, #OFS_DrawLineDest]\r
+ ldr r1, [r10, #OFS_EST_HighCol]\r
+ ldr r0, [r10, #OFS_EST_DrawLineDest]\r
add r1, r1, #8\r
\r
- ldrb r12, [r8, #12]\r
+ ldrb r12, [r8, #OFS_Pico_video_reg+12]\r
mov lr, lr, lsl #1\r
\r
tst r12, #1\r
movne r2, #320/8 @ len\r
bne .fl_no32colRGB555\r
- ldr r4, [r10, #OFS_PicoOpt]\r
+ ldr r4, [r10, #OFS_EST_PicoOpt]\r
mov r2, #256/8\r
ldr r4, [r4]\r
tst r4, #0x4000\r