.include "apple2.inc"
+; ------------------------------------------------------------------------
+; Initialization
+
+.segment "INIT"
+
initconio:
lda #$FF ; Normal character display mode
sta INVFLG
lda #$00
- jsr SETWND ; Reset text window to full screen
- rts
+ jmp SETWND ; Reset text window to full screen
+; ------------------------------------------------------------------------
; Plot a character - also used as internal function
+.code
+
_cputcxy:
- pha ; Save C
- jsr popa ; Get Y
- jsr _gotoxy
- pla ; Restore C
+ pha ; Save C
+ jsr popa ; Get Y
+ jsr _gotoxy
+ pla ; Restore C
_cputc:
- cmp #$0D ; Test for \r = carrage return
- beq left
- cmp #$0A ; Test for \n = line feed
- beq newline
- ora #$80 ; Turn on high bit
- cmp #$E0 ; Test for lowercase
- bcc cputdirect
- and #$DF ; Convert to uppercase
+ cmp #$0D ; Test for \r = carrage return
+ beq left
+ cmp #$0A ; Test for \n = line feed
+ beq newline
+ ora #$80 ; Turn on high bit
+ cmp #$E0 ; Test for lowercase
+ bcc cputdirect
+ and #$DF ; Convert to uppercase
cputdirect:
- jsr putchar
- inc CH ; Bump to next column
- lda CH
- cmp #40
- bne done
+ jsr putchar
+ inc CH ; Bump to next column
+ lda CH
+ cmp #40
+ bne done
left: lda #$00 ; Goto left edge of screen
- sta CH
+ sta CH
done: rts
newline:
- inc CV
- lda CV
- cmp #24
- bne :+
- lda #$00
- sta CV
-: jsr BASCALC
- rts
-
-putchar:
- and INVFLG ; Apply normal, inverse, flash
- ldy CH
- sta (BASL),Y
- rts
+ inc CV
+ lda CV
+ cmp #24
+ bne :+
+ lda #$00
+ sta CV
+: jmp BASCALC
+
+putchar:
+ and INVFLG ; Apply normal, inverse, flash
+ ldy CH
+ sta (BASL),Y
+ rts
_gotoxy:
- sta CV ; Store Y
- jsr BASCALC
- jsr popa ; Get X
- sta CH ; Store X
- rts
+ sta CV ; Store Y
+ jsr BASCALC
+ jsr popa ; Get X
+ sta CH ; Store X
+ rts
; Identify machine according to:
; "Apple II Miscellaneous TechNote #7: Apple II Family Identification"
+; ------------------------------------------------------------------------
+; Initialization
+
+.segment "INIT"
+
initostype:
sec
jsr $FE1F
bne :-
beq next ; Branch always
+; ------------------------------------------------------------------------
+
+.code
+
_get_ostype:
lda ostype
ldx #$00
rts
- .rodata
+.rodata
index: .byte $B3, $00 ; Apple ][
.byte $B3, $1E, $00 ; Apple ][+
.byte $00
- .bss
+.bss
ostype: .res 1
FNAM_LEN = $280
FNAM = $281
- .assert MAXARGS <= (BASIC_BUF_LEN - 2)/2, error, "Too many arguments"
MAXARGS = 10 ; Maximum number of arguments allowed
REM = $B2 ; BASIC token-code
NAME_LEN = 15 ; maximum length of command-name
+
+; Validate sizes
+.if MAXARGS > (BASIC_BUF_LEN - 2)/2
+.error "Too many arguments"
+.endif
+
+; Get possible command-line arguments. Goes into the special INIT segment,
+; which may be reused after the startup code is run
+
+.segment "INIT"
-; Get possible command-line arguments.
-;
initmainargs:
; Assume that the program was loaded, a moment ago, by the traditional LOAD