eliminate texrels, part 3
[picodrive.git] / pico / draw2_arm.S
index c37d059..6e7e1ac 100644 (file)
@@ -8,8 +8,7 @@
  * this is highly specialized, be careful if changing related C code!\r
  */\r
 \r
-.extern Pico\r
-.extern PicoDraw2FB\r
+#include "pico_int_o32.h"\r
 \r
 @ define these constants in your include file:\r
 @ .equiv START_ROW,            1\r
 .text\r
 .align 2\r
 \r
-.global BackFillFull @ int reg7\r
+@ void BackFillFull(void *dst, int reg7)\r
+\r
+.global BackFillFull\r
 \r
 BackFillFull:\r
     stmfd   sp!, {r4-r9,lr}\r
 \r
-    ldr     lr, =PicoDraw2FB      @ lr=PicoDraw2FB\r
-    mov     r0, r0, lsl #26\r
-    ldr     lr, [lr]\r
+    add     lr, r0, #328*8\r
+    mov     r0, r1, lsl #26\r
     mov     r0, r0, lsr #26\r
-    add     lr, lr, #328*8\r
 \r
     orr     r0, r0, r0, lsl #8\r
     orr     r0, r0, r0, lsl #16\r
@@ -67,8 +66,8 @@ BackFillFull:
 \r
     bne     .bff_loop\r
 \r
-    ldmfd   sp!, {r4-r9,r12}\r
-    bx      r12\r
+    ldmfd   sp!, {r4-r9,lr}\r
+    bx      lr\r
 \r
 .pool\r
 \r
@@ -343,17 +342,19 @@ BackFillFull:
 \r
 @ DrawLayerTiles(*hcache, *scrpos, (cells<<24)|(nametab<<9)|(vscroll&0x3ff)<<11|(shift[width]<<8)|planeend, (ymask<<24)|(planestart<<16)|[htab||hscroll]\r
 \r
-@static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend)\r
+@ void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,\r
+@                    struct PicoEState *est)\r
 \r
 .global DrawLayerFull\r
 \r
 DrawLayerFull:\r
+    ldr     r12,[sp]              @ est\r
     stmfd   sp!, {r4-r11,lr}\r
 \r
     mov     r6, r1        @ hcache\r
 \r
-    ldr     r11, =(Pico+0x22228)  @ Pico.video\r
-    ldr     r10, =(Pico+0x10000)  @ r10=Pico.vram\r
+    ldr     r11, [r12, #OFS_Pico_video]\r
+    ldr     r10, [r12, #OFS_Pico_vram]\r
     ldrb    r5, [r11, #13]        @ pvid->reg[13]\r
     ldrb    r7, [r11, #11]\r
 \r
@@ -402,9 +403,9 @@ DrawLayerFull:
     and     r4, r4, #7\r
     orr     lr, lr, r4, lsl #13   @ lr|=nametab_bits{3}<<13\r
 \r
-    ldr     r11, =PicoDraw2FB     @ r11=PicoDraw2FB\r
+    ldr     r11,[sp, #9*4]        @ est\r
     sub     r4, r9, #(START_ROW<<24)\r
-    ldr     r11, [r11]\r
+    ldr     r11, [r11, #OFS_Draw2FB]\r
     mov     r4, r4, asr #24\r
     mov     r7, #328*8\r
     mla     r11, r4, r7, r11      @ scrpos+=8*328*(planestart-START_ROW);\r
@@ -571,8 +572,9 @@ DrawLayerFull:
 .pool\r
 \r
 \r
+@ void DrawTilesFromCacheF(int *hc, struct PicoEState *est)\r
 \r
-.global DrawTilesFromCacheF @ int *hc\r
+.global DrawTilesFromCacheF\r
 \r
 DrawTilesFromCacheF:\r
     stmfd   sp!, {r4-r10,lr}\r
@@ -580,14 +582,13 @@ DrawTilesFromCacheF:
     mov     r9, #0xff000000 @ r9=prevcode=-1\r
     mvn     r6, #0          @ r6=prevy=-1\r
 \r
-    ldr     r4, =PicoDraw2FB  @ r4=PicoDraw2FB\r
-    ldr     r1, [r0], #4    @ read y offset\r
-    ldr     r4, [r4]\r
+    ldr     r4, [r1, #OFS_Draw2FB]\r
+    ldr     r2, [r0], #4    @ read y offset\r
     mov     r7, #328\r
-    mla     r1, r7, r1, r4\r
-    sub     r12, r1, #(328*8*START_ROW) @ r12=scrpos\r
+    mla     r2, r7, r2, r4\r
+    sub     r12, r2, #(328*8*START_ROW) @ r12=scrpos\r
 \r
-    ldr     r10, =(Pico+0x10000) @ r10=Pico.vram\r
+    ldr     r10, [r1, #OFS_Pico_vram]\r
     mov     r8, r0               @ hc\r
     mov     r0, #0xf\r
 \r
@@ -666,12 +667,14 @@ DrawTilesFromCacheF:
 @ @@@@@@@@@@@@@@@\r
 \r
 @ (tile_start<<16)|row_start\r
-.global DrawWindowFull @ int tstart, int tend, int prio\r
+@ void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)\r
+\r
+.global DrawWindowFull\r
 \r
 DrawWindowFull:\r
     stmfd   sp!, {r4-r11,lr}\r
 \r
-    ldr     r11, =(Pico+0x22228)  @ Pico.video\r
+    ldr     r11, [r3, #OFS_Pico_video]\r
     ldrb    r12, [r11, #3]        @ pvid->reg[3]\r
     mov     r12, r12, lsl #10\r
 \r
@@ -686,11 +689,11 @@ DrawWindowFull:
     and     r4, r0, #0xff\r
     mla     r12, r5, r4, r12      @ nametab += nametab_step*start;\r
 \r
+    ldr     r10, [r3, #OFS_Pico_vram]\r
     mov     r4, r0, lsr #16       @ r4=start_cell_h\r
     add     r7, r12, r4, lsl #1\r
 \r
     @ fetch the first code now\r
-    ldr     r10, =(Pico+0x10000)  @ lr=Pico.vram\r
     ldrh    r7, [r10, r7]\r
     cmp     r2, r7, lsr #15\r
     ldmnefd sp!, {r4-r11,pc}      @ hack: simply assume that whole window uses same priority\r
@@ -704,11 +707,10 @@ DrawWindowFull:
 \r
     mov     r9, #0xff000000       @ r9=prevcode=-1\r
 \r
-    ldr     r11, =PicoDraw2FB     @ r11=scrpos\r
+    ldr     r11, [r3, #OFS_Draw2FB]\r
     and     r4, r0, #0xff\r
-    ldr     r11, [r11]\r
-    sub     r4, r4, #START_ROW\r
     add     r11, r11, #328*8\r
+    sub     r4, r4, #START_ROW\r
     add     r11, r11, #8\r
 \r
     mov     r7, #328*8\r
@@ -873,8 +875,9 @@ DrawWindowFull:
     b       52b\r
 .endm\r
 \r
+@ void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est)\r
 \r
-.global DrawSpriteFull @ unsigned int *sprite\r
+.global DrawSpriteFull\r
 \r
 DrawSpriteFull:\r
     stmfd   sp!, {r4-r11,lr}\r
@@ -902,9 +905,8 @@ DrawSpriteFull:
     and     r3, lr, #0x6000\r
     mov     r3, r3, lsr #9  @ r3=pal=((code>>9)&0x30);\r
 \r
-    ldr     r11, =PicoDraw2FB     @ r11=scrpos\r
-    ldr     r10, =(Pico+0x10000)  @ r10=Pico.vram\r
-    ldr     r11, [r11]\r
+    ldr     r11, [r1, #OFS_Draw2FB]\r
+    ldr     r10, [r1, #OFS_Pico_vram]\r
     sub     r1, r12, #(START_ROW*8)\r
     mov     r0, #328\r
     mla     r11, r1, r0, r11      @ scrpos+=(sy-START_ROW*8)*328;\r