Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ________________________________________
- ;
- ; Plot function
- ;
- ; draws a pixel on bitmap screen
- ;
- ;
- ; 92cycl, without tables
- ;_________________________________________
- ; 10 SYS2064
- *=$0801
- BYTE $0B, $08, $0A, $00, $9E, $32, $30, $36, $34, $00, $00, $00
- *=$810
- jmp _main
- _Vic = $d000
- _Vmem= $2000
- _Cmem= $0400
- _V17 byte 0
- _V24 byte 0
- _Y = $2
- _X = $3
- wOffs = $fd
- ; ************************************************
- ;
- ; Plot
- ;
- ; input: _X* (word 0-319**)
- ; _Y* (byte 0-200**)
- ; *_X, _Y are variables in memory, not the registers
- ; **no boundary check
- ;
- ; offset = BaseAddr + 320*int(Y/8)+(Y and 7) + 8*int(X/8)
- ; pixel = 2^(7-(X and 7))
- ;
- ; ************************************************
- _Plot
- ldy #0 ; 2 ; comput. dY
- sty wOffs ; 3 ; reset lobyte
- lda _Y ; 3
- lsr ; 2
- lsr ; 2
- lsr ; 2 ; int(Y/8)
- sta wOffs+1 ; 3 ; 256*int(Y/8) hibyte (lobyte=0)
- lsr ; 2
- ror wOffs ; 5
- lsr ; 2 ; 64*int(Y/8) hibyte
- ror wOffs ; 5 ; 64*int(Y/8) lobyte (= 320*int(Y/8) lobyte)
- adc wOffs+1 ; 3 ; 256*int(Y/8) + 64*int(Y/8) hibyte
- sta wOffs+1 ; 3 ; =320*int(Y/8) hibyte
- lda _Y ; 3 ; add (Y and 7)
- and #7 ; 2
- ora wOffs ; 3 ; lobyte [xx000xxx]
- sta wOffs ; 3 48
- lda _X ; 3 ; dX + dY + BaseAddr
- and #248 ; 2
- adc wOffs ; 3
- sta wOffs ; 3
- lda wOffs+1 ; 3
- adc _X+1 ; 3
- adc #>_Vmem ; 2
- sta wOffs+1 ; 3 22
- lda _X ; 3 ; set pixel-bit
- and #7 ; 2
- tax ; 2
- lda (wOffs),y ; 5 ; draws the pixel
- ora ortab,x ; 4
- sta (wOffs),y ; 6 22
- rts
- ortab
- byte 128, 64, 32, 16, 8, 4, 2, 1
- ; ***************************************************
- _main
- ; set bitmap mode and bitmap window
- lda _Vic+17 ;bitmap mode
- sta _V17
- ora #32
- sta _Vic+17
- lda _Vic+24 ;videomem => 8192 ($2000)
- sta _V24
- ora #8
- sta _Vic+24
- ; clear video bitmap
- lda #01 ; black pen, white background
- jsr _ClearCol
- jsr _ClearBmap
- ; fillscreen loop
- lda #199
- sta _Y
- _rep lda #>319
- sta _X+1
- lda #<319
- sta _X
- _toPlot jsr _Plot
- dec _X
- bne _toPlot
- jsr _Plot
- dec _X
- dec _X+1
- bpl _toPlot
- dec _Y
- bne _rep
- ; restore char video
- jsr WaitForSpace
- lda _V17
- sta _Vic+17
- lda _V24
- sta _Vic+24
- lda #32 ;space
- jsr _ClearCol
- rts
- WaitForSpace ;thanx to Phaze101
- lda #$7f ;%01111111 - only row 7 KB matrix
- sta $dc00
- lda $dc01
- and #$10 ;mask %00010000
- bne WaitForSpace
- rts
- ; ***************************************************
- ; ClearCol
- ;
- ; clear screen/color memory
- ;
- ; input: .A = fill value
- ;
- _ClearCol
- ldx #200
- _ccl sta _Cmem-1 ,x
- sta _Cmem+199,x
- sta _Cmem+399,x
- sta _Cmem+599,x
- sta _Cmem+799,x
- dex
- bne _ccl
- rts
- ; ***************************************************
- ; ClearBmap
- ;
- ; clear bitmap screen
- ;
- align 256
- _ClearBmap
- ldx #200
- lda #0
- _cbl sta _Vmem-1 ,x
- sta _Vmem+199,x
- sta _Vmem+399,x
- sta _Vmem+599,x
- sta _Vmem+799,x
- sta _Vmem+ 999,x
- sta _Vmem+1199,x
- sta _Vmem+1399,x
- sta _Vmem+1599,x
- sta _Vmem+1799,x
- sta _Vmem+1999,x
- sta _Vmem+2199,x
- sta _Vmem+2399,x
- sta _Vmem+2599,x
- sta _Vmem+2799,x
- sta _Vmem+2999,x
- sta _Vmem+3199,x
- sta _Vmem+3399,x
- sta _Vmem+3599,x
- sta _Vmem+3799,x
- sta _Vmem+3999,x
- sta _Vmem+4199,x
- sta _Vmem+4399,x
- sta _Vmem+4599,x
- sta _Vmem+4799,x
- sta _Vmem+4999,x
- sta _Vmem+5199,x
- sta _Vmem+5399,x
- sta _Vmem+5599,x
- sta _Vmem+5799,x
- sta _Vmem+5999,x
- sta _Vmem+6199,x
- sta _Vmem+6399,x
- sta _Vmem+6599,x
- sta _Vmem+6799,x
- sta _Vmem+6999,x
- sta _Vmem+7199,x
- sta _Vmem+7399,x
- sta _Vmem+7599,x
- sta _Vmem+7799,x
- dex
- bne _cbl
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement