 ; This is an Applesoft interface to super-res
 ; The source is from NIBBLE magazine...
 ;
 ; Super.Hires
 ; By Tom Dorris
 ; Copyright (C) 1987
 ; By MicroSPARC, Inc.
 ; Concord, MA 01742
 ;
 ;
 ;
          org   $6000
 SuperHires     START
 chkcom   equ   $debe
 synchr   equ   $dec0                    ; print Syntax Error
 frmnum   equ   $dd67
 illqty   equ   $e199                    ; print Illegal Quantity Error
 getadr   equ   $e752
 getbyte  equ   $e6f8
 disply   equ   $c029
 adrlo    equ   $fd
 adrhi    equ   $fe
 adrbnk   equ   $ff
 clrmsk   equ   $fc
 xhi      equ   $6
 xlo      equ   $7
 ycor     equ   $8
 color    equ   $9
 ;
 ;
          LONGA OFF
          LONGI OFF
 setamp   lda   #<begin
          sta   $3f6
          lda   #>begin
          sta   $3f7
          rts
 ;
 begin    sta   xhi
          jsr   $00b1
          lda   xhi
          cmp   #137
          beq   text
          cmp   #145
          beq   hgr
          cmp   #146
          beq   hcl
          cmp   #147
          beq   hpl
          cmp   #168
          beq   str
          cmp   #136
          beq   gr
          jmp   prsynerr
 text     lda   #$1
          sta disply
          rts
 hcl      jmp   hcolor
 hpl      jmp   hplot
 str      jmp   store
 gr       lda   #163
          sta   disply
          rts
 hgr      jsr   gr
          jsr   setup
 more     sta   [$fd]
          inc   adrlo
          bne   more
          inc   adrhi
          ldy   adrhi
          cpy   #$a0
          bne   more
          ldx   #0
 clr      lda   clrs,x
          sta   $e19e00,x
          inx
          cpx   #$20
          bne   clr
          rts
 ; Paintworks Plus Palette
 clrs     dc    10h'00 00 77 07 41 08 2c 07 0f 00'
          dc    10h'80 00 70 0f 00 0d a9 0f f0 0f'
          dc    10h'e0 00 df 04 af 0d 8f 07 cc 0c'
          dc    2h'ff 0f'
 hcolor   jsr   getbyte
          txa
          and   #$0f
          sta   color
          rts
 store    jsr   getbyte
          cpx   #$10
          bcc   ok
          rts
 ok       stx   xhi
          jsr   getbt
          stx   xlo
          jsr   getbt
          txa
          and   #$0f
          sta   ycor
          jsr   getbt
          stx   clrmsk
          lda   xhi
          asl   A
          tax
          lda   clrmsk
          asl   A
          asl   A
          asl   A
          asl   A
          adc   ycor
          sta   $e19e00,x
          lda   xlo
          sta   $e19e01,x
          rts
 hplot    jsr   frmnum
          jsr   getadr
          lda   $50
          sta   xlo
          lda   $51
          sta   xhi
          beq   xok
          cmp   #2
          bcs   errout
          lda   xlo
          cmp   #64
          bcc   xok
 errout   jmp   prillqty
 xok      jsr   getbt
          stx   ycor
          cpx   #200
          bcc   yok
          jmp   prillqty
 yok      jsr   setup
          lda   xlo
          clc
          ror   A
          ldx   xhi
          beq   nodiv
          ora   #$80
 nodiv    sta   adrlo
          ldx   ycor
          inx
 domore   dex
          beq   done2
          lda   #$a0
          clc
          adc   adrlo
          sta   adrlo
          bcc   noover
          inc   adrhi
 noover   jmp   domore
 done2    lda   xlo
          and   #1
          bne   odd
          lda   color
          asl   A
          asl   A
          asl   A
          asl   A
          sta   clrmsk
          lda   [$fd]
          and   #$0f
          sta   [$fd]
          jmp   plt
 odd      lda   color
          and   #$0f
          sta   clrmsk
          lda   [$fd]
          and   #$f0
          sta   [$fd]
 plt      lda   [$fd]
          ora   clrmsk
          sta   [$fd]
          rts
 getbt    jsr   chkcom
          jmp   getbyte
 setup    lda   #$e1
          sta   adrbnk
          lda   #$20
          sta   adrhi
          lda   #$00
          sta   adrlo
          rts
 ;
 prillqty jsr   text
          jmp   illqty
 ;
 prsynerr jsr   text
          lda   #$ff
          jmp   synchr
          END
