mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 15:48:05 -04:00
giz port, restructuring
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@257 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
c9077ab4b9
commit
ea8c405fa7
30 changed files with 1706 additions and 970 deletions
32
Pico/Draw.c
32
Pico/Draw.c
|
@ -8,14 +8,18 @@
|
|||
|
||||
|
||||
#include "PicoInt.h"
|
||||
#ifndef __GNUC__
|
||||
#pragma warning (disable:4706) // Disable assignment within conditional
|
||||
#endif
|
||||
|
||||
int (*PicoScan)(unsigned int num, void *data)=NULL;
|
||||
|
||||
unsigned short DefOutBuff[320*2];
|
||||
#if OVERRIDE_HIGHCOL
|
||||
static unsigned char DefHighCol[8+320+8];
|
||||
unsigned char *HighCol=DefHighCol;
|
||||
#else
|
||||
unsigned char HighCol[8+320+8];
|
||||
#endif
|
||||
unsigned short DefOutBuff[320*2];
|
||||
void *DrawLineDest=DefOutBuff; // pointer to dest buffer where to draw this line to
|
||||
|
||||
static int HighCacheA[41+1]; // caches for high layers
|
||||
static int HighCacheB[41+1];
|
||||
static int HighCacheS[80+1]; // and sprites
|
||||
|
@ -25,7 +29,6 @@ char HighSprZ[320+8+8]; // Z-buffer for accurate sprites and shadow/hilight mode
|
|||
// lsb->msb: moved sprites, not all window tiles use same priority, accurate sprites (copied from PicoOpt), interlace
|
||||
// dirty sprites, sonic mode, have layer with all hi prio tiles (mk3), layer sh/hi already processed
|
||||
int rendstatus;
|
||||
void *DrawLineDest=DefOutBuff; // pointer to dest buffer where to draw this line to
|
||||
int Scanline=0; // Scanline
|
||||
|
||||
static int SpriteBlocks;
|
||||
|
@ -1253,7 +1256,7 @@ static void FinalizeLine8bit(int sh)
|
|||
}
|
||||
}
|
||||
|
||||
void (*FinalizeLine)(int sh) = FinalizeLineBGR444;
|
||||
static void (*FinalizeLine)(int sh) = FinalizeLineBGR444;
|
||||
|
||||
// --------------------------------------------
|
||||
|
||||
|
@ -1354,8 +1357,8 @@ PICO_INTERNAL int PicoLine(int scan)
|
|||
if (Pico.video.reg[1]&0x40)
|
||||
DrawDisplay(sh);
|
||||
|
||||
FinalizeLine(sh);
|
||||
//if (SpriteBlocks & (1<<(scan>>3))) for (sh=0; sh < 30; sh++) DrawLineDest[sh] = 0xf;
|
||||
if (FinalizeLine != NULL)
|
||||
FinalizeLine(sh);
|
||||
|
||||
Skip=PicoScan(Scanline,DrawLineDest);
|
||||
|
||||
|
@ -1365,9 +1368,12 @@ PICO_INTERNAL int PicoLine(int scan)
|
|||
|
||||
void PicoDrawSetColorFormat(int which)
|
||||
{
|
||||
if (which == 2)
|
||||
FinalizeLine = FinalizeLine8bit;
|
||||
else if (which == 1)
|
||||
FinalizeLine = FinalizeLineRGB555;
|
||||
else FinalizeLine = FinalizeLineBGR444;
|
||||
switch (which)
|
||||
{
|
||||
case 2: FinalizeLine = FinalizeLine8bit; break;
|
||||
case 1: FinalizeLine = FinalizeLineRGB555; break;
|
||||
case 0: FinalizeLine = FinalizeLineBGR444; break;
|
||||
default:FinalizeLine = NULL; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
85
Pico/Draw.s
85
Pico/Draw.s
|
@ -6,6 +6,7 @@
|
|||
@ (c) Copyright 2007, Grazvydas "notaz" Ignotas
|
||||
@ All Rights Reserved
|
||||
|
||||
.include "port_config.s"
|
||||
|
||||
.extern Pico
|
||||
.extern PicoOpt
|
||||
|
@ -317,11 +318,18 @@ DrawLayer:
|
|||
add r8, r8, r9, lsr #8 @ tilex+=cellskip
|
||||
add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
|
||||
sub r10,r10,r9, lsl #16 @ cells-=cellskip
|
||||
mvn r9, #0 @ r9=prevcode=-1
|
||||
|
||||
@ cache some stuff to avoid mem access
|
||||
.if OVERRIDE_HIGHCOL
|
||||
ldr r11,=HighCol
|
||||
mov r0, #0xf
|
||||
ldr r11,[r11]
|
||||
.else
|
||||
ldr r11,=HighCol
|
||||
mov r0, #0xf
|
||||
.endif
|
||||
|
||||
mvn r9, #0 @ r9=prevcode=-1
|
||||
add r1, r11, r7 @ r1=pdest
|
||||
|
||||
|
||||
|
@ -463,13 +471,19 @@ DrawLayer:
|
|||
add r8, r8, r9, lsr #8 @ tilex+=cellskip
|
||||
add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
|
||||
add r10,r10,r9, lsl #16 @ cell+=cellskip
|
||||
mvn r9, #0 @ r9=prevcode=-1
|
||||
|
||||
@ cache some stuff to avoid mem access
|
||||
.if OVERRIDE_HIGHCOL
|
||||
ldr r11,=HighCol
|
||||
mov r0, #0xf
|
||||
add r1, r11, r7 @ r1=pdest
|
||||
ldr r11,[r11]
|
||||
.else
|
||||
ldr r11,=HighCol
|
||||
mov r0, #0xf
|
||||
.endif
|
||||
|
||||
mvn r9, #0 @ r9=prevcode=-1
|
||||
add r1, r11, r7 @ r1=pdest
|
||||
|
||||
@ r4 & r7 are scratch in this loop
|
||||
.dsloop_vs_subr1:
|
||||
|
@ -639,10 +653,18 @@ DrawLayer:
|
|||
BackFill:
|
||||
stmfd sp!, {r4-r9,lr}
|
||||
|
||||
.if OVERRIDE_HIGHCOL
|
||||
ldr lr, =HighCol
|
||||
mov r0, r0, lsl #26
|
||||
ldr lr, [lr]
|
||||
mov r0, r0, lsr #26
|
||||
add lr, lr, #8
|
||||
.else
|
||||
ldr lr, =(HighCol+8)
|
||||
|
||||
mov r0, r0, lsl #26
|
||||
mov r0, r0, lsr #26
|
||||
.endif
|
||||
|
||||
orr r0, r0, r1, lsl #6
|
||||
orr r0, r0, r0, lsl #8
|
||||
orr r0, r0, r0, lsl #16
|
||||
|
@ -680,9 +702,15 @@ DrawTilesFromCache:
|
|||
stmfd sp!, {r4-r8,r11,lr}
|
||||
|
||||
@ cache some stuff to avoid mem access
|
||||
.if OVERRIDE_HIGHCOL
|
||||
ldr r11,=HighCol
|
||||
ldr lr, =(Pico+0x10000) @ lr=Pico.vram
|
||||
mov r12,#0xf
|
||||
ldr r11,[r11]
|
||||
.else
|
||||
ldr r11,=HighCol
|
||||
mov r12,#0xf
|
||||
.endif
|
||||
ldr lr, =(Pico+0x10000) @ lr=Pico.vram
|
||||
|
||||
mvn r5, #0 @ r5=prevcode=-1
|
||||
ands r8, r1, #1
|
||||
|
@ -874,11 +902,17 @@ DrawSpritesFromCache:
|
|||
stmfd sp!, {r4-r11,lr}
|
||||
|
||||
@ cache some stuff to avoid mem access
|
||||
.if OVERRIDE_HIGHCOL
|
||||
ldr r11,=HighCol
|
||||
mov r12,#0xf
|
||||
ldr r11,[r11]
|
||||
.else
|
||||
ldr r11,=HighCol
|
||||
mov r12,#0xf
|
||||
.endif
|
||||
ldr lr, =(Pico+0x10000) @ lr=Pico.vram
|
||||
mov r6, r1, lsl #31
|
||||
orr r6, r6, #1<<30
|
||||
mov r12,#0xf
|
||||
|
||||
mov r10, r0
|
||||
|
||||
|
@ -1042,9 +1076,15 @@ DrawSprite:
|
|||
bne .dspr_cache @ if(code&0x8000) // high priority - cache it
|
||||
|
||||
@ cache some stuff to avoid mem access
|
||||
.if OVERRIDE_HIGHCOL
|
||||
ldr r11,=HighCol
|
||||
ldr lr, =(Pico+0x10000) @ lr=Pico.vram
|
||||
mov r12,#0xf
|
||||
ldr r11,[r11]
|
||||
.else
|
||||
ldr r11,=HighCol
|
||||
mov r12,#0xf
|
||||
.endif
|
||||
ldr lr, =(Pico+0x10000) @ lr=Pico.vram
|
||||
|
||||
mov r5, r5, lsl #4 @ delta<<=4; // Delta of address
|
||||
and r4, r9, #0x6000
|
||||
|
@ -1202,12 +1242,19 @@ DrawWindow:
|
|||
orr r6, r6, r3, lsl #8 @ shadow mode
|
||||
|
||||
sub r8, r1, r0
|
||||
mov r8, r8, lsl #1 @ cells
|
||||
|
||||
mvn r9, #0 @ r9=prevcode=-1
|
||||
|
||||
@ cache some stuff to avoid mem access
|
||||
.if OVERRIDE_HIGHCOL
|
||||
ldr r11,=HighCol
|
||||
mov r8, r8, lsl #1 @ cells
|
||||
ldr r11,[r11]
|
||||
mvn r9, #0 @ r9=prevcode=-1
|
||||
add r11,r11,#8
|
||||
.else
|
||||
ldr r11,=(HighCol+8)
|
||||
mov r8, r8, lsl #1 @ cells
|
||||
mvn r9, #0 @ r9=prevcode=-1
|
||||
.endif
|
||||
add r1, r11, r0, lsl #4 @ r1=pdest
|
||||
mov r0, #0xf
|
||||
b .dwloop_enter
|
||||
|
@ -1408,9 +1455,17 @@ FinalizeLineBGR444:
|
|||
|
||||
|
||||
.fl_noshBGR444:
|
||||
.if OVERRIDE_HIGHCOL
|
||||
ldr r1, =HighCol
|
||||
mov lr, #0xff
|
||||
ldr r1, [r1]
|
||||
mov lr, lr, lsl #1
|
||||
add r1, r1, #8
|
||||
.else
|
||||
ldr r1, =(HighCol+8)
|
||||
mov lr, #0xff
|
||||
mov lr, lr, lsl #1
|
||||
.endif
|
||||
|
||||
.fl_loopBGR444:
|
||||
|
||||
|
@ -1480,6 +1535,8 @@ FinalizeLineBGR444:
|
|||
orr \reg, \reg, r3 @ add blue back
|
||||
.endm
|
||||
|
||||
.global vidConvCpyRGB565
|
||||
|
||||
vidConvCpyRGB565: @ void *to, void *from, int pixels
|
||||
stmfd sp!, {r4-r9,lr}
|
||||
|
||||
|
@ -1562,9 +1619,17 @@ FinalizeLineRGB555:
|
|||
sub r3, r3, #0x40*2
|
||||
|
||||
.fl_noshRGB555:
|
||||
.if OVERRIDE_HIGHCOL
|
||||
ldr r1, =HighCol
|
||||
ldr r0, =DrawLineDest
|
||||
ldr r1, [r1]
|
||||
ldr r0, [r0]
|
||||
add r1, r1, #8
|
||||
.else
|
||||
ldr r0, =DrawLineDest
|
||||
ldr r1, =(HighCol+8)
|
||||
ldr r0, [r0]
|
||||
.endif
|
||||
|
||||
ldrb r12, [r8, #12]
|
||||
mov lr, #0xff
|
||||
|
|
37
Pico/Draw2.s
37
Pico/Draw2.s
|
@ -23,11 +23,11 @@ BackFillFull:
|
|||
stmfd sp!, {r4-r9,lr}
|
||||
|
||||
ldr lr, =PicoDraw2FB @ lr=PicoDraw2FB
|
||||
mov r0, r0, lsl #26
|
||||
ldr lr, [lr]
|
||||
mov r0, r0, lsr #26
|
||||
add lr, lr, #328*8
|
||||
|
||||
mov r0, r0, lsl #26
|
||||
mov r0, r0, lsr #26
|
||||
orr r0, r0, r0, lsl #8
|
||||
orr r0, r0, r0, lsl #16
|
||||
|
||||
|
@ -344,25 +344,25 @@ DrawLayerFull:
|
|||
|
||||
mov r6, r1 @ hcache
|
||||
|
||||
ldr r11, =(Pico+0x22228) @ Pico.video
|
||||
ldr r10, =(Pico+0x10000) @ r10=Pico.vram
|
||||
ldrb r5, [r11, #13] @ pvid->reg[13]
|
||||
ldrb r7, [r11, #11]
|
||||
|
||||
sub lr, r3, r2
|
||||
and lr, lr, #0x00ff0000 @ lr=cells
|
||||
|
||||
ldr r10, =(Pico+0x10000) @ r10=Pico.vram
|
||||
|
||||
ldr r11, =(Pico+0x22228) @ Pico.video
|
||||
ldrb r5, [r11, #13] @ pvid->reg[13]
|
||||
mov r5, r5, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords)
|
||||
add r5, r5, r0, lsl #1 @ htab+=plane
|
||||
bic r5, r5, #0x00ff0000 @ just in case
|
||||
|
||||
ldrb r7, [r11, #11]
|
||||
tst r7, #3 @ full screen scroll? (if ==0)
|
||||
ldrb r7, [r11, #16] @ ??hh??ww
|
||||
ldreqh r5, [r10, r5]
|
||||
biceq r5, r5, #0x0000fc00 @ r5=hscroll (0-0x3ff)
|
||||
movne r5, r5, lsr #1
|
||||
orrne r5, r5, #0x8000 @ this marks that we have htab pointer, not hscroll here
|
||||
|
||||
ldrb r7, [r11, #16] @ ??hh??ww
|
||||
and r8, r7, #3
|
||||
|
||||
orr r5, r5, r7, lsl #1+24
|
||||
|
@ -386,7 +386,7 @@ DrawLayerFull:
|
|||
mov r8, r8, lsl #24+5
|
||||
orr r8, r8, #0x1f000000
|
||||
|
||||
@ Find name table:
|
||||
@ Find name table:
|
||||
tst r0, r0
|
||||
ldreqb r4, [r11, #2]
|
||||
moveq r4, r4, lsr #3
|
||||
|
@ -395,13 +395,13 @@ DrawLayerFull:
|
|||
orr lr, lr, r4, lsl #13 @ lr|=nametab_bits{3}<<13
|
||||
|
||||
ldr r11, =PicoDraw2FB @ r11=PicoDraw2FB
|
||||
ldr r11, [r11]
|
||||
sub r4, r9, #(START_ROW<<24)
|
||||
ldr r11, [r11]
|
||||
mov r4, r4, asr #24
|
||||
mov r7, #328*8
|
||||
mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW);
|
||||
|
||||
@ Get vertical scroll value:
|
||||
@ Get vertical scroll value:
|
||||
add r7, r10, #0x012000
|
||||
add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
|
||||
ldr r7, [r7]
|
||||
|
@ -454,10 +454,10 @@ DrawLayerFull:
|
|||
ldrh r7, [r10, r7]
|
||||
|
||||
.rtr_hscroll_done:
|
||||
and r8, r8, #0xff000000
|
||||
rsb r4, r7, #0 @ r4=tilex=(-ts->hscroll)>>3
|
||||
mov r4, r4, asr #3
|
||||
and r4, r4, #0xff
|
||||
and r8, r8, #0xff000000
|
||||
orr r8, r8, r4 @ r8=(xmask<<24)|tilex
|
||||
|
||||
sub r7, r7, #1
|
||||
|
@ -573,8 +573,8 @@ DrawTilesFromCacheF:
|
|||
mvn r6, #0 @ r6=prevy=-1
|
||||
|
||||
ldr r4, =PicoDraw2FB @ r4=PicoDraw2FB
|
||||
ldr r4, [r4]
|
||||
ldr r1, [r0], #4 @ read y offset
|
||||
ldr r4, [r4]
|
||||
mov r7, #328
|
||||
mla r1, r7, r1, r4
|
||||
sub r12, r1, #(328*8*START_ROW) @ r12=scrpos
|
||||
|
@ -591,7 +591,7 @@ DrawTilesFromCacheF:
|
|||
movs r1, r7, lsr #16 @ r1=dx;
|
||||
ldmeqfd sp!, {r4-r10,pc} @ dx is never zero, this must be a terminator, return
|
||||
|
||||
@ trow changed?
|
||||
@ row changed?
|
||||
cmp r6, r7, lsr #27
|
||||
movne r6, r7, lsr #27
|
||||
movne r4, #328*8
|
||||
|
@ -697,12 +697,12 @@ DrawWindowFull:
|
|||
mov r9, #0xff000000 @ r9=prevcode=-1
|
||||
|
||||
ldr r11, =PicoDraw2FB @ r11=scrpos
|
||||
and r4, r0, #0xff
|
||||
ldr r11, [r11]
|
||||
sub r4, r4, #START_ROW
|
||||
add r11, r11, #328*8
|
||||
add r11, r11, #8
|
||||
|
||||
and r4, r0, #0xff
|
||||
sub r4, r4, #START_ROW
|
||||
mov r7, #328*8
|
||||
mla r11, r7, r4, r11 @ scrpos+=8*328*(start-START_ROW);
|
||||
mov r0, #0xf
|
||||
|
@ -881,9 +881,9 @@ DrawSpriteFull:
|
|||
|
||||
mov r12, r3, lsl #23
|
||||
mov r12, r12, lsr #23
|
||||
sub r12, r12, #0x78 @ r12=sy
|
||||
|
||||
ldr lr, [r0, #4] @ lr=code
|
||||
sub r12, r12, #0x78 @ r12=sy
|
||||
mov r8, lr, lsl #7
|
||||
mov r8, r8, lsr #23
|
||||
sub r8, r8, #0x78 @ r8=sx
|
||||
|
@ -894,9 +894,8 @@ DrawSpriteFull:
|
|||
and r3, lr, #0x6000
|
||||
mov r3, r3, lsr #9 @ r3=pal=((code>>9)&0x30);
|
||||
|
||||
ldr r10, =(Pico+0x10000) @ r10=Pico.vram
|
||||
|
||||
ldr r11, =PicoDraw2FB @ r11=scrpos
|
||||
ldr r10, =(Pico+0x10000) @ r10=Pico.vram
|
||||
ldr r11, [r11]
|
||||
sub r1, r12, #(START_ROW*8)
|
||||
mov r0, #328
|
||||
|
|
|
@ -106,6 +106,9 @@ extern void (*PicoCartLoadProgressCB)(int percent);
|
|||
// Draw.c
|
||||
void PicoDrawSetColorFormat(int which); // 0=BGR444, 1=RGB555, 2=8bit(HighPal pal)
|
||||
extern void *DrawLineDest;
|
||||
#if OVERRIDE_HIGHCOL
|
||||
extern unsigned char *HighCol;
|
||||
#endif
|
||||
extern int (*PicoScan)(unsigned int num, void *data);
|
||||
// internals
|
||||
extern unsigned short HighPal[0x100];
|
||||
|
@ -113,6 +116,7 @@ extern int rendstatus;
|
|||
// utility
|
||||
#ifdef _ASM_DRAW_C
|
||||
void *blockcpy(void *dst, const void *src, size_t n);
|
||||
void vidConvCpyRGB565(void *to, void *from, int pixels);
|
||||
#else
|
||||
#define blockcpy memcpy
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue