]> Joshua Wise's Git repositories - fpgaboy.git/commitdiff
It typechecks! Ship it!
authorJoshua Wise <joshua@nyus.joshuawise.com>
Sat, 19 Apr 2008 05:09:56 +0000 (01:09 -0400)
committerJoshua Wise <joshua@nyus.joshuawise.com>
Sat, 19 Apr 2008 05:09:56 +0000 (01:09 -0400)
LCDC.v
diag.asm

diff --git a/LCDC.v b/LCDC.v
index 9a111f7bd2de8fa3a37a1c1895a6fbf0532f0fab..9cebfd7d161712d690dd561749d1a48b0bdfe135 100644 (file)
--- a/LCDC.v
+++ b/LCDC.v
@@ -63,8 +63,8 @@ module LCDC(
        reg [8:0] posx = 9'h000;
        reg [7:0] posy = 8'h00;
        
-       wire vraminuse = (posx < 163);
-       wire oaminuse = (posx > 369);
+       wire vraminuse = (posx < 163) && (posy < 144);
+       wire oaminuse = (posx > 369) && (posy < 144);
        
        wire display = (posx > 2) && (posx < 163) && (posy < 144);
        
@@ -81,7 +81,7 @@ module LCDC(
        assign lcdhs = (posx == 455);
        assign lcdr = display ? {pixdata[1] ? 3'b111 : 3'b000} : 3'b000;
        assign lcdg = display ? {pixdata[0] ? 3'b111 : 3'b000} : 3'b000;
-       assign lcdb = display ? {(vypos < 8) ? 2'b11 : 2'b00} : 2'b00;
+       assign lcdb = display ? {(vypos < 8 || vxpos < 8) ? 2'b11 : 2'b00} : 2'b00;
        
        reg mode00irq = 0, mode01irq = 0, mode10irq = 0, lycirq = 0;
        assign lcdcirq = (rSTAT[3] & mode00irq) | (rSTAT[4] & mode01irq) | (rSTAT[5] & mode10irq) | (rSTAT[6] & lycirq);
@@ -150,7 +150,7 @@ module LCDC(
        always @(negedge clk)
                if ((vraminuse && ((posx == 1) || ((posx > 2) && (vxpos[2:0] == 3'b110)))) || decode_bgmap1) begin
                        tileno <= bgmap1[bgmapaddr_in];
-                       if (wr && decode_bgmap1)
+                       if (wr && decode_bgmap1 && ~vraminuse)
                                bgmap1[bgmapaddr_in] <= data;
                end
        
@@ -158,9 +158,9 @@ module LCDC(
                if ((vraminuse && ((posx == 2) || ((posx > 2) && (vxpos[2:0] == 3'b111)))) || decode_tiledata) begin
                        tilehigh <= tiledatahigh[tileaddr_in];
                        tilelow <= tiledatalow[tileaddr_in];
-                       if (wr && addr[0] && decode_tiledata)
+                       if (wr && addr[0] && decode_tiledata && ~vraminuse)
                                tiledatahigh[tileaddr_in] <= data;
-                       if (wr && ~addr[0] && decode_tiledata)
+                       if (wr && ~addr[0] && decode_tiledata && ~vraminuse)
                                tiledatalow[tileaddr_in] <= data;
                end
   
index 2c843eb33c7a1a0a15a4349f3ffe66ebf9f8b46c..50cefe73b0dff3747ce10de9d9d98202859e9b01 100644 (file)
--- a/diag.asm
+++ b/diag.asm
@@ -52,11 +52,7 @@ signon:
 
 putscreen:
        ; Wait for vblank
-.stat: ld a, [$FF41]
-       ld [$FF51], a
-       and $03         ; mode
-       cp $01          ; VBLANK
-       jr nz, .stat
+       call .vblwait
 
        ld hl, $8000    ; Copy two tiles.
        ld a, $AA
@@ -102,13 +98,30 @@ putscreen:
        ld [hli], a
        
        ld hl, $9800
+.vloop:        call .vblwait
+       ld c, $40
 .loop: ld a, $01
        ld [hli], a
        xor a
        ld [hli], a
        ld a, h
        cp $9C
-       jp nz,.loop
+       ret z
+       dec c
+       xor a
+       cp c
+       jr nz,.loop
+       jr .vloop
+
+.vblwait:
+.stat1:        ld a, [$FF41]   ; STAT
+       and $03
+       cp $00
+       jp nz, .stat1
+.stat2:        ld a, [$FF41]
+       and $03
+       cp $01
+       jr nz, .stat2
        ret
 
 vbl:
@@ -120,16 +133,34 @@ vbl:
        xor a
        ld [$FF0F], a
 
-       ld c, $42       ; SCY
-       ld a, [c]
-       inc a
-       ld [c], a
+       ld a, [$FF51]
+       ld b, a
+       and $80
+       cp $80
+       jr nz, .nothing
+       ld c, $0
+
+       ld a, b
+       and $1
+       cp c
+       call nz, .scyup
        
-       ld c, $43       ; SCX
-       ld a, [c]
-       inc a
-       ld [c], a
+       ld a, b
+       and $2
+       cp c
+       call nz, .scydown
+       
+       ld a, b
+       and $4
+       cp c
+       call nz, .scxup
+       
+       ld a, b
+       and $8
+       cp c
+       call nz, .scxdown
 
+.nothing:
        POP HL
        POP DE
        POP BC
@@ -137,6 +168,23 @@ vbl:
 
        RETI
 
+.scyup:        ld hl, $FF42
+       inc [hl]
+       ret
+
+.scydown:      ld hl, $FF42
+       dec [hl]
+       ret
+
+.scxup:        ld hl, $FF43
+       inc [hl]
+       ret
+
+.scxdown:      ld hl, $FF43
+       dec [hl]
+       ret     
+       
+
 lcdc:
        PUSH AF
        PUSH BC
This page took 0.022192 seconds and 4 git commands to generate.