*/09FEB17:00 --GSCRASM--
ORG $8000
OBJ $8000
KEYCLR EQU $C010
KEYHIT EQU $C000
BEEP EQU $C030
GMODE EQU $C050
TMODE EQU $C051
MIXED EQU $C053
NOMIX EQU $C052
PAGE1 EQU $C054
HGR EQU $C057
STATUS EQU $C08E
DATA EQU $C08F
SOAKTIME EQU $301
SLOTADR EQU $303
KEYEXIT EQU $304
KEY EQU $305
PATORG EQU $307
ROWSTART EQU $309
RADR EQU $06
DEST EQU $08
DEST2 EQU $1C
CTR EQU $19
YREG EQU $1B
TMP EQU $1E
PAT EQU $1F
*
GETARRAY JMP INIT ;ROUTINE TO GET IMAGES FROM THE MICRONEYE
JMP ROLLUP ;ROLLUP SCREEN IMAGE 1/3 OF THE WAY
*
INIT LDA FIRST ;IF NOT FIRST TIME THRU ROUTINE THEN SKIP
BEQ A1 ; INITIALIZATION
DEC FIRST ;CLEAR 'FIRST TIME' FLAG TO FALSE
JSR GRCLR ;CLEAR HIRES SCREEN
A1 JSR SETGR ;SET UP APPLE FOR HIRES PAGE2 USAGE
START JSR ACIACLR ;FLUSH THE INPUT BUFFER
LDA PATORG
STA PAT
LDA #$D3
JSR SENDCMD
JSR SOAK
LDA #$C0
JSR SENDCMD ;TELL MICRONEYE TO SEND IMAGE AS SPECIFIED
LDX #0 ;INITIALIZE THE ROW INDEX
NEWROW LDY #0 ;START NEXT ROW AND INIT COLUMN INDEX (Y)
LDA ROWPTR,X ;BUILD BASE ROW ADRESS FOR CURRENT ROW
CLC
ADC ROWSTART
STA RADR ; FROM THE TABLE OF ADRESSES IN ROWPTR
INX
LDA ROWPTR,X
STA RADR+1
* LDA PATORG
* STA PAT
INX ;POINT X-REG TO NEXT ADDRESS IN ROWPTR
GET STY YREG ;GET NEXT BYTE FROM MICRONEYE
LDY SLOTADR ; LOAD OFFSET TO MICRONEYE SLOT
LDA STATUS,Y ; CHECK TO SEE IF NEXT BYTE HAS ARRIVED
LSR
BCS C15 ; IF BYTE AVAILABLE BRANCH
LDA #0 ; IF BYTE NOT YET AVAILABLE
STA CTR ; SET UP TIMEOUT COUNTER
LDA #$15
STA CTR+1
C0 DEC CTR ; CHECK FOR BYTE UNTIL TIMED OUT
BNE C1
DEC CTR+1
BNE C1
LDA BEEP ; IF TIMED OUT CLICK APPLE SPEAKER
LDA KEYHIT ; CHECK FOR KEYPRESS AFTER TIMING OUT
BMI DONE ; IF KEY HIT THEN RETURN TO APPLESOFT
JMP START ; OTHERWISE TRY REISSUING COMMAND SEQUENCE
C1 LDA STATUS,Y
LSR
BCC C0
C15 LDA DATA,Y ;WHEN BYTE AVAILABLE GET IT
AND PAT
STA TMP
LDA PAT
EOR #$7F
STA PAT
LDY YREG
AND (RADR),Y
ORA TMP
STA (RADR),Y
INY ;INCREMENT COLUMN POINTER
CPY #37 ;HAVE WE REACHED THE END OF THE COLUMN?
BNE GET ; IF NOT JUST GO GET THE NEXT BYTE
CPX #$80 ; OTHERWISE
BNE NEWROW ; IF NOT DONE WITH IMAGE GO TO NEXTROW
DONE LDA #$D1
JSR SENDCMD
LDA #$20 ; BY DEFAULT CLEAR THE 'EXIT CAUSED BY KEY' FLAG
STA KEY ; AND BLANK THE KEY VALUE FOR SAFEKEEPING
LDA #0
STA KEYEXIT
LDA KEYHIT ; IF A KEY WAS HIT, THOUGH, WE NEED TO
BPL D1
BIT KEYCLR ; CLEAR THE KEYBOARD STROBE
INC KEYEXIT ; SET THE 'EXIT CAUSED BY KEY' FLAG
STA KEY
CMP #"Q" ; IF THE KEY WAS A 'Q'
BNE D1
JSR GRCLR ; CLEAR THE GRAPHICS SCREEN
LDA TMODE
D1 RTS
*
ROLLUP LDX #0
RU0 LDA ROWPTR,X
STA RADR
CLC
ADC #$28
STA DEST
ADC #$28
STA DEST2
INX
LDA ROWPTR,X
STA RADR+1
STA DEST+1
STA DEST2+1
INX
LDY #39
RU1 LDA (DEST),Y
STA (RADR),Y
LDA (DEST2),Y
STA (DEST),Y
LDA #0
STA (DEST2),Y
DEY
BPL RU1
CPX #$80
BNE RU0
RTS
*
*
ACIACLR LDA #3 ;MASTER RESET ACIA
STY YREG
LDY SLOTADR
STA STATUS,Y
LDA #$14 ;1 START BIT, 8 DATA, 1 STOP BIT WITH EXT CLOCK
STA STATUS,Y
LDY YREG
RTS
*
GRCLR LDX #0 ;CLEAR PAGE2 OF HIRES
LDY #0
STY RADR
LDA #$20
STA RADR+1
TXA
E2 STA (RADR),Y
INY
BNE E2
INC RADR+1
INX
CPX #$20
BNE E2
RTS
*
SETGR LDA NOMIX ;SELECT MIXED GRAPHICS AND TEXT MODE
LDA HGR ;USE HIRES GRAPHICS
LDA PAGE1 ;USE PAGE1 OF HIRES
LDA GMODE ;SWITCH FROM TEXT TO GRAPHICS MODE
RTS
*
SENDCMD STY YREG ;SEND THEBYTE IN ACC TO THE MICRONEYE
LDY SLOTADR
PHA
F1 LDA STATUS,Y
AND #2
BEQ F1
PLA
STA DATA,Y
LDY YREG
RTS
*
SOAK LDA SOAKTIME+1 ;SOAK FOR THE NUMBER OF MILLISECONDS SPECIFIED
STA CTR+1 ; BY SOAKTIME
INC CTR+1
LDA SOAKTIME
STA CTR
INC CTR
LDA SOAKTIME
BNE G1
LDA SOAKTIME+1
BEQ G3
G1 JSR MSEC
DEC CTR
BNE G1
DEC CTR+1
BNE G1
G3 RTS
*
MSEC STY YREG ;1 MILLISECOND LOOP
LDY #197
H1 DEY
BNE H1
LDY YREG
RTS
********************
FIRST DFB 1
STRING DFB $FF
ROWPTR DA $2000,$2400,$2800,$2C00,$3000,$3400,$3800,$3C00
DA $2080,$2480,$2880,$2C80,$3080,$3480,$3880,$3C80
DA $2100,$2500,$2900,$2D00,$3100,$3500,$3900,$3D00
DA $2180,$2580,$2980,$2D80,$3180,$3580,$3980,$3D80
DA $2200,$2600,$2A00,$2E00,$3200,$3600,$3A00,$3E00
DA $2280,$2680,$2A80,$2E80,$3280,$3680,$3A80,$3E80
DA $2300,$2700,$2B00,$2F00,$3300,$3700,$3B00,$3F00
DA $2380,$2780,$2B80,$2F80,$3380,$3780,$3B80,$3F80
END