first commit
This commit is contained in:
177
graphics.s
Normal file
177
graphics.s
Normal file
@@ -0,0 +1,177 @@
|
||||
; Graphics Module
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
INCDIR "c:/Users/capitano/Documents/giochino/"
|
||||
INCLUDE "custom.i"
|
||||
|
||||
; XDEF InitGraphics
|
||||
; XDEF CopperList
|
||||
; XDEF Bitplane1
|
||||
; XDEF ClearScreen
|
||||
; XDEF DrawText
|
||||
; XDEF DrawChar
|
||||
|
||||
; XREF Font8x8
|
||||
|
||||
; SECTION Code,CODE_C
|
||||
|
||||
InitGraphics:
|
||||
lea CUSTOM,a6
|
||||
|
||||
; 1. Setup Bitplanes
|
||||
move.w #$1200,BPLCON0(a6) ; 1 Bitplane, Color on
|
||||
move.w #0,BPLCON1(a6) ; Scroll 0
|
||||
move.w #0,BPLCON2(a6) ; Priority 0
|
||||
move.w #0,BPL1MOD(a6) ; Modulo 0
|
||||
|
||||
; Setup Display Window
|
||||
move.w #$2c81,DIWSTRT(a6)
|
||||
move.w #$2cc1,DIWSTOP(a6)
|
||||
move.w #$0038,DDFSTRT(a6)
|
||||
move.w #$00d0,DDFSTOP(a6)
|
||||
|
||||
; 2. Setup Copper List
|
||||
lea CopperList,a0
|
||||
move.l a0,COP1LCH(a6)
|
||||
move.w #0,COPJMP1(a6)
|
||||
|
||||
; 3. Setup Bitplane Pointers
|
||||
lea Bitplane1,a1
|
||||
move.l a1,d0
|
||||
lea CopperBplPtr,a0
|
||||
swap d0
|
||||
move.w d0,2(a0)
|
||||
swap d0
|
||||
move.w d0,6(a0)
|
||||
|
||||
; 4. Clear Screen
|
||||
bsr ClearScreen
|
||||
|
||||
rts
|
||||
|
||||
ClearScreen:
|
||||
lea Bitplane1,a0
|
||||
move.w #(40*256)/4-1,d0 ; Longwords
|
||||
.loop:
|
||||
move.l #0,(a0)+
|
||||
dbf d0,.loop
|
||||
rts
|
||||
|
||||
; DrawText
|
||||
; d0 = X, d1 = Y, a0 = String
|
||||
DrawText:
|
||||
movem.l d0-d3/a0-a2,-(sp)
|
||||
|
||||
; d0 = Initial X (keep in d3 for CR)
|
||||
move.w d0,d3
|
||||
|
||||
; Initial Setup
|
||||
bsr .calcAddr
|
||||
|
||||
.charLoop:
|
||||
move.b (a0)+,d2 ; Get char
|
||||
beq.s .done ; Null terminator?
|
||||
|
||||
cmp.b #10,d2 ; Newline (LF)?
|
||||
beq.s .newline
|
||||
cmp.b #13,d2 ; CR?
|
||||
beq.s .carriageReturn
|
||||
|
||||
sub.b #32,d2 ; ASCII adjustment
|
||||
ext.w d2
|
||||
|
||||
; Get font address
|
||||
lea Font8x8,a2
|
||||
lsl.w #3,d2 ; * 8
|
||||
add.w d2,a2
|
||||
|
||||
; Draw 8 lines of the char
|
||||
move.b (a2)+,(a1)
|
||||
move.b (a2)+,40(a1)
|
||||
move.b (a2)+,80(a1)
|
||||
move.b (a2)+,120(a1)
|
||||
move.b (a2)+,160(a1)
|
||||
move.b (a2)+,200(a1)
|
||||
move.b (a2)+,240(a1)
|
||||
move.b (a2)+,280(a1)
|
||||
|
||||
addq.w #1,a1 ; Next char pos
|
||||
bra.s .charLoop
|
||||
|
||||
.newline:
|
||||
addq.w #1,d1 ; Increment Y (lines)
|
||||
bsr .calcAddr ; Recalculate address (Resets X to d3)
|
||||
bra.s .charLoop
|
||||
|
||||
.carriageReturn:
|
||||
; Just reset X to d3, keep Y
|
||||
bsr .calcAddr
|
||||
bra.s .charLoop
|
||||
|
||||
.done:
|
||||
movem.l (sp)+,d0-d3/a0-a2
|
||||
rts
|
||||
|
||||
.calcAddr:
|
||||
lea Bitplane1,a1
|
||||
move.l d1,d4 ; Copy Y
|
||||
mulu #320,d4 ; Y * 320
|
||||
add.l d4,a1
|
||||
add.w d3,a1 ; Add Initial X
|
||||
rts
|
||||
|
||||
; DrawChar
|
||||
; d2 = Char code, d0 = X, d1 = Y
|
||||
DrawChar:
|
||||
movem.l d0-d3/a0-a2,-(sp)
|
||||
lea Bitplane1,a1
|
||||
mulu #320,d1
|
||||
add.l d1,a1
|
||||
add.w d0,a1
|
||||
|
||||
sub.b #32,d2
|
||||
ext.w d2
|
||||
lea Font8x8,a2
|
||||
lsl.w #3,d2
|
||||
add.w d2,a2
|
||||
|
||||
move.b (a2)+,(a1)
|
||||
move.b (a2)+,40(a1)
|
||||
move.b (a2)+,80(a1)
|
||||
move.b (a2)+,120(a1)
|
||||
move.b (a2)+,160(a1)
|
||||
move.b (a2)+,200(a1)
|
||||
move.b (a2)+,240(a1)
|
||||
move.b (a2)+,280(a1)
|
||||
|
||||
movem.l (sp)+,d0-d3/a0-a2
|
||||
rts
|
||||
|
||||
; SECTION Data,DATA_C
|
||||
|
||||
CNOP 0,4
|
||||
CopperList:
|
||||
DC.W COLOR00, $0333 ; Background
|
||||
DC.W COLOR01, $0FF0 ; Text
|
||||
|
||||
CopperBplPtr:
|
||||
DC.W BPL1PTH, $0000
|
||||
DC.W BPL1PTL, $0000
|
||||
|
||||
; Desk Top
|
||||
DC.W $2c07, $FFFE
|
||||
DC.W COLOR00, $0642
|
||||
|
||||
; Monitor Area (Lines 80-200 approx)
|
||||
DC.W $5007, $FFFE
|
||||
DC.W COLOR00, $0000
|
||||
|
||||
; Desk Bottom
|
||||
DC.W $D007, $FFFE
|
||||
DC.W COLOR00, $0642
|
||||
|
||||
DC.W $FFFF, $FFFE
|
||||
|
||||
CNOP 0,4
|
||||
Bitplane1:
|
||||
DS.B 40*256
|
||||
Reference in New Issue
Block a user