fix cell scroll drawing

This commit is contained in:
notaz 2017-10-08 22:33:04 +03:00
parent c041308933
commit cf07a88d6e
6 changed files with 48 additions and 17 deletions

View file

@ -261,7 +261,11 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
// Draw tiles across screen: // Draw tiles across screen:
tilex=(-ts->hscroll)>>3; tilex=(-ts->hscroll)>>3;
dx=((ts->hscroll-1)&7)+1; dx=((ts->hscroll-1)&7)+1;
if(dx != 8) cell--; // have hscroll, start with negative cell if (ts->hscroll & 0x0f) {
int adj = ((ts->hscroll ^ dx) >> 3) & 1;
cell -= adj + 1;
ts->cells -= adj;
}
cell+=cellskip; cell+=cellskip;
tilex+=cellskip; tilex+=cellskip;
dx+=cellskip<<3; dx+=cellskip<<3;

View file

@ -73,8 +73,17 @@ BackFillFull:
@ -------- some macros -------- @ -------- some macros --------
@ helpers
.macro add_c24 d s c
add \d, \s, #(\c & 0x00ff00)
.if \c & 0x0000ff
add \d, \d, #(\c & 0x0000ff)
.endif
.if \c & 0xff0000
add \d, \d, #(\c & 0xff0000)
.endif
.endm
@ helper
@ TileLineSinglecol (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: pixels8_old @ TileLineSinglecol (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: pixels8_old
.macro TileLineSinglecol notsinglecol=0 .macro TileLineSinglecol notsinglecol=0
and r2, r2, #0xf @ #0x0000000f and r2, r2, #0xf @ #0x0000000f
@ -411,8 +420,7 @@ DrawLayerFull:
mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW); mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW);
@ Get vertical scroll value: @ Get vertical scroll value:
add r7, r10, #0x012000 add_c24 r7, r10, (OFS_PMEM_vsram-OFS_PMEM_vram)
add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
ldr r7, [r7] ldr r7, [r7]
tst r0, r0 tst r0, r0
moveq r7, r7, lsl #22 moveq r7, r7, lsl #22

View file

@ -19,7 +19,17 @@
.equ PDRAW_PLANE_HI_PRIO, (1<<6) .equ PDRAW_PLANE_HI_PRIO, (1<<6)
.equ PDRAW_SHHI_DONE, (1<<7) .equ PDRAW_SHHI_DONE, (1<<7)
@ helper @ helpers
.macro add_c24 d s c
add \d, \s, #(\c & 0x00ff00)
.if \c & 0x0000ff
add \d, \d, #(\c & 0x0000ff)
.endif
.if \c & 0xff0000
add \d, \d, #(\c & 0xff0000)
.endif
.endm
.macro TilePixel pat lsrr offs .macro TilePixel pat lsrr offs
.if !\lsrr .if !\lsrr
ands r4, \pat, r2 ands r4, \pat, r2
@ -344,8 +354,7 @@ DrawLayer:
bne .DrawStrip_vsscroll bne .DrawStrip_vsscroll
@ Get vertical scroll value: @ Get vertical scroll value:
add r7, lr, #0x012000 add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)
add r7, r7, #0x000180 @ r7=PicoMem.vsram (PicoMem+0x22180)
ldr r7, [r7] ldr r7, [r7]
tst r8, #2 tst r8, #2
@ -522,17 +531,22 @@ DrawLayer:
add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1 add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
mov r10,r9, lsl #16 mov r10,r9, lsl #16
orr r10,r10, #0xff000000 @ will be adjusted on entering loop
tst r0, #1 tst r0, #1
orrne r10,r10, #0x8000 orrne r10,r10, #0x8000
tst r3, #0x0f @ hscroll & 0x0f?
beq 0f
eor r3, r3, r7
sub r10,r10, #1<<24 @ cell-- // start from negative for hscroll
tst r3, #0x08
subne r10,r10, #1<<16 @ cells--
subne r10,r10, #1<<24 @ cell-- // even more negative
0:
tst r9, #1<<31 tst r9, #1<<31
mov r3, #0 mov r3, #0
orr r10,r10, #0xff000000 @ will be adjusted on entering loop
orrne r10,r10, #1<<23 @ r10=(cell[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0]) orrne r10,r10, #1<<23 @ r10=(cell[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0])
movne r3, #0x40 @ default to shadowed pal on sh mode movne r3, #0x40 @ default to shadowed pal on sh mode
cmp r7, #8
subne r10,r10, #0x01000000 @ have hscroll, start with negative cell
and r9, r9, #0xff00 and r9, r9, #0xff00
add r8, r8, r9, lsr #8 @ tilex+=cellskip add r8, r8, r9, lsr #8 @ tilex+=cellskip
add r7, r7, r9, lsr #5 @ dx+=cellskip<<3; add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
@ -556,8 +570,7 @@ DrawLayer:
ble .dsloop_vs_exit ble .dsloop_vs_exit
@ calc offset and read tileline code to r7, also calc ty @ calc offset and read tileline code to r7, also calc ty
add r7, lr, #0x012000 add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)
add r7, r7, #0x000180 @ r7=PicoMem.vsram (PicoMem+0x22180)
add r7, r7, r10,asr #23 @ vsram + ((cell&~1)<<1) add r7, r7, r10,asr #23 @ vsram + ((cell&~1)<<1)
bic r7, r7, #3 bic r7, r7, #3
tst r10,#0x8000 @ plane1? tst r10,#0x8000 @ plane1?

