Skip to content

Apple II Hires Screen

Oliver Schmidt edited this page Dec 2, 2019 · 3 revisions

Direct writing to the hires video screen

Because of the non-contiguous memory layout it's not trivial to directly write to the Apple II hires video screen. Therefore usually the Applesoft ROM routines are used instead. However, those ROM routines are rather optimized for size than for speed. When speed is utmost priority, then it is appropriate to use a table with the start address of every hires line.

The code below has ca65 create such a table (in fact one table with the low byte of the address and one table with the high byte of the address) using its .repeat control command. Additionally it contains a snippet showing how to use the two tables.

    .include "zeropage.inc"


    .rodata

BASELO:
    .repeat $C0, I
    .byte   I & $08 << 4 | I & $C0 >> 1 | I & $C0 >> 3
    .endrep

BASEHI:
    .repeat $C0, I
    .byte   >$2000 | I & $07 << 2 | I & $30 >> 4
    .endrep


    .code

    ; tmp1: Value to write to the hires screen
    ; X:    Line to write the value to (0..191)
    ; Y:    Byte in that line to write the value to (0..39)
    lda BASELO,x
    sta ptr1
    lda BASEHI,x
    sta ptr1+1
    lda tmp1
    sta (ptr1),y
Clone this wiki locally