Opening Top and Bottom Borders on the Commodore 64


Opening up the top and bottom border is of course a trick any seasoned C64 demo writer knows. But anyone who started with BASIC before switching to 6510 probably remembers how much fun it was to get that extra space for sprites and even some simple graphics. So this posting is not telling anything new to most of you. I am just reminiscing my own youthful awe when I made the switch.

The program below shows how to do this. Set up a raster interrupt right before the bottom border start. Then toggle between 24 and 25 lines of text. This tricks the VIC into forgetting to turn on the border. The opened border can be used to display sprites. By manipulating the last address of the VIC page ($3fff by default), you can even get some interesting graphics. For example, Pasi Ojala posted an article Opening the Borders with some truly amazing effects! 

Of course, opening up the side borders is the next challenge!




; little demo to open up the border
; for win2c64 by Aart Bik
; https://www.aartbik.com/

scroly   =   $d011
raster   =   $d012
vicirq   =   $d019
irqmsk   =   $d01a
ciaicr   =   $dc0d
ci2icr   =   $dd0d
garbage  =   $3fff

;
; encode SYS 2064 line
; in BASIC program space
;
        .org  $0801                          
        .byte     $0c $08 $0a $00 $9e $20 $32 
        .byte $30 $36 $34 $00 $00 $00 $00 $00

lab2064 sei            ; disable irq
        ldx #$7f       ;
        stx ciaicr     ; disable timer irq CIA 1
        stx ci2icr     ; disable timer irq CIA 2
        ldx #$01       ;
        stx irqmsk     ; enable raster irq
        ldx #<nearend  ;
        stx $0314      ;
        ldx #>nearend  ;
        stx $0315      ; set handler
        ldx #$1b       ;
        stx scroly     ; 25 rows
        ldx #$f9       ;
        stx raster     ; irq at raster $f9
        ldx #$00       ;
        stx garbage    ; clear "garbage"
        cli            ; enable irq
        rts            ; done
;
; NEAR END HANDLER
;
nearend ldx #$13       ;
        stx scroly     ; 24 rows
delay   inx            ;
        bne delay      ;
        ldx #$1b       ;
        stx scroly     ; 25 rows
        ldx #$01       ;
        stx vicirq     ; ack irq
        jmp $ea31      ; continue

Comments

tony p said…
This comment has been removed by the author.
tony p said…
This comment has been removed by the author.
tony p said…
With NO DELAY (wasted cycles)
*=$C000 ; sys 49152 to run it
Init SEI ; set interrupt bit, make the CPU ignore interrupt req
LDA #%01111111 ; switch off interrupt signals from CIA-1
STA $DC0D
AND $D011 ; clear most significant bit of VIC's raster register
STA $D011
LDA $DC0D ; acknowledge pending interrupts from CIA-1
LDA $DD0D ; acknowledge pending interrupts from CIA-2

LDX #Irq
STX $0315
LDX #000001 ; enable raster interrupt signals from VIC
STX $D01A
DEX ; was a one above
STX $3fff ; clear garbage
CLI ; clear interrupt flag, allowing the CPU to respond to
RTS


Irq ASL $D019 ; acknowledge the interrupt by clearing the VIC's interrupt
selfmod LDX #0-0 ; 249 or 27
BMI restore25 ; branch if bit 7 set
STX $D012 ; set next rasterline where interrupt shall occur
LDX #249 ; value over 128 is a 'minus'
STX selfmod+1
LDX #$13 ; set 24 rows, has to be be done on line 249
STX $D011 ; scrolly trick for no border
JMP $EA31 ; keyboard scan

restore25 STX $D012 ; set next rasterline where interrupt shall occur
LDX #$1B ; decimal 27
STX $D011 ; undo scroll on any other line
STX selfmod+1 ; set rasterline where interrupt shall occur
JMP $EA81 ; no keyboard scan

Popular posts from this blog

Connecting Chess for Android to a Remote Server

Checkers Move Generation

Connecting with the DGT Board