* = $033C ;GRAPHICS 2 ;25/08/2025 ; ; ;--------------------------------- ;Enter/exit hires subroutine ; ;hires memory: fm $2000 to $3F3F ; (fm 8192 to 16191) ;col/scrn mem: fm $0400 to $07E7 ; (fm 1024 to 2023) ; ;Entry point to enter hires ; LDA $D011 ;Set bit 5 of $D011 ORA #$20 ;w/logic OR %00100000. PHA ; LDA $D018 ;Set bit 3 of $D018 ORA #$08 ;w/logic OR %00001000. ; BNE L1 ;goto L1 (always, ;given that A!=0) ; ;Entry point to exit hires ; LDA $D011 ;Reset bit 5 of $D011 AND #$DF ;w/AND mask %11011111 PHA ; LDA $D018 ;Reset bit 3 of $D018 AND #$F7 ;w/AND mask %11110111. ; ;Common part of the routine ; L1: STA $D018 ;set the VIC II PLA ;registers STA $D011 ; RTS ;Return to caller. ; ; ; ;--------------------------------- ;Fill screen memory subroutine ; ;hires memory: fm $2000 to $3F3F ; (fm 8192 to 16191) ;color memory: fm $0400 to $07E7 ; (fm 1024 to 2023) ; ;Set fill val in loc $FD (dec 253) ; ; ;Entry point to fill hires screen ; ;Set the following ;constants: LDY #$20 ;ptr val (MSB) Y=20h, LDX #$1F ;blocks to fill X=1Fh, LDA #$40 ;plus extra A=3Fh loc. ; BNE L2 ;goto L2 (always, ;given that A!=0) ; ; ;Entry point to fill color memory ; ;Set the following ;constants: LDY #$04 ;ptr val (MSB) Y=04h, LDX #$03 ;blocks to fill X=03h, LDA #$E8 ;plus extra A=E7h loc. ; ; L2: STA $02 ;Save extra loc A ;into $02. ; ;Common part of the fill routine ; STY $FC ;Set ptr (MSB) to Y. LDY #$00 ;Ptr val (LSB) Y=0. STY $FB ;Set ptr (LSB) to Y. ; LDA $FD ;Read fill val fm $FD. ; L3: DEY ;Fill a blk (FFh loc). STA ($FB),Y ; BNE L3 ; ; INC $FC ;Next block. DEX ; BNE L3 ; ; LDY $02 ;Recover extra loc ;from $02 ; L4: DEY ;fill extra locations. STA ($FB),Y ; BNE L4 ; ; RTS ;Return to caller. ; ; ; ;--------------------------------- ;plot x,y subroutine ; ;set x val in loc $FD (dec 253) ;and y val in loc $FE (dec 254) ;valid ranges 0<=x<=255, 0<=y<=199 ; ; LDY $FE ;load y value from $FE ;first of all let's ;calc the offset of ;first cell of the row TYA ; LSR ;divide by 8 LSR ; LSR ; ;now we have in A ;the number of the ;row (0-24) ; TAX ;save it into X LDA U,X ;read ads table ; TAX ;save the ads in X ; AND #$3F ;extract MSB of ptr ; ;Now we have in A ;the MSB offset ; STA $FC ;set ptr (MSB) ; ;set LSB of the ptr ; TXA ;recover the ads ; AND #$C0 ;reset bits 0 to 5 ; ;Now we have in A ;the LSB of ptr ; STA $FB ;set LSB of ptr ; ;Now we have in ptr ;the ads of the first ;cell of the row ; LDX $FD ;load x value from $FD TXA ;and copy it in A ; AND #$F8 ;perform an AND mask ;to obtain col offset STA $02 ;and save it in $02 ; TYA ;load y value in A AND #$07 ;perform an AND mask ;to obtain row offset ORA $02 ;add col offset to ;obtain index TAY ;save index in Y ; TXA ;recover x val fm X AND #$07 ;perform an AND mask ;to obtain bit pos TAX ;and save it into X ; LDA T,X ;read bit table ; ORA ($FB),Y ;set the bit in the STA ($FB),Y ;actual cell ; RTS ;return to caller ; ;Bit table T: .DB $80,$40,$20,$10,$08,$04,$02,$01 ; ;Ads table U: .DB $20,$61,$A2,$E3,$25,$66,$A7,$E8 .DB $2A,$6B,$AC,$ED,$2F,$70,$B1,$F2 .DB $34,$75,$B6,$F7,$39,$7A,$BB,$FC .DB $3E .END