aboutsummaryrefslogtreecommitdiff
path: root/src-68k/video
diff options
context:
space:
mode:
Diffstat (limited to 'src-68k/video')
-rw-r--r--src-68k/video/bg.68k43
-rw-r--r--src-68k/video/text.68k108
-rw-r--r--src-68k/video/vsync.68k19
3 files changed, 170 insertions, 0 deletions
diff --git a/src-68k/video/bg.68k b/src-68k/video/bg.68k
new file mode 100644
index 0000000..c64e287
--- /dev/null
+++ b/src-68k/video/bg.68k
@@ -0,0 +1,43 @@
+;****************************************************************************
+; DrawBG
+; Draws the background
+;****************************************************************************
+
+DrawBG:
+ lea ($C00004), a2
+ lea ($C00000), a1
+
+ lea (@BGData), a0
+ move.l #$60000003, d0
+ moveq #28-1, d6
+@YLoop:
+ move.l d0, (a2)
+ moveq #40-1, d7
+@XLoop:
+ move.w (a0)+, (a1)
+ dbf d7, @XLoop
+ add.l #$00800000, d0
+ dbf d6, @YLoop
+
+ lea (@BGData), a0
+ move.l #$60000002, d0
+ moveq #28-1, d6
+@YLoop2:
+ move.l d0, (a2)
+ moveq #40-1, d7
+@XLoop2:
+ move.w (a0)+, d1
+ bset.l #11, d1
+ move.w d1, (a1)
+ dbf d7, @XLoop2
+ add.l #$00800000, d0
+ dbf d6, @YLoop2
+
+ rts ; End of subroutine
+
+;****************************************************************************
+; Background data
+;****************************************************************************
+
+@BGData:
+ incbin "data/bg.bin"
diff --git a/src-68k/video/text.68k b/src-68k/video/text.68k
new file mode 100644
index 0000000..832605e
--- /dev/null
+++ b/src-68k/video/text.68k
@@ -0,0 +1,108 @@
+;****************************************************************************
+; LoadFont
+; Loads the font in VRAM
+;****************************************************************************
+
+LoadFont:
+ move.l #$40000000, ($C00004) ; Where font will be stored
+
+ lea (@Font), a0 ; Font data
+ lea ($C00000), a1 ; VDP data port
+ move.w #96*16-1, d7 ; Go through all lines
+@Loop:
+
+ move.b (a0)+, d0 ; Fetch next line
+ moveq #0, d1 ; Initial color
+ moveq #8-1, d6 ; Go through all pixels
+@ILoop:
+
+ add.b d0, d0 ; Get pixel color
+ bcc.s @Transparent
+ moveq #3, d1
+@Transparent:
+ subq.b #1, d1
+ bgt.s @NoUnderflow
+ moveq #0, d1
+@NoUnderflow:
+
+ lsl.l #4, d2 ; Make room for pixel
+ or.b d1, d2 ; Store pixel
+ dbf d6, @ILoop ; Next pixel
+
+ move.l d2, (a1) ; Store line in VRAM
+ dbf d7, @Loop ; Next line
+
+ rts ; End of subroutine
+
+@Font:
+ incbin "data/font.bin"
+
+;****************************************************************************
+; WriteString
+; Writes a string on screen
+;
+; input d0.w ... X coordinate
+; input d1.w ... Y coordinate
+; input d2.w ... FX and such
+; input a0.l ... String
+;****************************************************************************
+
+WriteString:
+ movem.l d0-d2, -(sp) ; Save registers
+
+ lsl.w #6, d1 ; Calculate address
+ add.w d1, d0
+ add.w d0, d0
+
+ and.l #$FFFF, d0 ; Tell VDP the address
+ or.l #$00034000, d0
+ swap d0
+ move.l d0, ($C00004)
+
+ lea ($C00000), a5 ; VDP data port
+ moveq #2-1, d7 ; Go through both lines
+@Loop:
+
+ move.l a0, a6
+@ILoop:
+ move.b (a6)+, d1 ; Get next character
+ beq.s @End ; End of string?
+
+ sub.b #$20, d1 ; Write tile in VRAM
+ and.w #$7F, d1
+ add.w d1, d1
+ add.w d2, d1
+ move.w d1, (a5)
+
+ bra.s @ILoop ; Next character
+
+@End:
+ add.l #$80<<16, d0
+ move.l d0, ($C00004)
+ addq.w #1, d2 ; Next line
+ dbf d7, @Loop
+
+ movem.l (sp)+, d0-d2 ; Restore registers
+ rts ; End of subroutine
+
+;****************************************************************************
+; ClearLines
+; Clears the description lines
+;****************************************************************************
+
+ClearLines:
+ move.l #$448E0003, d0 ; Initial position to clear
+ lea ($C00004), a0 ; VDP control port
+ lea ($C00000), a1 ; VDP data port
+
+ moveq #7-1, d1 ; Clear all lines
+ moveq #0, d2
+@Loop:
+ move.l d0, (a0)
+ rept 26/2
+ move.l d2, (a1)
+ endr
+ add.l #$80<<16, d0
+ dbf d1, @Loop
+
+ rts ; End of subroutine
diff --git a/src-68k/video/vsync.68k b/src-68k/video/vsync.68k
new file mode 100644
index 0000000..ed5ac17
--- /dev/null
+++ b/src-68k/video/vsync.68k
@@ -0,0 +1,19 @@
+;****************************************************************************
+; VSync
+; Waits until the next frame
+;****************************************************************************
+
+VSync:
+ lea ($C00004), a6
+
+@Loop1: ; Wait until current VBlank is over
+ move.w (a6), d7
+ btst.l #3, d7
+ bne.s @Loop1
+
+@Loop2: ; Wait until next VBlank starts
+ move.w (a6), d7
+ btst.l #3, d7
+ beq.s @Loop2
+
+ rts ; End of subroutine