From: cuz Date: Thu, 6 Jan 2005 12:26:47 +0000 (+0000) Subject: New code from Oliver Schmidt X-Git-Tag: V2.12.0~485 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=818879524067abbeb23ed00715734deef54ab519;p=cc65 New code from Oliver Schmidt git-svn-id: svn://svn.cc65.org/cc65/trunk@3351 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/include/apple2.h b/include/apple2.h index dad0b16bd..175df71d8 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -74,14 +74,21 @@ #define CH_CROSS '+' /* Return codes for get_ostype */ -#define APPLE_IIPLAIN 0x01 /* Plain Apple ][ */ -#define APPLE_IIPLUS 0x02 /* Apple ][+ */ -#define APPLE_IIIEM 0x03 /* Apple /// in emulation mode */ -#define APPLE_IIE 0x04 /* Apple //e */ -#define APPLE_IIEENH 0x05 /* Enhanced Apple //e */ -#define APPLE_IIECARD 0x06 /* Apple //e Option Card */ -#define APPLE_IIC 0x07 /* Apple //c */ - +#define APPLE_UNKNOWN 0x00 +#define APPLE_II 0x10 /* Apple ][ */ +#define APPLE_IIPLUS 0x11 /* Apple ][+ */ +#define APPLE_IIIEM 0x20 /* Apple /// (emulation) */ +#define APPLE_IIE 0x30 /* Apple //e */ +#define APPLE_IIEENH 0x31 /* Apple //e (enhanced) */ +#define APPLE_IIECARD 0x40 /* Apple //e Option Card */ +#define APPLE_IIC 0x50 /* Apple //c */ +#define APPLE_IIC35 0x51 /* Apple //c (3.5 ROM) */ +#define APPLE_IICEXP 0x53 /* Apple //c (Mem. Exp.) */ +#define APPLE_IICREV 0x54 /* Apple //c (Rev. Mem. Exp.) */ +#define APPLE_IICPLUS 0x55 /* Apple //c Plus */ +#define APPLE_IIGS 0x80 /* Apple IIgs */ +#define APPLE_IIGS1 0x81 /* Apple IIgs (ROM 1) */ +#define APPLE_IIGS3 0x83 /* Apple IIgs (ROM 3) */ /*****************************************************************************/ diff --git a/libsrc/apple2/_scrsize.s b/libsrc/apple2/_scrsize.s index 269f12a27..29d54edaf 100644 --- a/libsrc/apple2/_scrsize.s +++ b/libsrc/apple2/_scrsize.s @@ -6,10 +6,7 @@ .export screensize -.proc screensize - +screensize: ldx #40 ldy #24 rts - -.endproc diff --git a/libsrc/apple2/chline.s b/libsrc/apple2/chline.s index 83b03a504..ab07991b0 100644 --- a/libsrc/apple2/chline.s +++ b/libsrc/apple2/chline.s @@ -20,10 +20,10 @@ _chline: chlinedirect: cmp #$00 ; Is the length zero? - beq L9 ; Jump if done + beq done ; Jump if done sta tmp1 -L1: txa ; Screen code +: txa ; Screen code jsr cputdirect ; Direct output dec tmp1 - bne L1 -L9: rts + bne :- +done: rts diff --git a/libsrc/apple2/cputc.s b/libsrc/apple2/cputc.s index 3e70a8fcb..76ca7769c 100644 --- a/libsrc/apple2/cputc.s +++ b/libsrc/apple2/cputc.s @@ -31,16 +31,12 @@ _cputcxy: _cputc: cmp #$0D ; Test for \r = carrage return - bne L1 - lda #$00 ; Goto left edge of screen - sta CH - rts ; That's all we do -L1: + beq left cmp #$0A ; Test for \n = line feed beq newline ora #$80 ; Turn on high bit cmp #$E0 ; Test for lowercase - bmi cputdirect + bcc cputdirect and #$DF ; Convert to uppercase cputdirect: @@ -48,33 +44,27 @@ cputdirect: inc CH ; Bump to next column lda CH cmp #40 - bne return - lda #$00 + bne done +left: lda #$00 ; Goto left edge of screen sta CH -return: - rts - -putchar: - and INVFLG ; Apply normal, inverse, flash - ldy CH - sta (BASL),Y - rts +done: rts newline: - lda CH - pha inc CV lda CV cmp #24 - bne L2 + bne :+ lda #$00 sta CV -L2: - jsr BASCALC - pla - sta CH +: jsr BASCALC rts +putchar: + and INVFLG ; Apply normal, inverse, flash + ldy CH + sta (BASL),Y + rts + _gotoxy: sta CV ; Store Y jsr BASCALC diff --git a/libsrc/apple2/cvline.s b/libsrc/apple2/cvline.s index eeca3807a..044e73d58 100644 --- a/libsrc/apple2/cvline.s +++ b/libsrc/apple2/cvline.s @@ -20,11 +20,11 @@ _cvline: cvlinedirect: cmp #$00 ; Is the length zero? - beq L9 ; Jump if done + beq done ; Jump if done sta tmp1 -L1: txa ; Screen code +: txa ; Screen code jsr putchar ; Write, no cursor advance jsr newline ; Advance cursor to next line dec tmp1 - bne L1 -L9: rts + bne :- +done: rts diff --git a/libsrc/apple2/dosdetect.s b/libsrc/apple2/dosdetect.s index bf4af58ad..9b3731ac5 100644 --- a/libsrc/apple2/dosdetect.s +++ b/libsrc/apple2/dosdetect.s @@ -19,7 +19,6 @@ ; ProDOS 2.0.2 $22 ; ProDOS 2.0.3 $23 - .constructor initdostype .export __dos_type @@ -36,9 +35,9 @@ initdostype: bne done lda $BFFF ; ProDOS KVERSION cmp #$10 - bpl L1 + bcs :+ ora #$10 ; Make high nibble match major version -L1: sta __dos_type +: sta __dos_type done: rts .bss diff --git a/libsrc/apple2/get_ostype.s b/libsrc/apple2/get_ostype.s index d23254e19..9523d8b5e 100644 --- a/libsrc/apple2/get_ostype.s +++ b/libsrc/apple2/get_ostype.s @@ -1,52 +1,70 @@ ; -; Stefan Haubenthal, Jul 12 2003 +; Oliver Schmidt, 04.01.2005 ; ; unsigned char get_ostype(void) ; .constructor initostype - .export _get_ostype, ostype + .export _get_ostype ; Identify machine according to: ; "Apple II Miscellaneous TechNote #7: Apple II Family Identification" initostype: - ldx #$01 ; Start out with a plain Apple ][ - lda $FBB3 - cmp #$38 - beq identified - inx ; It's at least an Apple ][+ - cmp #$EA - bne apple2e - lda $FB1E - cmp #$AD - beq identified - inx ; It's an Apple /// in emulation mode - bne identified ; Branch always -apple2e: - ldx #$04 ; It's at least an Apple //e - lda $FBC0 - cmp #$EA - beq identified - inx ; It's at least an enhanced Apple //e - cmp #$E0 - bne apple2c - lda $FBDD - cmp #$02 - bne identified - inx ; It's an Apple //e Option Card - bne identified ; Branch always -apple2c: - ldx #$07 ; It's an Apple //c -identified: - stx ostype + sec + jsr $FE1F + bcs nogs + tya + ora #$80 +done: sta ostype rts +nogs: ldx #$FF +next: inx + lda value,x + ldy index,x + beq done ; $00 is no valid index + cmp $FB00,y + beq next +: inx + ldy index,x + bne :- + beq next ; Branch always _get_ostype: lda ostype ldx #$00 rts + + .rodata + +index: .byte $B3, $00 ; Apple ][ + .byte $B3, $1E, $00 ; Apple ][+ + .byte $B3, $1E, $00 ; Apple /// (emulation) + .byte $B3, $C0, $00 ; Apple //e + .byte $B3, $C0, $DD, $BE, $00 ; Apple //e Option Card + .byte $B3, $C0, $00 ; Apple //e (enhanced) + .byte $B3, $C0, $BF, $00 ; Apple //c + .byte $B3, $C0, $BF, $00 ; Apple //c (3.5 ROM) + .byte $B3, $C0, $BF, $00 ; Apple //c (Mem. Exp.) + .byte $B3, $C0, $BF, $00 ; Apple //c (Rev. Mem. Exp.) + .byte $B3, $C0, $BF, $00 ; Apple //c Plus + .byte $00 + +value: .byte $38, $10 ; Apple ][ + .byte $EA, $AD, $11 ; Apple ][+ + .byte $EA, $8A, $20 ; Apple /// (emulation) + .byte $06, $EA, $30 ; Apple //e + .byte $06, $E0, $02, $00, $40 ; Apple //e Option Card + .byte $06, $E0, $31 ; Apple //e (enhanced) + .byte $06, $00, $FF, $50 ; Apple //c + .byte $06, $00, $00, $51 ; Apple //c (3.5 ROM) + .byte $06, $00, $03, $53 ; Apple //c (Mem. Exp.) + .byte $06, $00, $04, $54 ; Apple //c (Rev. Mem. Exp.) + .byte $06, $00, $05, $55 ; Apple //c Plus + .byte $00 + + .bss ostype: .res 1 diff --git a/libsrc/apple2/systime.s b/libsrc/apple2/systime.s index 1d039e80e..5a90e3e55 100644 --- a/libsrc/apple2/systime.s +++ b/libsrc/apple2/systime.s @@ -13,16 +13,9 @@ .importzp sreg -.code - -.proc __systime - +__systime: lda #$FF tax sta sreg sta sreg+1 rts ; Return -1 - -.endproc - - diff --git a/libsrc/apple2/wherex.s b/libsrc/apple2/wherex.s index cb9be3f07..6cf140531 100644 --- a/libsrc/apple2/wherex.s +++ b/libsrc/apple2/wherex.s @@ -7,11 +7,7 @@ .include "apple2.inc" -.proc _wherex - +_wherex: lda CH ldx #$00 rts - -.endproc - diff --git a/libsrc/apple2/wherey.s b/libsrc/apple2/wherey.s index a8c341c48..30612cc77 100644 --- a/libsrc/apple2/wherey.s +++ b/libsrc/apple2/wherey.s @@ -7,11 +7,7 @@ .include "apple2.inc" -.proc _wherey - +_wherey: lda CV ldx #$00 rts - -.endproc - diff --git a/libsrc/apple2enh/_scrsize.s b/libsrc/apple2enh/_scrsize.s index d3e580807..1b020c344 100644 --- a/libsrc/apple2enh/_scrsize.s +++ b/libsrc/apple2enh/_scrsize.s @@ -8,11 +8,7 @@ .include "../apple2/apple2.inc" -.proc screensize - +screensize: ldx WNDWDTH ldy #24 rts - -.endproc - diff --git a/libsrc/apple2enh/chline.s b/libsrc/apple2enh/chline.s index 165dffb20..db5cde9c9 100644 --- a/libsrc/apple2enh/chline.s +++ b/libsrc/apple2enh/chline.s @@ -26,13 +26,13 @@ _chline: chlinedirect: cmp #$00 ; Is the length zero? - beq L9 ; Jump if done + beq done ; Jump if done sta tmp1 -L1: txa ; Screen code +: txa ; Screen code jsr cputdirect ; Direct output dec tmp1 - bne L1 -L9: rts + bne :- +done: rts diff --git a/libsrc/apple2enh/cputc.s b/libsrc/apple2enh/cputc.s index 5cfdc3a14..c82a67d5b 100644 --- a/libsrc/apple2enh/cputc.s +++ b/libsrc/apple2enh/cputc.s @@ -14,7 +14,6 @@ .include "../apple2/apple2.inc" - initconio: lda #$FF ; Normal character display mode sta INVFLG @@ -33,10 +32,7 @@ _cputcxy: _cputc: cmp #$0D ; Test for \r = carrage return - bne L1 - stz CH ; Goto left edge of screen - rts ; That's all we do -L1: + beq left cmp #$0A ; Test for \n = line feed beq newline ora #$80 ; Turn on high bit @@ -46,9 +42,18 @@ cputdirect: inc CH ; Bump to next column lda CH cmp WNDWDTH - bne return - stz CH -return: + bne done +left: stz CH ; Goto left edge of screen +done: rts + +newline: + inc CV + lda CV + cmp #24 + bne :+ + lda #$00 + sta CV +: jsr BASCALC rts putchar: @@ -56,13 +61,11 @@ putchar: cpy #$FF ; Normal character display mode? beq put cmp #$E0 ; Lowercase? - bmi mask + bcc mask and #$7F ; Inverse lowercase bra put -mask: - and INVFLG ; Apply normal, inverse, flash -put: - ldy CH +mask: and INVFLG ; Apply normal, inverse, flash +put: ldy CH bit RD80VID ; In 80 column mode? bpl col40 ; No, in 40 cols pha @@ -75,23 +78,7 @@ put: sta (BASL),Y bit LOWSCR rts -col40: - sta (BASL),Y - rts - -newline: - lda CH - pha - inc CV - lda CV - cmp #24 - bne L2 - lda #$00 - sta CV -L2: - jsr BASCALC - pla - sta CH +col40: sta (BASL),Y rts _gotoxy: diff --git a/libsrc/apple2enh/cvline.s b/libsrc/apple2enh/cvline.s index 7357242ca..ff9704a15 100644 --- a/libsrc/apple2enh/cvline.s +++ b/libsrc/apple2enh/cvline.s @@ -20,11 +20,11 @@ _cvline: cvlinedirect: cmp #$00 ; Is the length zero? - beq L9 ; Jump if done + beq done ; Jump if done sta tmp1 -L1: txa ; Screen code +: txa ; Screen code jsr putchar ; Write, no cursor advance jsr newline ; Advance cursor to next line dec tmp1 - bne L1 -L9: rts + bne :- +done: rts diff --git a/libsrc/apple2enh/textframe.s b/libsrc/apple2enh/textframe.s index 2020f6451..9b36dc73b 100644 --- a/libsrc/apple2enh/textframe.s +++ b/libsrc/apple2enh/textframe.s @@ -47,15 +47,15 @@ noxy: sta XORIGIN plx ; Restore index loop: lda XOFFS,x clc - bpl L1 ; Relative to left edge? + bpl :+ ; Relative to left edge? adc WIDTH -L1: adc XORIGIN +: adc XORIGIN jsr pusha lda YOFFS,x clc - bpl L2 ; Relative to top? + bpl :+ ; Relative to top? adc HEIGHT -L2: adc YORIGIN +: adc YORIGIN jsr _gotoxy ; Call this one, will pop params txa tay