View file

@ -356,7 +356,6 @@ struct PicoEState
unsigned short HighPal[0x100]; unsigned short HighPal[0x100];
}; };
// some assembly stuff still depends on these, do not touch!
struct PicoMem struct PicoMem
{ {
unsigned char ram[0x10000]; // 0x00000 scratch ram unsigned char ram[0x10000]; // 0x00000 scratch ram
@ -366,9 +365,9 @@ struct PicoMem
}; };
unsigned char zram[0x2000]; // 0x20000 Z80 ram unsigned char zram[0x2000]; // 0x20000 Z80 ram
unsigned char ioports[0x10]; // XXX: fix asm and mv unsigned char ioports[0x10]; // XXX: fix asm and mv
unsigned char pad[0xf0]; // unused unsigned short cram[0x40]; // 0x22010
unsigned short cram[0x40]; // 0x22100 unsigned char pad[0x70]; // 0x22050 DrawStripVSRam reads 0 from here
unsigned short vsram[0x40]; // 0x22180 unsigned short vsram[0x40]; // 0x22100
}; };
// sram // sram

View file

@ -24,3 +24,5 @@
#define OFS_EST_PicoOpt 0x20 #define OFS_EST_PicoOpt 0x20
#define OFS_EST_Draw2FB 0x24 #define OFS_EST_Draw2FB 0x24
#define OFS_EST_HighPal 0x28 #define OFS_EST_HighPal 0x28
#define OFS_PMEM_vram 0x10000
#define OFS_PMEM_vsram 0x22100

View file

@ -18,6 +18,9 @@
#define DUMP_EST(f, field) \ #define DUMP_EST(f, field) \
DUMP(f, "OFS_EST_", struct PicoEState, field) DUMP(f, "OFS_EST_", struct PicoEState, field)
#define DUMP_PMEM(f, field) \
DUMP(f, "OFS_PMEM_", struct PicoMem, field)
extern struct Pico p; extern struct Pico p;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -58,6 +61,8 @@ int main(int argc, char *argv[])
DUMP_EST(f, PicoOpt); DUMP_EST(f, PicoOpt);
DUMP_EST(f, Draw2FB); DUMP_EST(f, Draw2FB);
DUMP_EST(f, HighPal); DUMP_EST(f, HighPal);
DUMP_PMEM(f, vram);
DUMP_PMEM(f, vsram);
fclose(f); fclose(f);
return 0; return 0;