mirror of
https://github.com/Pecusx/scorch_src.git
synced 2026-05-20 22:33:43 +02:00
Code cleanup and native graphics routines for C64 (almost).
This commit is contained in:
@@ -189,6 +189,361 @@ ClearPlot
|
||||
and bittable,x
|
||||
rts
|
||||
.endp
|
||||
;--------------------------------------------------
|
||||
.proc drawmountains
|
||||
;--------------------------------------------------
|
||||
mwa #0 xdraw
|
||||
mwa #mountaintable modify
|
||||
mva #1 color
|
||||
|
||||
drawmountainsloop
|
||||
ldy #0
|
||||
lda (modify),y
|
||||
cmp #screenheight
|
||||
beq NoMountain
|
||||
sta ydraw
|
||||
sty ydraw+1
|
||||
.IF FASTER_GRAF_PROCS = 1
|
||||
; there was Drawline proc
|
||||
lda #screenheight
|
||||
sec
|
||||
sbc ydraw
|
||||
sta tempbyte01
|
||||
jsr plot.MakePlot
|
||||
; after plot we have: (xbyte),y - addres of screen byte; X - index in bittable (number of bit)
|
||||
; jmp IntoDraw ; jumps inside Draw routine
|
||||
; because one pixel is already plotted (and who cares? :) )
|
||||
@
|
||||
lda (xbyte),y
|
||||
and bittable2,x
|
||||
sta (xbyte),y
|
||||
;IntoDraw
|
||||
adw xbyte #screenBytes
|
||||
dec tempbyte01
|
||||
bne @-
|
||||
; end of Drawline proc
|
||||
.ELSE
|
||||
; there was Drawline proc
|
||||
drawline
|
||||
jsr plot.MakePlot
|
||||
inc ydraw
|
||||
lda ydraw
|
||||
cmp #screenheight
|
||||
bne drawline
|
||||
; end of Drawline proc
|
||||
.ENDIF
|
||||
NoMountain
|
||||
inw modify
|
||||
inw xdraw
|
||||
cpw xdraw #screenwidth
|
||||
bne drawmountainsloop
|
||||
rts
|
||||
.endp
|
||||
;--------------------------------------------------
|
||||
.proc TypeChar
|
||||
; puts char on the graphics screen
|
||||
; in: CharCode
|
||||
; in: left LOWER corner of the char coordinates (xdraw, ydraw)
|
||||
;--------------------------------------------------
|
||||
; char to the table
|
||||
lda CharCode
|
||||
sta fontind
|
||||
lda #$00
|
||||
sta fontind+1
|
||||
; char intex times 8
|
||||
aslw fontind
|
||||
rolw fontind
|
||||
rolw fontind
|
||||
|
||||
adw fontind #TankFont
|
||||
|
||||
; and 8 bytes to the table
|
||||
ldy #7
|
||||
CopyChar
|
||||
lda (fontind),y
|
||||
eor #$ff
|
||||
sta char1,y
|
||||
lda #$ff
|
||||
sta char2,y
|
||||
dey
|
||||
bpl CopyChar
|
||||
; and 8 subsequent bytes as a mask
|
||||
adw fontind #8
|
||||
ldy #7
|
||||
CopyMask
|
||||
lda (fontind),y
|
||||
eor #$ff
|
||||
sta mask1,y
|
||||
lda #$00
|
||||
sta mask2,y
|
||||
dey
|
||||
bpl CopyMask
|
||||
|
||||
.IF FASTER_GRAF_PROCS = 1
|
||||
; calculating coordinates from xdraw and ydraw
|
||||
mwa xdraw xbyte
|
||||
|
||||
lda xbyte
|
||||
and #$7
|
||||
sta ybit
|
||||
|
||||
lsrw xbyte ; div 8
|
||||
rorw xbyte
|
||||
rorw xbyte
|
||||
;---
|
||||
ldy xbyte
|
||||
|
||||
lda ydraw ; y = y - 7 because left lower. shouldn't it be 8?
|
||||
sec
|
||||
sbc #7
|
||||
tax
|
||||
|
||||
lda linetableL,x
|
||||
sta xbyte
|
||||
lda linetableH,x
|
||||
sta xbyte+1
|
||||
; mask preparation and character shifting
|
||||
ldx ybit
|
||||
beq MaskOK00
|
||||
MakeMask00
|
||||
.rept 8
|
||||
lsr mask1+#
|
||||
ror mask2+#
|
||||
.endr
|
||||
sec
|
||||
.rept 8
|
||||
ror char1+# ; in second (and next) lines we have C=1 - one SEC enough
|
||||
ror char2+#
|
||||
.endr
|
||||
dex
|
||||
bne MakeMask00
|
||||
MaskOK00
|
||||
; here x=0
|
||||
lda Erase
|
||||
beq CharLoopi ; it works, because x=0
|
||||
lda #$ff
|
||||
ldx #7
|
||||
EmptyChar
|
||||
sta char1,x
|
||||
sta char2,x
|
||||
dex
|
||||
bpl EmptyChar
|
||||
ldx #0
|
||||
CharLoopi
|
||||
lda (xbyte),y
|
||||
ora mask1,x
|
||||
and char1,x
|
||||
sta (xbyte),y
|
||||
iny
|
||||
lda (xbyte),y
|
||||
ora mask2,x
|
||||
and char2,x
|
||||
sta (xbyte),y
|
||||
dey
|
||||
adw xbyte #screenBytes
|
||||
inx
|
||||
cpx #8
|
||||
bne CharLoopi
|
||||
.ELSE
|
||||
mvx #7 temp ; line counter (Y)
|
||||
CharLoop1
|
||||
mva #7 temp+1 ; pixel counter (X)
|
||||
CharLoop2
|
||||
mva #0 color
|
||||
rol mask1,x
|
||||
bcc NoMaskNoPlot
|
||||
rol char1,x
|
||||
bcs NoPlot
|
||||
MakeCharPlot
|
||||
lda Erase
|
||||
bne ErasingChar
|
||||
inc color
|
||||
ErasingChar
|
||||
NoPlot
|
||||
jsr plot.MakePlot
|
||||
AfterCharPlot
|
||||
inw xdraw
|
||||
ldx temp
|
||||
dec temp+1
|
||||
bpl CharLoop2
|
||||
sec
|
||||
sbw xdraw #8
|
||||
dec ydraw
|
||||
ldx temp
|
||||
dex
|
||||
stx temp
|
||||
bpl CharLoop1
|
||||
clc
|
||||
lda ydraw
|
||||
adc #8
|
||||
sta ydraw
|
||||
bne EndPutChar
|
||||
NoMaskNoPlot
|
||||
rol char1,x
|
||||
jmp AfterCharPlot
|
||||
.ENDIF
|
||||
EndPutChar
|
||||
rts
|
||||
.endp
|
||||
|
||||
;--------------------------------------------------
|
||||
.proc PutChar4x4
|
||||
; puts 4x4 pixels char on the graphics screen
|
||||
; in: dx, dy (LOWER left corner of the char)
|
||||
; in: CharCode4x4 (.sbyte)
|
||||
; in: plot4x4color (0/255)
|
||||
; all pixels are being drawn
|
||||
; (empty and not empty)
|
||||
;--------------------------------------------------
|
||||
cpw dy #(screenheight-1)
|
||||
jcs TypeChar.EndPutChar ;nearest RTS
|
||||
cpw dy #(4)
|
||||
jcc TypeChar.EndPutChar ;nearest RTS
|
||||
cpw dx #(screenwidth-4)
|
||||
jcs TypeChar.EndPutChar ;nearest RTS
|
||||
; checks ommited.
|
||||
; char to the table
|
||||
lda CharCode4x4
|
||||
and #%00000001
|
||||
beq Upper4bits
|
||||
lda #$ff ; better option to check (nibbler4x4 = $00 or $ff)
|
||||
Upper4bits
|
||||
sta nibbler4x4
|
||||
lda CharCode4x4
|
||||
lsr
|
||||
sta fontind
|
||||
lda #$00
|
||||
sta fontind+1
|
||||
|
||||
adw fontind #font4x4
|
||||
|
||||
; and 4 bytes to the table
|
||||
ldy #0
|
||||
ldx #3
|
||||
CopyChar
|
||||
lda (fontind),y ; Y must be 0 !!!!
|
||||
bit nibbler4x4
|
||||
bpl GetUpper4bits
|
||||
:4 rol
|
||||
GetUpper4bits
|
||||
ora #$0f
|
||||
sta char1,x
|
||||
lda #$ff
|
||||
sta char2,x
|
||||
; and 4 bytes as a mask
|
||||
lda #$f0
|
||||
sta mask1,x
|
||||
lda #$00
|
||||
sta mask2,x
|
||||
adw fontind #32 ; next byte of 4x4 font
|
||||
dex
|
||||
bpl CopyChar
|
||||
|
||||
.IF FASTER_GRAF_PROCS = 1
|
||||
; calculating coordinates from xdraw and ydraw
|
||||
mwa dx xbyte
|
||||
|
||||
lda xbyte
|
||||
and #$7
|
||||
sta ybit
|
||||
|
||||
:3 lsrw xbyte ; div 8
|
||||
; rorw xbyte
|
||||
; rorw xbyte
|
||||
;---
|
||||
ldy xbyte ; horizontal byte offet stored in Y
|
||||
lda dy ; y = y - 3 because left lower.
|
||||
sec
|
||||
sbc #3
|
||||
tax
|
||||
|
||||
lda linetableL,x
|
||||
sta xbyte
|
||||
lda linetableH,x
|
||||
sta xbyte+1
|
||||
; mask preparation and character shifting
|
||||
ldx ybit
|
||||
beq MaskOK01
|
||||
MakeMask01
|
||||
.rept 4
|
||||
lsr mask1+#
|
||||
ror mask2+#
|
||||
.endr
|
||||
sec
|
||||
.rept 4
|
||||
ror char1+# ; in second (and next) lines we have C=1 - one SEC enough
|
||||
ror char2+#
|
||||
.endr
|
||||
dex
|
||||
bne MakeMask01
|
||||
MaskOK01
|
||||
ldx #0
|
||||
CharLoopi4x4
|
||||
lda (xbyte),y
|
||||
ora mask1,x
|
||||
bit plot4x4color
|
||||
bpl PutInColor0_1 ; only mask - no char
|
||||
and char1,x
|
||||
PutInColor0_1
|
||||
sta (xbyte),y
|
||||
iny
|
||||
lda (xbyte),y
|
||||
ora mask2,x
|
||||
bit plot4x4color
|
||||
bpl PutInColor0_2 ; only mask - no char
|
||||
and char2,x
|
||||
PutInColor0_2
|
||||
sta (xbyte),y
|
||||
dey
|
||||
adw xbyte #screenBytes
|
||||
inx
|
||||
cpx #4
|
||||
bne CharLoopi4x4
|
||||
.ELSE
|
||||
mwa xdraw char2
|
||||
mwa ydraw mask2
|
||||
mva color mask2+2
|
||||
mwa dx xdraw
|
||||
mwa dy ydraw
|
||||
mvx #3 temp ; line counter (Y)
|
||||
CharLoop1
|
||||
mva #3 temp+1 ; pixel counter (X)
|
||||
CharLoop2
|
||||
mva #0 color
|
||||
rol mask1,x
|
||||
bcc NoMaskNoPlot
|
||||
rol char1,x
|
||||
bcs NoPlot
|
||||
MakeCharPlot
|
||||
lda plot4x4color
|
||||
beq ErasingChar
|
||||
inc color
|
||||
ErasingChar
|
||||
NoPlot
|
||||
jsr plot.MakePlot
|
||||
AfterCharPlot
|
||||
inw xdraw
|
||||
ldx temp
|
||||
dec temp+1
|
||||
bpl CharLoop2
|
||||
sec
|
||||
sbw xdraw #4
|
||||
dec ydraw
|
||||
ldx temp
|
||||
dex
|
||||
stx temp
|
||||
bpl CharLoop1
|
||||
mwa char2 xdraw
|
||||
mwa mask2 ydraw
|
||||
mva mask2+2 color
|
||||
bpl EndPut4x4
|
||||
NoMaskNoPlot
|
||||
rol char1,x
|
||||
jmp AfterCharPlot
|
||||
.ENDIF
|
||||
EndPut4x4
|
||||
rts
|
||||
.endp
|
||||
|
||||
;--------------------------------------------------
|
||||
.proc ClearScreen
|
||||
|
||||
Reference in New Issue
Block a user