From 11be575b6dddeba424c0bf02d848f6dd143ada8d Mon Sep 17 00:00:00 2001 From: kym Date: Thu, 5 Dec 2013 11:40:44 +0000 Subject: [PATCH 001/407] Initial Creativision Import --- asminc/creativision.inc | 38 +++++++ include/creativision.h | 59 +++++++++++ libsrc/creativision/_scrsize.s | 15 +++ libsrc/creativision/boxchars.inc | 62 +++++++++++ libsrc/creativision/cclear.s | 29 ++++++ libsrc/creativision/cgetc.s | 17 +++ libsrc/creativision/chline.s | 24 +++++ libsrc/creativision/clrscr.s | 41 ++++++++ libsrc/creativision/color.s | 13 +++ libsrc/creativision/cputc.s | 125 ++++++++++++++++++++++ libsrc/creativision/ctype.s | 172 +++++++++++++++++++++++++++++++ libsrc/creativision/cvline.s | 29 ++++++ libsrc/creativision/gotox.s | 19 ++++ libsrc/creativision/gotoxy.s | 22 ++++ libsrc/creativision/gotoy.s | 19 ++++ libsrc/creativision/joy.s | 58 +++++++++++ libsrc/creativision/libref.s | 9 ++ libsrc/creativision/mainargs.s | 24 +++++ libsrc/creativision/psg.s | 68 ++++++++++++ libsrc/creativision/setcursor.s | 36 +++++++ libsrc/creativision/sysuname.s | 39 +++++++ libsrc/creativision/wherex.s | 19 ++++ libsrc/creativision/wherey.s | 19 ++++ 23 files changed, 956 insertions(+) create mode 100644 asminc/creativision.inc create mode 100644 include/creativision.h create mode 100644 libsrc/creativision/_scrsize.s create mode 100644 libsrc/creativision/boxchars.inc create mode 100644 libsrc/creativision/cclear.s create mode 100644 libsrc/creativision/cgetc.s create mode 100644 libsrc/creativision/chline.s create mode 100644 libsrc/creativision/clrscr.s create mode 100644 libsrc/creativision/color.s create mode 100644 libsrc/creativision/cputc.s create mode 100644 libsrc/creativision/ctype.s create mode 100644 libsrc/creativision/cvline.s create mode 100644 libsrc/creativision/gotox.s create mode 100644 libsrc/creativision/gotoxy.s create mode 100644 libsrc/creativision/gotoy.s create mode 100644 libsrc/creativision/joy.s create mode 100644 libsrc/creativision/libref.s create mode 100644 libsrc/creativision/mainargs.s create mode 100644 libsrc/creativision/psg.s create mode 100644 libsrc/creativision/setcursor.s create mode 100644 libsrc/creativision/sysuname.s create mode 100644 libsrc/creativision/wherex.s create mode 100644 libsrc/creativision/wherey.s diff --git a/asminc/creativision.inc b/asminc/creativision.inc new file mode 100644 index 000000000..624b65e8f --- /dev/null +++ b/asminc/creativision.inc @@ -0,0 +1,38 @@ +;* +;** VTech Creativision Definitions +;* + +;** Screen +SCREEN_ROWS = 24 +SCREEN_COLS = 32 +SCREEN_PTR = $3A +CURSOR_X = $3C +CURSOR_Y = $3D + +;** VDP +VDP_CONTROL_W = $3001 +VDP_DATA_W = $3000 +VDP_STATUS_R = $2001 +VDP_DATA_R = $2000 + +;** PIA +PIA0_DATA = $1000 +PIA0_STATUS = $1001 +PIA1_DATA = $1002 +PIA1_STATUS = $1003 + +;** General +CH_VLINE = 33 +CH_HLINE = 34 +CH_ULCORNER = 35 +CH_URCORNER = 36 +CH_LLCORNER = 37 +CH_LRCORNER = 38 + +;** I/O +ZP_KEYBOARD = $10 +ZP_JOY0_DIR = $11 +ZP_JOY1_DIR = $13 +ZP_JOY_LBUTTONS = $16 +ZP_JOY_RBUTTONS = $17 + diff --git a/include/creativision.h b/include/creativision.h new file mode 100644 index 000000000..adaa1caab --- /dev/null +++ b/include/creativision.h @@ -0,0 +1,59 @@ +/* CreatiVision Header */ + +#ifndef _CVISION_H + +#define _CVISION_H + +#define CH_VLINE 33 +#define CH_HLINE 34 +#define CH_ULCORNER 35 +#define CH_URCORNER 36 +#define CH_LLCORNER 37 +#define CH_LRCORNER 38 + +#define DYN_DRV 0 + +/* Colours - from TMS9918 */ +#define C_TRANSPARENT 0 +#define C_BLACK 1 +#define C_MED_GREEN 2 +#define C_LIGHT_GREEN 3 +#define C_DARK_BLUE 4 +#define C_LIGHT_BLUE 5 +#define C_DARK_RED 6 +#define C_CYAN 7 +#define C_MED_RED 8 +#define C_LIGHT_RED 9 +#define C_DARK_YELLOW 10 +#define C_LIGHT_YELLOW 11 +#define C_DARK_GREEN 12 +#define C_MAGENTA 13 +#define C_GREY 14 +#define C_WHITE 15 + +/* Joystick states */ +#define JOY_UP 5 +#define JOY_DOWN 1 +#define JOY_LEFT 7 +#define JOY_RIGHT 3 +#define JOY_LEFT_UP 6 +#define JOY_LEFT_DOWN 8 +#define JOY_RIGHT_UP 4 +#define JOY_RIGHT_DOWN 2 +#define JOY_LBUTTON 1 +#define JOY_RBUTTON 2 + +/* Joystick values */ +#define JOY_LEFT_DIR 1 +#define JOY_RIGHT_DIR 2 +#define JOY_LEFT_BUTTONS 3 +#define JOY_RIGHT_BUTTONS 4 + +/* Protos */ +void __fastcall__ psg_outb( unsigned char b ); +void __fastcall__ psg_delay( unsigned char b ); +void psg_silence( void ); +void __fastcall__ bios_playsound( void *a, unsigned char b); +unsigned char __fastcall__ joystate( unsigned char which ); + +#endif diff --git a/libsrc/creativision/_scrsize.s b/libsrc/creativision/_scrsize.s new file mode 100644 index 000000000..fdcc7fc60 --- /dev/null +++ b/libsrc/creativision/_scrsize.s @@ -0,0 +1,15 @@ +;* +;** _scrsize.s +;* + + .export screensize + + .include "creativision.inc" + +.proc screensize + + ldx #SCREEN_COLS + ldy #SCREEN_ROWS + rts + +.endproc diff --git a/libsrc/creativision/boxchars.inc b/libsrc/creativision/boxchars.inc new file mode 100644 index 000000000..0916d49ce --- /dev/null +++ b/libsrc/creativision/boxchars.inc @@ -0,0 +1,62 @@ +; Boxchars + +boxchars: + ; Vertical Line + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + + ; Horizontal Line + .byte 0 + .byte 0 + .byte 0 + .byte $ff + .byte 0 + .byte 0 + .byte 0 + .byte 0 + + ; Top Left + .byte 0 + .byte 0 + .byte 0 + .byte $1f + .byte $18 + .byte $18 + .byte $18 + .byte $18 + + ; Top Right + .byte 0 + .byte 0 + .byte 0 + .byte $F8 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + + ; Bottom Left + .byte $18 + .byte $18 + .byte $18 + .byte $1F + .byte 0 + .byte 0 + .byte 0 + .byte 0 + + ; Bottom Right + .byte $18 + .byte $18 + .byte $18 + .byte $F8 + .byte 0 + .byte 0 + .byte 0 + .byte 0 diff --git a/libsrc/creativision/cclear.s b/libsrc/creativision/cclear.s new file mode 100644 index 000000000..507c072bd --- /dev/null +++ b/libsrc/creativision/cclear.s @@ -0,0 +1,29 @@ +;* +;* void cclearxy (unsigned char x, unsigned char y, unsigned char length); +;* void cclear (unsigned char length); +;* + + .export _cclearxy, _cclear + .import popa, _gotoxy, cputdirect + .importzp tmp1 + +_cclearxy: + pha ; Save length + jsr popa ; get Y + jsr _gotoxy + pla + +_cclear: + cmp #0 ; Zero length? + beq L2 + sta tmp1 + +L1: + lda #$20 ; Space + jsr cputdirect + dec tmp1 + bne L1 + +L2: rts + + diff --git a/libsrc/creativision/cgetc.s b/libsrc/creativision/cgetc.s new file mode 100644 index 000000000..f1e89942a --- /dev/null +++ b/libsrc/creativision/cgetc.s @@ -0,0 +1,17 @@ +;* cgetc + + .export _cgetc + .include "creativision.inc" + +_cgetc: + lda #$80 + +L1: + bit ZP_KEYBOARD + bpl L1 + + lda ZP_KEYBOARD + and #$7f + rts + + diff --git a/libsrc/creativision/chline.s b/libsrc/creativision/chline.s new file mode 100644 index 000000000..c206180e0 --- /dev/null +++ b/libsrc/creativision/chline.s @@ -0,0 +1,24 @@ +;* void chlinexy (unsigned char x, unsigned char y, unsigned char length); +;* void chline (unsigned char length); + + .export _chlinexy, _chline + .import popa, _gotoxy, cputdirect + .importzp tmp1 + + .include "creativision.inc" + +_chlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length + +_chline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #CH_HLINE ; Horizontal line, screen code + jsr cputdirect ; Direct output + dec tmp1 + bne L1 +L9: rts diff --git a/libsrc/creativision/clrscr.s b/libsrc/creativision/clrscr.s new file mode 100644 index 000000000..ef800a9bd --- /dev/null +++ b/libsrc/creativision/clrscr.s @@ -0,0 +1,41 @@ +;* +;* clrscr +;* +;* NB: All screen functions assume Graphics Mode 1 in a default configuration. +;* Therefore, this is hard coded to use $1000-$12FF as screen VRAM. + + .export _clrscr + .include "creativision.inc" + +_clrscr: + + sei ; Disable interrupts. Default INT handler reads VDP_STATUS + ; and would lose any setup done here. + + lda #$00 ; VRAM offset low + sta VDP_CONTROL_W + + lda #$50 ; VRAM offset high ($10 OR $40) + sta VDP_CONTROL_W + + lda #$C0 ; Space from ROM setup + + ldx #0 + ldy #3 + +L1: sta VDP_DATA_W + inx + bne L1 + dey + bne L1 + + cli ; Let interrupts go again + + lda #0 + sta CURSOR_X + sta CURSOR_Y + sta SCREEN_PTR + + rts diff --git a/libsrc/creativision/color.s b/libsrc/creativision/color.s new file mode 100644 index 000000000..b6fd360b4 --- /dev/null +++ b/libsrc/creativision/color.s @@ -0,0 +1,13 @@ +;* +;* unsigned char __fastcall__ textcolor (unsigned char color); +;* unsigned char __fastcall__ bgcolor (unsigned char color); +;* unsigned char __fastcall__ bordercolor (unsigned char color); +;* + + .export _textcolor, _bgcolor, _bordercolor + .import return0 + .include "creativision.inc" + +_bordercolor = return0; +_textcolor = return0; +_bgcolor = return0; diff --git a/libsrc/creativision/cputc.s b/libsrc/creativision/cputc.s new file mode 100644 index 000000000..902caf277 --- /dev/null +++ b/libsrc/creativision/cputc.s @@ -0,0 +1,125 @@ +; +; Written by Groepaz/Hitmen +; Cleanup by Ullrich von Bassewitz +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + + .export _cputcxy, _cputc, cputdirect, putchar + .export newline + .constructor initconio + .import popa, _gotoxy + .import setcursor + + .importzp tmp3,tmp4 + + .include "creativision.inc" + .include "boxchars.inc" + +;----------------------------------------------------------------------------- + +.code + +_cputcxy: + pha ; Save C + jsr popa ; Get Y + jsr _gotoxy ; Set cursor, drop x + pla ; Restore C + +; Plot a character - also used as internal function + +_cputc: cmp #$0d ; CR? + bne L1 + lda #0 + sta CURSOR_X + beq plot ; Recalculate pointers + +L1: cmp #$0a ; LF? + beq newline ; Recalculate pointers + +; Printable char of some sort + +cputdirect: + jsr putchar ; Write the character to the screen + +; Advance cursor position + +advance: + ldy CURSOR_X + iny + cpy #SCREEN_COLS + bne L3 + inc CURSOR_Y ; new line + ldy #0 ; + cr +L3: sty CURSOR_X + jmp plot + +newline: + inc CURSOR_Y + +; Set cursor position, calculate RAM pointers + +plot: ldy CURSOR_X + ldx CURSOR_Y + jmp setcursor ; Set the new cursor + + +; Write one character to the screen without doing anything else, return X +; position in Y + +putchar: + cmp #$5B + bcc IS_UPPER + + clc + sbc #$1F + +IS_UPPER: + cmp #$20 + bcc BAD_CHAR + + pha + lda SCREEN_PTR + sei + sta VDP_CONTROL_W + lda SCREEN_PTR+1 + ora #$40 + sta VDP_CONTROL_W + pla + clc + adc #160 + sta VDP_DATA_W + cli + +BAD_CHAR: + jmp plot + +;----------------------------------------------------------------------------- +; Initialize the conio subsystem. Code goes into the INIT segment, which may +; be reused after startup. + +.segment "INIT" + +initconio: + lda #$0 + sta SCREEN_PTR + lda #$10 + sta SCREEN_PTR+1 + + ; Copy box characters to slot + sei + lda #08 + sta VDP_CONTROL_W + lda #$46 + sta VDP_CONTROL_W + ldx #0 +LL: + lda boxchars,x + sta VDP_DATA_W + inx + cpx #48 + bne LL + + cli + jmp plot diff --git a/libsrc/creativision/ctype.s b/libsrc/creativision/ctype.s new file mode 100644 index 000000000..6e0ab1785 --- /dev/null +++ b/libsrc/creativision/ctype.s @@ -0,0 +1,172 @@ +; +; Ullrich von Bassewitz, 02.06.1998 +; +; Character specification table. +; + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it were'nt for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). +; +; * It is highly portable. The only unportable part is the table itself, +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. +; +; +; Bit assignments: +; +; 0 - Lower case char +; 1 - Upper case char +; 2 - Numeric digit +; 3 - Hex digit (both, lower and upper) +; 4 - Control character +; 5 - The space character itself +; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v') +; 7 - Space or tab character + + .export __ctype + +__ctype: + +.repeat 2 ; 2 times for normal and inverted + + .byte $10 ; 0/00 ___ctrl_@___ + .byte $10 ; 1/01 ___ctrl_A___ + .byte $10 ; 2/02 ___ctrl_B___ + .byte $10 ; 3/03 ___ctrl_C___ + .byte $10 ; 4/04 ___ctrl_D___ + .byte $10 ; 5/05 ___ctrl_E___ + .byte $10 ; 6/06 ___ctrl_F___ + .byte $10 ; 7/07 ___ctrl_G___ + .byte $10 ; 8/08 ___ctrl_H___ + .byte $D0 ; 9/09 ___ctrl_I___ + .byte $50 ; 10/0a ___ctrl_J___ + .byte $50 ; 11/0b ___ctrl_K___ + .byte $50 ; 12/0c ___ctrl_L___ + .byte $50 ; 13/0d ___ctrl_M___ + .byte $10 ; 14/0e ___ctrl_N___ + .byte $10 ; 15/0f ___ctrl_O___ + .byte $10 ; 16/10 ___ctrl_P___ + .byte $10 ; 17/11 ___ctrl_Q___ + .byte $10 ; 18/12 ___ctrl_R___ + .byte $10 ; 19/13 ___ctrl_S___ + .byte $10 ; 20/14 ___ctrl_T___ + .byte $10 ; 21/15 ___ctrl_U___ + .byte $10 ; 22/16 ___ctrl_V___ + .byte $10 ; 23/17 ___ctrl_W___ + .byte $10 ; 24/18 ___ctrl_X___ + .byte $10 ; 25/19 ___ctrl_Y___ + .byte $10 ; 26/1a ___ctrl_Z___ + .byte $10 ; 27/1b ___ctrl_[___ + .byte $10 ; 28/1c ___ctrl_\___ + .byte $10 ; 29/1d ___ctrl_]___ + .byte $10 ; 30/1e ___ctrl_^___ + .byte $10 ; 31/1f ___ctrl_____ + .byte $A0 ; 32/20 ___SPACE___ + .byte $00 ; 33/21 _____!_____ + .byte $00 ; 34/22 _____"_____ + .byte $00 ; 35/23 _____#_____ + .byte $00 ; 36/24 _____$_____ + .byte $00 ; 37/25 _____%_____ + .byte $00 ; 38/26 _____&_____ + .byte $00 ; 39/27 _____'_____ + .byte $00 ; 40/28 _____(_____ + .byte $00 ; 41/29 _____)_____ + .byte $00 ; 42/2a _____*_____ + .byte $00 ; 43/2b _____+_____ + .byte $00 ; 44/2c _____,_____ + .byte $00 ; 45/2d _____-_____ + .byte $00 ; 46/2e _____._____ + .byte $00 ; 47/2f _____/_____ + .byte $0C ; 48/30 _____0_____ + .byte $0C ; 49/31 _____1_____ + .byte $0C ; 50/32 _____2_____ + .byte $0C ; 51/33 _____3_____ + .byte $0C ; 52/34 _____4_____ + .byte $0C ; 53/35 _____5_____ + .byte $0C ; 54/36 _____6_____ + .byte $0C ; 55/37 _____7_____ + .byte $0C ; 56/38 _____8_____ + .byte $0C ; 57/39 _____9_____ + .byte $00 ; 58/3a _____:_____ + .byte $00 ; 59/3b _____;_____ + .byte $00 ; 60/3c _____<_____ + .byte $00 ; 61/3d _____=_____ + .byte $00 ; 62/3e _____>_____ + .byte $00 ; 63/3f _____?_____ + + .byte $00 ; 64/40 _____@_____ + .byte $0A ; 65/41 _____A_____ + .byte $0A ; 66/42 _____B_____ + .byte $0A ; 67/43 _____C_____ + .byte $0A ; 68/44 _____D_____ + .byte $0A ; 69/45 _____E_____ + .byte $0A ; 70/46 _____F_____ + .byte $02 ; 71/47 _____G_____ + .byte $02 ; 72/48 _____H_____ + .byte $02 ; 73/49 _____I_____ + .byte $02 ; 74/4a _____J_____ + .byte $02 ; 75/4b _____K_____ + .byte $02 ; 76/4c _____L_____ + .byte $02 ; 77/4d _____M_____ + .byte $02 ; 78/4e _____N_____ + .byte $02 ; 79/4f _____O_____ + .byte $02 ; 80/50 _____P_____ + .byte $02 ; 81/51 _____Q_____ + .byte $02 ; 82/52 _____R_____ + .byte $02 ; 83/53 _____S_____ + .byte $02 ; 84/54 _____T_____ + .byte $02 ; 85/55 _____U_____ + .byte $02 ; 86/56 _____V_____ + .byte $02 ; 87/57 _____W_____ + .byte $02 ; 88/58 _____X_____ + .byte $02 ; 89/59 _____Y_____ + .byte $02 ; 90/5a _____Z_____ + .byte $00 ; 91/5b _____[_____ + .byte $00 ; 92/5c _____\_____ + .byte $00 ; 93/5d _____]_____ + .byte $00 ; 94/5e _____^_____ + .byte $00 ; 95/5f _UNDERLINE_ + .byte $00 ; 96/60 ___grave___ + .byte $09 ; 97/61 _____a_____ + .byte $09 ; 98/62 _____b_____ + .byte $09 ; 99/63 _____c_____ + .byte $09 ; 100/64 _____d_____ + .byte $09 ; 101/65 _____e_____ + .byte $09 ; 102/66 _____f_____ + .byte $01 ; 103/67 _____g_____ + .byte $01 ; 104/68 _____h_____ + .byte $01 ; 105/69 _____i_____ + .byte $01 ; 106/6a _____j_____ + .byte $01 ; 107/6b _____k_____ + .byte $01 ; 108/6c _____l_____ + .byte $01 ; 109/6d _____m_____ + .byte $01 ; 110/6e _____n_____ + .byte $01 ; 111/6f _____o_____ + .byte $01 ; 112/70 _____p_____ + .byte $01 ; 113/71 _____q_____ + .byte $01 ; 114/72 _____r_____ + .byte $01 ; 115/73 _____s_____ + .byte $01 ; 116/74 _____t_____ + .byte $01 ; 117/75 _____u_____ + .byte $01 ; 118/76 _____v_____ + .byte $01 ; 119/77 _____w_____ + .byte $01 ; 120/78 _____x_____ + .byte $01 ; 121/79 _____y_____ + .byte $01 ; 122/7a _____z_____ + .byte $00 ; 123/7b _____{_____ + .byte $00 ; 124/7c _____|_____ + .byte $00 ; 125/7d _____}_____ + .byte $00 ; 126/7e _____~_____ + .byte $40 ; 127/7f ____DEL____ + +.endrepeat diff --git a/libsrc/creativision/cvline.s b/libsrc/creativision/cvline.s new file mode 100644 index 000000000..4e7d2563e --- /dev/null +++ b/libsrc/creativision/cvline.s @@ -0,0 +1,29 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; +; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); +; void cvline (unsigned char length); +; + + .export _cvlinexy, _cvline + .import popa, _gotoxy, putchar, newline + .importzp tmp1 + + .include "creativision.inc" + +_cvlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cvline + +_cvline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #CH_VLINE ; Vertical bar + jsr putchar ; Write, no cursor advance + jsr newline ; Advance cursor to next line + dec tmp1 + bne L1 +L9: rts diff --git a/libsrc/creativision/gotox.s b/libsrc/creativision/gotox.s new file mode 100644 index 000000000..6970e5d24 --- /dev/null +++ b/libsrc/creativision/gotox.s @@ -0,0 +1,19 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; void gotox (unsigned char x); +; + + .export _gotox + .import setcursor + + .include "creativision.inc" + +.proc _gotox + + sta CURSOR_X ; Set new position + tay + ldx CURSOR_Y + jmp setcursor ; Set the cursor to the new position + +.endproc diff --git a/libsrc/creativision/gotoxy.s b/libsrc/creativision/gotoxy.s new file mode 100644 index 000000000..6c0cf932f --- /dev/null +++ b/libsrc/creativision/gotoxy.s @@ -0,0 +1,22 @@ +; +; Ullrich von Bassewitz, 06.08.1998 +; +; void gotoxy (unsigned char x, unsigned char y); +; + + .export _gotoxy + .import setcursor + .import popa + + .include "creativision.inc" + +.proc _gotoxy + + sta CURSOR_Y ; Set Y + jsr popa ; Get X + sta CURSOR_X ; Set X + tay + ldx CURSOR_Y + jmp setcursor ; Set the cursor position + +.endproc diff --git a/libsrc/creativision/gotoy.s b/libsrc/creativision/gotoy.s new file mode 100644 index 000000000..484608d75 --- /dev/null +++ b/libsrc/creativision/gotoy.s @@ -0,0 +1,19 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; void gotoy (unsigned char y); +; + + .export _gotoy + .import setcursor + + .include "creativision.inc" + +.proc _gotoy + + sta CURSOR_Y ; Set new position + tax + ldy CURSOR_X + jmp setcursor ; Set the cursor to the new position + +.endproc diff --git a/libsrc/creativision/joy.s b/libsrc/creativision/joy.s new file mode 100644 index 000000000..f1c9b09f7 --- /dev/null +++ b/libsrc/creativision/joy.s @@ -0,0 +1,58 @@ +;* +;* Creativision Joystick Function +;* +;* unsigned char __fastcall__ joystate(unsigned char joy); +;* +;* JOY_1 -> Return Left Joystick direction +;* JOY_2 -> Return Right Joystick direction +;* JOY_3 -> Return Left Joystick buttons +;* JOY_4 -> Return Right Joystick buttons +;* +;* Will only work if interrupts are enabled. + + .export _joystate + .include "creativision.inc" + +_joystate: + cmp #1 ; Left Direction + bne l1 + + lda $11 + beq l5 + and #$f + lsr a + tax + inx + txa + rts + +l1: cmp #2 ; Right Direction + bne l2 + + lda $13 + beq l5 + and #$f + lsr a + tax + inx + txa + rts + +l2: cmp #3 ; Left Buttons + bne l3 + + lda $16 + beq l5 + and #$f + rts + +l3: cmp #4 + bne l4 + + lda $17 + beq l5 + and #$f + rts + +l4: lda #0 +l5: rts diff --git a/libsrc/creativision/libref.s b/libsrc/creativision/libref.s new file mode 100644 index 000000000..d947c1aa4 --- /dev/null +++ b/libsrc/creativision/libref.s @@ -0,0 +1,9 @@ +; +; Oliver Schmidt, 2013-05-31 +; + + .export joy_libref, tgi_libref + .import _exit + +joy_libref := _exit +tgi_libref := _exit diff --git a/libsrc/creativision/mainargs.s b/libsrc/creativision/mainargs.s new file mode 100644 index 000000000..7ed8d46f4 --- /dev/null +++ b/libsrc/creativision/mainargs.s @@ -0,0 +1,24 @@ +; +; Ullrich von Bassewitz, 2003-03-07 +; +; Setup arguments for main +; + + + .constructor initmainargs, 24 + .import __argc, __argv + + +;--------------------------------------------------------------------------- +; Get possible command-line arguments. Goes into the special INIT segment, +; which may be reused after the startup code is run + +.segment "INIT" + +.proc initmainargs + + rts + +.endproc + + diff --git a/libsrc/creativision/psg.s b/libsrc/creativision/psg.s new file mode 100644 index 000000000..12b474339 --- /dev/null +++ b/libsrc/creativision/psg.s @@ -0,0 +1,68 @@ +; void __fastcall__ psg_outb( unsigned char b ); +; void __fastcall__ psg_delayms( unsigned char c); +; void __fastcall__ bios_playsound( void *b, unsigned char c); +; void psg_silence( void ); + + .export _psg_outb, _psg_silence, _psg_delay + .export _bios_playsound + .import popa + .include "creativision.inc" + +_psg_outb: + + ;* Let BIOS output the value + jmp $FE77 + +_psg_silence: + + jmp $FE54 + + +_psg_delay: + + tay +l1: + lda #200 +l2: + sbc #1 + bne l2 + + lda #200 +l3: + sbc #1 + bne l3 + + dey + bne l1 + + rts + + +;* Creativision Sound Player +;* +;* Based on BIOS sound player. +;* Pass a pointer to a set of note triples, terminated with a tempo byte +;* and the len (max 255) + +_bios_playsound: + + pha ; Save Length Byte + + sei + + lda #$D5 ; BIOS volume table low + sta $4 + lda #$FC ; BIOS volume table high + sta $5 + + jsr popa ; Get Sound table pointer low + sta $0 + jsr popa ; Get Sound table pointer high + sta $1 + + pla + tay ; Put length in Y + dey + php + jmp $fbed ; Let BIOS do it's thing + diff --git a/libsrc/creativision/setcursor.s b/libsrc/creativision/setcursor.s new file mode 100644 index 000000000..9918cbcb2 --- /dev/null +++ b/libsrc/creativision/setcursor.s @@ -0,0 +1,36 @@ +; +; Written by Groepaz/Hitmen +; Cleanup by Ullrich von Bassewitz +; +; Set the cursor position + + .export setcursor + + .include "creativision.inc" + +;----------------------------------------------------------------------------- + +.proc setcursor + + tya + clc + adc addrlo,x + sta SCREEN_PTR + + lda addrhi,x + adc #0 + sta SCREEN_PTR+1 + rts + +.endproc + +;----------------------------------------------------------------------------- +; Tables with screen addresses + +addrlo: .repeat SCREEN_ROWS,line + .byte <($1000+(line*SCREEN_COLS)) + .endrepeat + +addrhi: .repeat SCREEN_ROWS,line + .byte >($1000+(line*SCREEN_COLS)) + .endrepeat diff --git a/libsrc/creativision/sysuname.s b/libsrc/creativision/sysuname.s new file mode 100644 index 000000000..df1a81b67 --- /dev/null +++ b/libsrc/creativision/sysuname.s @@ -0,0 +1,39 @@ +; +; Ullrich von Bassewitz, 2003-08-12 +; +; unsigned char __fastcall__ _sysuname (struct utsname* buf); +; + + .export __sysuname, utsdata + + .import utscopy + + __sysuname = utscopy + +;-------------------------------------------------------------------------- +; Data. We define a fixed utsname struct here and just copy it. + +.rodata + +utsdata: + ; sysname + .asciiz "cc65" + + ; nodename + .asciiz "" + + ; release + .byte ((.VERSION >> 8) & $0F) + '0' + .byte '.' + .byte ((.VERSION >> 4) & $0F) + '0' + .byte $00 + + ; version + .byte (.VERSION & $0F) + '0' + .byte $00 + + ; machine + .asciiz "CREATIVISION" + + + diff --git a/libsrc/creativision/wherex.s b/libsrc/creativision/wherex.s new file mode 100644 index 000000000..f9df2d1a1 --- /dev/null +++ b/libsrc/creativision/wherex.s @@ -0,0 +1,19 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; unsigned char wherex (void); +; + + .export _wherex + + .include "creativision.inc" + +.proc _wherex + + lda CURSOR_X + ldx #$00 + rts + +.endproc + + diff --git a/libsrc/creativision/wherey.s b/libsrc/creativision/wherey.s new file mode 100644 index 000000000..6d7b056f5 --- /dev/null +++ b/libsrc/creativision/wherey.s @@ -0,0 +1,19 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; unsigned char wherey (void); +; + + .export _wherey + + .include "creativision.inc" + +.proc _wherey + + lda CURSOR_Y + ldx #$00 + rts + +.endproc + + From d23db09f7f424ae837b2cabaa1f57506073044e9 Mon Sep 17 00:00:00 2001 From: John Brandwood Date: Thu, 25 Feb 2016 12:40:31 -0800 Subject: [PATCH 002/407] Add optional feature to use brackets instead of parens for 6502 indirect addressing. --- doc/ca65.sgml | 14 ++++++++++++ src/ca65/ea65.c | 56 +++++++++++++++++++++++++++++----------------- src/ca65/feature.c | 2 ++ src/ca65/feature.h | 1 + src/ca65/global.c | 1 + src/ca65/global.h | 1 + 6 files changed, 55 insertions(+), 20 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 213033cd4..f863e7e10 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -2699,6 +2699,20 @@ Here's a list of all control commands and a description, what they do: at character is not allowed to start an identifier, even with this feature enabled. + bracket_as_indirect + + Use [] intead of () for the indirect addressing mode. + Example: + + + lda [$82] + lda [$82,x] + lda [$82],y + + / for more information. + c_comments Allow C like comments using /* and */ as left and right diff --git a/src/ca65/ea65.c b/src/ca65/ea65.c index 5f76f2966..69468c072 100644 --- a/src/ca65/ea65.c +++ b/src/ca65/ea65.c @@ -40,6 +40,7 @@ #include "expr.h" #include "instr.h" #include "nexttok.h" +#include "global.h" @@ -53,6 +54,20 @@ void GetEA (EffAddr* A) /* Parse an effective address, return the result in A */ { unsigned long Restrictions; + token_t IndirectEnter; + token_t IndirectLeave; + const char* IndirectExpect; + + /* Choose syntax for indirection */ + if (BracketAsIndirect) { + IndirectEnter = TOK_LBRACK; + IndirectLeave = TOK_RBRACK; + IndirectExpect = "']' expected"; + } else { + IndirectEnter = TOK_LPAREN; + IndirectLeave = TOK_RPAREN; + IndirectExpect = "')' expected"; + } /* Clear the output struct */ A->AddrModeSet = 0; @@ -97,23 +112,7 @@ void GetEA (EffAddr* A) NextTok (); A->AddrModeSet = AM65_ACCU; - } else if (CurTok.Tok == TOK_LBRACK) { - - /* [dir] or [dir],y */ - NextTok (); - A->Expr = Expression (); - Consume (TOK_RBRACK, "']' expected"); - if (CurTok.Tok == TOK_COMMA) { - /* [dir],y */ - NextTok (); - Consume (TOK_Y, "`Y' expected"); - A->AddrModeSet = AM65_DIR_IND_LONG_Y; - } else { - /* [dir] */ - A->AddrModeSet = AM65_DIR_IND_LONG | AM65_ABS_IND_LONG; - } - - } else if (CurTok.Tok == TOK_LPAREN) { + } else if (CurTok.Tok == IndirectEnter) { /* One of the indirect modes */ NextTok (); @@ -127,12 +126,12 @@ void GetEA (EffAddr* A) /* (adr,x) */ NextTok (); A->AddrModeSet = AM65_ABS_X_IND | AM65_DIR_X_IND; - ConsumeRParen (); + Consume (IndirectLeave, IndirectExpect); } else if (CurTok.Tok == TOK_S) { /* (rel,s),y */ NextTok (); A->AddrModeSet = AM65_STACK_REL_IND_Y; - ConsumeRParen (); + Consume (IndirectLeave, IndirectExpect); ConsumeComma (); Consume (TOK_Y, "`Y' expected"); } else { @@ -142,7 +141,7 @@ void GetEA (EffAddr* A) } else { /* (adr) or (adr),y */ - ConsumeRParen (); + Consume (IndirectLeave, IndirectExpect); if (CurTok.Tok == TOK_COMMA) { /* (adr),y */ NextTok (); @@ -154,6 +153,23 @@ void GetEA (EffAddr* A) } } + } else if (CurTok.Tok == TOK_LBRACK) { + + /* Never executed if BracketAsIndirect feature is enabled. */ + /* [dir] or [dir],y */ + NextTok (); + A->Expr = Expression (); + Consume (TOK_RBRACK, "']' expected"); + if (CurTok.Tok == TOK_COMMA) { + /* [dir],y */ + NextTok (); + Consume (TOK_Y, "`Y' expected"); + A->AddrModeSet = AM65_DIR_IND_LONG_Y; + } else { + /* [dir] */ + A->AddrModeSet = AM65_DIR_IND_LONG | AM65_ABS_IND_LONG; + } + } else { /* Remaining stuff: diff --git a/src/ca65/feature.c b/src/ca65/feature.c index 3462d5501..35bdf4b98 100644 --- a/src/ca65/feature.c +++ b/src/ca65/feature.c @@ -64,6 +64,7 @@ static const char* FeatureKeys[FEAT_COUNT] = { "force_range", "underline_in_numbers", "addrsize", + "bracket_as_indirect", }; @@ -121,6 +122,7 @@ feature_t SetFeature (const StrBuf* Key) case FEAT_FORCE_RANGE: ForceRange = 1; break; case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= 1; break; case FEAT_ADDRSIZE: AddrSize = 1; break; + case FEAT_BRACKET_AS_INDIRECT: BracketAsIndirect = 1; break; default: /* Keep gcc silent */ break; } diff --git a/src/ca65/feature.h b/src/ca65/feature.h index 3a520a54a..050c197f0 100644 --- a/src/ca65/feature.h +++ b/src/ca65/feature.h @@ -66,6 +66,7 @@ typedef enum { FEAT_FORCE_RANGE, FEAT_UNDERLINE_IN_NUMBERS, FEAT_ADDRSIZE, + FEAT_BRACKET_AS_INDIRECT, /* Special value: Number of features available */ FEAT_COUNT diff --git a/src/ca65/global.c b/src/ca65/global.c index e77b9201c..31e599f00 100644 --- a/src/ca65/global.c +++ b/src/ca65/global.c @@ -83,4 +83,5 @@ unsigned char CComments = 0; /* Allow C like comments */ unsigned char ForceRange = 0; /* Force values into expected range */ unsigned char UnderlineInNumbers = 0; /* Allow underlines in numbers */ unsigned char AddrSize = 0; /* Allow .ADDRSIZE function */ +unsigned char BracketAsIndirect = 0; /* Use '[]' not '()' for indirection */ diff --git a/src/ca65/global.h b/src/ca65/global.h index fb254f835..397d9221b 100644 --- a/src/ca65/global.h +++ b/src/ca65/global.h @@ -85,6 +85,7 @@ extern unsigned char CComments; /* Allow C like comments */ extern unsigned char ForceRange; /* Force values into expected range */ extern unsigned char UnderlineInNumbers; /* Allow underlines in numbers */ extern unsigned char AddrSize; /* Allow .ADDRSIZE function */ +extern unsigned char BracketAsIndirect; /* Use '[]' not '()' for indirection */ From ef153364eab92e2124035e5555b8c5cfbfa6e5b4 Mon Sep 17 00:00:00 2001 From: John Brandwood Date: Fri, 26 Feb 2016 08:10:11 -0800 Subject: [PATCH 003/407] Add indirect JMP examples and fix typos in the documentation. --- doc/ca65.sgml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index f863e7e10..14fe8714f 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -2701,13 +2701,15 @@ Here's a list of all control commands and a description, what they do: bracket_as_indirect - Use [] intead of () for the indirect addressing mode. + Use [] instead of () for the indirect addressing modes. Example: lda [$82] lda [$82,x] lda [$82],y + jmp [$fffe] + jmp [table,x] Date: Fri, 26 Feb 2016 17:11:11 -0500 Subject: [PATCH 004/407] draft of cc65-intern document --- doc/cc65-intern.sgml | 138 +++++++++++++++++++++++++++++++++++++++++++ doc/index.sgml | 3 + 2 files changed, 141 insertions(+) create mode 100644 doc/cc65-intern.sgml diff --git a/doc/cc65-intern.sgml b/doc/cc65-intern.sgml new file mode 100644 index 000000000..f3aef939a --- /dev/null +++ b/doc/cc65-intern.sgml @@ -0,0 +1,138 @@ + + +
+cc65 internals +<author><url url="mailto:brad@rainwarrior.ca" name="Brad Smith"> +<date>2016-02-27 + +<abstract> +Internal details of cc65 code generation, +such as calling assembly functions from C. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + + + +<sect>Calling assembly functions from C<p> + +<sect1>Calling conventions<p> + +There are two calling conventions used in cc65: + +<itemize> + <item><tt/cdecl/ - passes all parameters on the C-stack. + <p> + <item><tt/fastcall/ - passes the rightmost parameter in + registers <tt>A/X/sreg</tt> an all others on the C-stack. + <p> +</itemize> + +The default convention is <tt/fastcall/, but this can be changed with +the <tt/--all-cdecl/ command line option. If a convention is specified in +the function's declaration, that convention will be used instead. +Variadic functions will always use <tt/cdecl/ convention. + +If the <tt/--standard/ command line option is used, +the <tt/cdecl/ and <tt/fastcall/ keywords will not be available. +The standard compliant variations <tt/__cdecl__/ and <tt/__fastcall__/ are always available. + +K & R style function prototypes may be used, but they do not alter the calling conventions in any way. + +<sect1>Prologue, before the function call<p> + +If the function is declared as fastcall, the rightmost argument will be loaded into +the <tt>A/X/sreg</tt> registers: + +<itemize> + <item><tt/A/ - 8-bit parameter, or low byte of larger tyes<p> + <item><tt/X/ - 16-bit high byte, or second byte of 32-bits<p> + <item><tt/sreg/ - Zeropage pseudo-register including high 2 bytes of 32-bit parameter<p> +</itemize> + +All other parameters will be pushed to the C-stack from left to right. +The rightmost parameter will have the lowest address on the stack, +and multi-byte parameters will have their least significant byte at the lower address. + +The <tt/Y/ register will contain the number of bytes pushed to the stack for this function, +and the <tt/sp/ pseudo-register is a zeropage pointer to the base of the C-stack. + +Example: +<tscreen><verb> +// C prototype +void foo(unsigned bar, unsigned char baz); + +; C-stack layout within the function: +; +; +------------------+ +; | High byte of bar | +; Offset 2 ->+------------------+ +; | Low byte of bar | +; Offset 1 ->+------------------+ +; | baz | +; Offset 0 ->+------------------+ + +; Example code for accessing bar. The variable is in A/X after this code snippet: +; + ldy #2 ; Offset of high byte of bar + lda (sp),y ; High byte now in A + tax ; High byte now in X + dey ; Offset of low byte of bar + lda (sp),y ; Low byte now in A +</verb></tscreen> + +Variadic functions push all parameters exactly as other <tt/cdecl/ convention functions, +but the value of <tt/Y/ should be used to determine how many bytes of parameters +were placed onto the stack. + +<sect1>Epilogue, after the functiona call<p> + +<sect2>Return requirements</p> + +If the function has a return value, it will appear in the <tt>A/X/sreg</tt> registers. + +Functions with an 8-bit return value (<tt/char/ or <tt/unsigned char/) are expected +to promote this value to a 16-bit integer on return, and store the high byte in <tt/X/. +The compiler will depend on the promoted value in some cases (e.g. implicit conversion to <tt/int/), +and failure to return the high byte in <tt/X/ will cause unexpected errors. +This problem does not apply to the <tt/sreg/ pseudo-register, which is only +used if the return type is 32-bit. + +If the function has a void return type, the compiler will not depend on the result +of <tt>A/X/sreg</tt>, so these may be clobbered by the function. + +The C-stack pointer <tt/sp/ must be restored by the function to its value before the +function call prologue. It may pop all of its parameters from the C-stack +(e.g. using the <tt/runtime/ function <tt/popa/.), +or it could adjust <tt/sp/ directly. +On entry to the function the <tt/Y/ register contains the number of bytes +pushed to the stack, which may be added to <tt/sp/ to restore its original state. + +The internal pseudo-register <tt/regbank/ must not be changed by the function. + +<sect2>Clobbered state</p> + +The <tt/Y/ register may be clobbered by the function. +The compiler will not depend on its state after a function call. + +The <tt>A/X/sreg</tt> registers may be clobbered if any of them +are not used by the return value (see above). + +Many of the internal pseudo-registers used by cc65 are available for +free use by any function called by C, and do not need to be preserved. +Note that if another C function is called from your assembly function, +it may clobber any of these itself: +<itemize> + <item><tt>tmp1 .. tmp4</tt><p> + <item><tt>ptr1 .. ptr4</tt><p> + <item><tt>regsave</tt><p> + <item><tt>sreg</tt> (if unused by return)<p> +</itemize> + + + +</article> + diff --git a/doc/index.sgml b/doc/index.sgml index b6ef06ef9..5b36db6e9 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -58,6 +58,9 @@ <tag><htmlurl url="coding.html" name="coding.html"></tag> Contains hints on creating the most effective code with cc65. + + <tag><htmlurl url="cc65-intern.html" name="cc65-intern.html"></tag> + Describes internal details of cc65, such as calling conventions. <tag><htmlurl url="using-make.html" name="using-make.html"></tag> Build programs, using the GNU Make utility. From 222ab93026cdd03ea85c49a1999f5d568be2efab Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Fri, 26 Feb 2016 17:33:46 -0500 Subject: [PATCH 005/407] revise note on prototypes/K&R conventions --- doc/cc65-intern.sgml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/doc/cc65-intern.sgml b/doc/cc65-intern.sgml index f3aef939a..0bcb51cba 100644 --- a/doc/cc65-intern.sgml +++ b/doc/cc65-intern.sgml @@ -40,7 +40,11 @@ If the <tt/--standard/ command line option is used, the <tt/cdecl/ and <tt/fastcall/ keywords will not be available. The standard compliant variations <tt/__cdecl__/ and <tt/__fastcall__/ are always available. -K & R style function prototypes may be used, but they do not alter the calling conventions in any way. +If a function has a prototype, parameters are pushed to the C-stack as their respective types +(i.e. a <tt/char/ parameter will push 1 byte), but if a function has no prototype, default +promotions will apply. This means that with no prototype, <tt/char/ will be promoted +to <tt/int/ and be pushed as 2 bytes. K & R style function prototypes may be used, +but they will function the same as if no prototype was used. <sect1>Prologue, before the function call<p> @@ -57,8 +61,9 @@ All other parameters will be pushed to the C-stack from left to right. The rightmost parameter will have the lowest address on the stack, and multi-byte parameters will have their least significant byte at the lower address. -The <tt/Y/ register will contain the number of bytes pushed to the stack for this function, -and the <tt/sp/ pseudo-register is a zeropage pointer to the base of the C-stack. +The <tt/sp/ pseudo-register is a zeropage pointer to the base of the C-stack. +If the function has no prototype or is variadic +the <tt/Y/ register will contain the number of bytes pushed to the stack for this function. Example: <tscreen><verb> @@ -84,10 +89,6 @@ void foo(unsigned bar, unsigned char baz); lda (sp),y ; Low byte now in A </verb></tscreen> -Variadic functions push all parameters exactly as other <tt/cdecl/ convention functions, -but the value of <tt/Y/ should be used to determine how many bytes of parameters -were placed onto the stack. - <sect1>Epilogue, after the functiona call<p> <sect2>Return requirements</p> @@ -106,10 +107,10 @@ of <tt>A/X/sreg</tt>, so these may be clobbered by the function. The C-stack pointer <tt/sp/ must be restored by the function to its value before the function call prologue. It may pop all of its parameters from the C-stack -(e.g. using the <tt/runtime/ function <tt/popa/.), +(e.g. using the <tt/runtime/ function <tt/popa/), or it could adjust <tt/sp/ directly. -On entry to the function the <tt/Y/ register contains the number of bytes -pushed to the stack, which may be added to <tt/sp/ to restore its original state. +If the function has no prototype, or is variadic the <tt/Y/ register contains the +number of bytes pushed to the stack on entry, which may be added to <tt/sp/ to restore its original state. The internal pseudo-register <tt/regbank/ must not be changed by the function. From 54e09fdd0369fe4388956ca7ed65528af1675bd7 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 25 Nov 2013 22:52:04 +0100 Subject: [PATCH 006/407] Added basic frame for new target 'creativision'. Kym Greenshields <kym.greenshields@gmail.com> has expressed interest in contributing and maintaining support for the VTech CreatiVision system. this resembles commit 8e6b8dd0afed52c1963ea29c4921157693463cbe from oliver --- cfg/creativision.cfg | 35 +++++++++++++ libsrc/Makefile | 1 + libsrc/creativision/crt0.s | 102 +++++++++++++++++++++++++++++++++++++ src/ca65/main.c | 38 +++++++++----- src/cc65/main.c | 38 +++++++++----- src/common/target.c | 16 +++--- src/common/target.h | 15 +++--- 7 files changed, 203 insertions(+), 42 deletions(-) create mode 100644 cfg/creativision.cfg create mode 100644 libsrc/creativision/crt0.s diff --git a/cfg/creativision.cfg b/cfg/creativision.cfg new file mode 100644 index 000000000..9122ccd42 --- /dev/null +++ b/cfg/creativision.cfg @@ -0,0 +1,35 @@ +SYMBOLS { + __STACKSIZE__: type = weak, value = $0180; +} +MEMORY { + ZP: file = "", define = yes, start = $0020, size = $00E0; + RAM: file = "", define = yes, start = $01FA, size = $0206; + ROM: file = %O, define = yes, start = $B000, size = $1000; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + ZP: load = ZP, type = zp, optional = yes; + VECTORS: load = ROM, run = RAM, type = rw, define = yes; + DATA: load = ROM, run = RAM, type = rw, define = yes, start = $0204; + BSS: load = RAM, type = bss, define = yes; + CODE: load = ROM, type = ro; + INIT: load = ROM, type = ro; + RODATA: load = ROM, type = ro; + AUDIO: load = ROM, type = ro, optional = yes, start = $BF00; + SETUP: load = ROM, type = ro, start = $BFE8; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = INIT; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/libsrc/Makefile b/libsrc/Makefile index a4101aecd..364b266c8 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -20,6 +20,7 @@ TARGETS = apple2 \ atarixl \ atari5200 \ atmos \ + creativision \ $(CBMS) \ $(GEOS) \ gamate \ diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s new file mode 100644 index 000000000..ccae38e81 --- /dev/null +++ b/libsrc/creativision/crt0.s @@ -0,0 +1,102 @@ +; +; Startup code for cc65 (CreatiVision version) +; + + .export _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + .import zerobss, copydata + .import initlib, donelib, callmain + .import __VECTORS_LOAD__, __VECTORS_RUN__, __VECTORS_SIZE__ + .import __ZP_LAST__, __STACKSIZE__, __RAM_START__ + + .include "zeropage.inc" + +; ------------------------------------------------------------------------ + +entry: + ; Init the CPU + sei + cld + + ; Copy the IRQ vectors + ldx #<__VECTORS_SIZE__ - 1 +: lda __VECTORS_LOAD__,x + sta __VECTORS_RUN__,x + dex + bpl :- + + ; Setup the CPU stack ptr + ldx #<__RAM_START__ - 1 + txs + + ; Start interrupts + cli + + ; Clear the BSS data + jsr zerobss + + ; Copy data from ROM to RAM + jsr copydata + + ; Setup the argument stack ptr + lda #<(__ZP_LAST__ + __STACKSIZE__) + ldx #>(__ZP_LAST__ + __STACKSIZE__) + sta sp + stx sp+1 + + ; Call module constructors + jsr initlib + + ; Call main() + jsr callmain + + ; Call module destructors. This is also the _exit entry. +_exit: jsr donelib + + ; TODO: Replace with some sort of reset +loop: jmp loop + +; ------------------------------------------------------------------------ +; Define the IRQ vectors. + +.segment "VECTORS" + +irq1: jmp $FF3F +irq2: jmp $FF52 + +; ------------------------------------------------------------------------ +; Define CART setup values for BIOS. + +.segment "SETUP" + + ; BIOS Jump Start + ; This is where the entry point of the program needs to be + .addr entry + .addr irq2 + + .res 4 + + ; VDP Setup + ; This sets to Graphics Mode 1 + .byte $00 ; Register 0 + .byte $C0 ; Register 1 16K RAM, Active Display, Mode 1 + .byte $04 ; Register 2 Name Table at $1000 - $12FF + .byte $60 ; Register 3 Colour Table at $1800 - $181F + .byte $00 ; Register 4 Pattern Table at $0000 - $07FF + .byte $10 ; Register 5 Sprite Attribute at $0800 - $087F + .byte $01 ; Register 6 Sprite Pattern + .byte $F1 ; Register 7 Text colour Foreground / background + + .res 4 + + ; BIOS Vector after NMI or RESET + ; Keeping with retail cartridges, we jump back to BIOS ROM and have it + ; setup zeropage etc, and show the Creativision logo and copyright. + .addr $F808 + + ; BIOS Short Interrupt Handler + ; Vectored from BIOS ROM:FE2C. This should contain a pointer to the user's + ; BIOS interrupt handler. + .addr irq1 + +; ------------------------------------------------------------------------ diff --git a/src/ca65/main.c b/src/ca65/main.c index 0016c46f3..b25d5ad9f 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -251,10 +251,6 @@ static void SetSys (const char* Sys) CBMSystem ("__PET__"); break; - case TGT_BBC: - NewSymbol ("__BBC__", 1); - break; - case TGT_APPLE2: NewSymbol ("__APPLE2__", 1); break; @@ -274,31 +270,41 @@ static void SetSys (const char* Sys) NewSymbol ("__GEOS_CBM__", 1); break; + case TGT_ATMOS: + NewSymbol ("__ATMOS__", 1); + break; + + case TGT_BBC: + NewSymbol ("__BBC__", 1); + break; + + case TGT_CREATIVISION: + NewSymbol ("__CREATIVISION__", 1); + break; + case TGT_GEOS_APPLE: NewSymbol ("__GEOS__", 1); NewSymbol ("__GEOS_APPLE__", 1); break; + case TGT_GEOS_CBM: + /* Do not handle as a CBM system */ + NewSymbol ("__GEOS__", 1); + NewSymbol ("__GEOS_CBM__", 1); + break; + case TGT_LUNIX: NewSymbol ("__LUNIX__", 1); break; - case TGT_ATMOS: - NewSymbol ("__ATMOS__", 1); + case TGT_LYNX: + NewSymbol ("__LYNX__", 1); break; case TGT_NES: NewSymbol ("__NES__", 1); break; - case TGT_SUPERVISION: - NewSymbol ("__SUPERVISION__", 1); - break; - - case TGT_LYNX: - NewSymbol ("__LYNX__", 1); - break; - case TGT_SIM6502: NewSymbol ("__SIM6502__", 1); break; @@ -315,6 +321,10 @@ static void SetSys (const char* Sys) NewSymbol ("__PCE__", 1); break; + case TGT_SUPERVISION: + NewSymbol ("__SUPERVISION__", 1); + break; + default: AbEnd ("Invalid target name: `%s'", Sys); diff --git a/src/cc65/main.c b/src/cc65/main.c index abe2af56e..c4a5c3788 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -207,10 +207,6 @@ static void SetSys (const char* Sys) cbmsys ("__PET__"); break; - case TGT_BBC: - DefineNumericMacro ("__BBC__", 1); - break; - case TGT_APPLE2: DefineNumericMacro ("__APPLE2__", 1); break; @@ -230,31 +226,41 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__GEOS_CBM__", 1); break; + case TGT_ATMOS: + DefineNumericMacro ("__ATMOS__", 1); + break; + + case TGT_BBC: + DefineNumericMacro ("__BBC__", 1); + break; + + case TGT_CREATIVISION: + DefineNumericMacro ("__CREATIVISION__", 1); + break; + case TGT_GEOS_APPLE: DefineNumericMacro ("__GEOS__", 1); DefineNumericMacro ("__GEOS_APPLE__", 1); break; + case TGT_GEOS_CBM: + /* Do not handle as a CBM system */ + DefineNumericMacro ("__GEOS__", 1); + DefineNumericMacro ("__GEOS_CBM__", 1); + break; + case TGT_LUNIX: DefineNumericMacro ("__LUNIX__", 1); break; - case TGT_ATMOS: - DefineNumericMacro ("__ATMOS__", 1); + case TGT_LYNX: + DefineNumericMacro ("__LYNX__", 1); break; case TGT_NES: DefineNumericMacro ("__NES__", 1); break; - case TGT_SUPERVISION: - DefineNumericMacro ("__SUPERVISION__", 1); - break; - - case TGT_LYNX: - DefineNumericMacro ("__LYNX__", 1); - break; - case TGT_SIM6502: DefineNumericMacro ("__SIM6502__", 1); break; @@ -271,6 +277,10 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__PCE__", 1); break; + case TGT_SUPERVISION: + DefineNumericMacro ("__SUPERVISION__", 1); + break; + default: AbEnd ("Unknown target system type %d", Target); } diff --git a/src/common/target.c b/src/common/target.c index e89010123..cc5d41206 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -134,7 +134,7 @@ static const unsigned char CTPET[256] = { /* One entry in the target map */ typedef struct TargetEntry TargetEntry; struct TargetEntry { - char Name[12]; /* Target name */ + char Name[13]; /* Target name */ target_t Id; /* Target id */ }; @@ -154,6 +154,7 @@ static const TargetEntry TargetMap[] = { { "c64", TGT_C64 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, + { "creativision", TGT_CREATIVISION}, { "gamate", TGT_GAMATE }, { "geos", TGT_GEOS_CBM }, { "geos-apple", TGT_GEOS_APPLE }, @@ -192,20 +193,21 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "cbm610", CPU_6502, BINFMT_BINARY, CTPET }, { "osic1p", CPU_6502, BINFMT_BINARY, CTOSI }, { "pet", CPU_6502, BINFMT_BINARY, CTPET }, - { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2enh", CPU_65C02, BINFMT_BINARY, CTNone }, - { "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone }, - { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, - { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, - { "nes", CPU_6502, BINFMT_BINARY, CTNone }, - { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, + { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, + { "creativision", CPU_6502, BINFMT_BINARY, CTNone }, + { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, + { "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone }, + { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "lynx", CPU_65C02, BINFMT_BINARY, CTNone }, + { "nes", CPU_6502, BINFMT_BINARY, CTNone }, { "sim6502", CPU_6502, BINFMT_BINARY, CTNone }, { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, + { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 6366b725f..c266a4408 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -66,27 +66,28 @@ typedef enum { TGT_CBM610, TGT_OSIC1P, TGT_PET, - TGT_BBC, TGT_APPLE2, TGT_APPLE2ENH, - TGT_GEOS_CBM, - TGT_GEOS_APPLE, - TGT_LUNIX, TGT_ATMOS, - TGT_NES, - TGT_SUPERVISION, + TGT_BBC, + TGT_CREATIVISION, + TGT_GEOS_APPLE, + TGT_GEOS_CBM, + TGT_LUNIX, TGT_LYNX, + TGT_NES, TGT_SIM6502, TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, + TGT_SUPERVISION, TGT_COUNT /* Number of target systems */ } target_t; /* Collection of target properties */ typedef struct TargetProperties TargetProperties; struct TargetProperties { - const char Name[12]; /* Name of the target */ + const char Name[13]; /* Name of the target */ cpu_t DefaultCPU; /* Default CPU for this target */ unsigned char BinFmt; /* Default binary format for this target */ const unsigned char* CharMap; /* Character translation table */ From 0dc85268c4c4c4651899b6211984b07f8b25723c Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 28 Feb 2016 19:11:04 +0100 Subject: [PATCH 007/407] fix merge fxxxup --- src/ca65/main.c | 6 ------ src/cc65/main.c | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index b25d5ad9f..49e7a1fb5 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -287,12 +287,6 @@ static void SetSys (const char* Sys) NewSymbol ("__GEOS_APPLE__", 1); break; - case TGT_GEOS_CBM: - /* Do not handle as a CBM system */ - NewSymbol ("__GEOS__", 1); - NewSymbol ("__GEOS_CBM__", 1); - break; - case TGT_LUNIX: NewSymbol ("__LUNIX__", 1); break; diff --git a/src/cc65/main.c b/src/cc65/main.c index c4a5c3788..d8b312fab 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -243,12 +243,6 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__GEOS_APPLE__", 1); break; - case TGT_GEOS_CBM: - /* Do not handle as a CBM system */ - DefineNumericMacro ("__GEOS__", 1); - DefineNumericMacro ("__GEOS_CBM__", 1); - break; - case TGT_LUNIX: DefineNumericMacro ("__LUNIX__", 1); break; From 3d08abcfa802bb9862ed01427b37256bd7210663 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 28 Feb 2016 19:29:37 +0100 Subject: [PATCH 008/407] Load INITBSS segment from disk. Conceptually the INITBSS segment is not initialized in any way. Therefore it makes sense to not load it from disk. However the INIT segment has to be loaded from disk and therefore moved to its run location above the INITBSS segment. The necessary move routine increases runtime RAM usage :-( Therefore we now "unnecessarily" load the INITBSS segment from disk too meaning that the INIT segment is loaded at its run location. Therefore there's no need for the move routine anymore. After all we trade disk space for (runtime) RAM space - an easy decision ;-) Notes: - The code allowing to re-run a program without re-load present so far could not have worked as far as I can see as it only avoided to re-run the move routine but still tried to re-run the code in the INIT segment that was clobbered by zeroing the BSS. Therefore I removed the code in question altogether. I'm personally not into this "dirty re-run" but if someone wants to add an actually working solution I won't block that. - INITBSS is intentionally not just merged with the DATA segment as ROM-based targets can't reuse the INIT segment for the BSS and therefore have no reason to place the INIT segment above INITBSS. - Because ROM-based targets don't copy INITBSS from the ROM (like it is done with the DATA segment) all users of INITBSS _MUST_NOT_ presume INITBSS to be initialized with zeros! --- cfg/c64-overlay.cfg | 61 ++++++++++++++++++++-------------------- cfg/c64.cfg | 25 ++++++++-------- libsrc/c64/crt0.s | 39 ++++++------------------- libsrc/common/moveinit.s | 45 ----------------------------- 4 files changed, 51 insertions(+), 119 deletions(-) delete mode 100644 libsrc/common/moveinit.s diff --git a/cfg/c64-overlay.cfg b/cfg/c64-overlay.cfg index 1c3b19c09..522a6d1a6 100644 --- a/cfg/c64-overlay.cfg +++ b/cfg/c64-overlay.cfg @@ -15,8 +15,7 @@ MEMORY { LOADADDR: file = %O, start = %S - 2, size = $0002; HEADER: file = %O, define = yes, start = %S, size = $000D; MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __OVERLAYSTART__ - __STACKSIZE__ - __HEADER_LAST__; - MOVE: file = %O, start = __INITBSS_LOAD__, size = __HIMEM__ - __BSS_RUN__; - INIT: file = "", start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__; + INIT: file = %O, start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__; OVL1ADDR: file = "%O.1", start = __OVERLAYSTART__ - 2, size = $0002; OVL1: file = "%O.1", start = __OVERLAYSTART__, size = __OVERLAYSIZE__; OVL2ADDR: file = "%O.2", start = __OVERLAYSTART__ - 2, size = $0002; @@ -37,35 +36,35 @@ MEMORY { OVL9: file = "%O.9", start = __OVERLAYSTART__, size = __OVERLAYSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - LOADADDR: load = LOADADDR, type = ro; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INITBSS: load = MAIN, type = bss, define = yes; - BSS: load = MAIN, type = bss, define = yes; - INIT: load = MOVE, run = INIT, type = ro, define = yes; - OVL1ADDR: load = OVL1ADDR, type = ro; - OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; - OVL2ADDR: load = OVL2ADDR, type = ro; - OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; - OVL3ADDR: load = OVL3ADDR, type = ro; - OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; - OVL4ADDR: load = OVL4ADDR, type = ro; - OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; - OVL5ADDR: load = OVL5ADDR, type = ro; - OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; - OVL6ADDR: load = OVL6ADDR, type = ro; - OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; - OVL7ADDR: load = OVL7ADDR, type = ro; - OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; - OVL8ADDR: load = OVL8ADDR, type = ro; - OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; - OVL9ADDR: load = OVL9ADDR, type = ro; - OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; + ZEROPAGE: load = ZP, type = zp; + LOADADDR: load = LOADADDR, type = ro; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INITBSS: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes; + INIT: load = INIT, type = ro; + OVL1ADDR: load = OVL1ADDR, type = ro; + OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; + OVL2ADDR: load = OVL2ADDR, type = ro; + OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; + OVL3ADDR: load = OVL3ADDR, type = ro; + OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; + OVL4ADDR: load = OVL4ADDR, type = ro; + OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; + OVL5ADDR: load = OVL5ADDR, type = ro; + OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; + OVL6ADDR: load = OVL6ADDR, type = ro; + OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; + OVL7ADDR: load = OVL7ADDR, type = ro; + OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; + OVL8ADDR: load = OVL8ADDR, type = ro; + OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; + OVL9ADDR: load = OVL9ADDR, type = ro; + OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/c64.cfg b/cfg/c64.cfg index 2a105c7f1..8ff7db03c 100644 --- a/cfg/c64.cfg +++ b/cfg/c64.cfg @@ -12,21 +12,20 @@ MEMORY { LOADADDR: file = %O, start = %S - 2, size = $0002; HEADER: file = %O, define = yes, start = %S, size = $000D; MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __STACKSIZE__ - __HEADER_LAST__; - MOVE: file = %O, start = __INITBSS_LOAD__, size = __HIMEM__ - __BSS_RUN__; - INIT: file = "", start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__; + INIT: file = %O, start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - LOADADDR: load = LOADADDR, type = ro; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INITBSS: load = MAIN, type = bss, define = yes; - BSS: load = MAIN, type = bss, define = yes; - INIT: load = MOVE, run = INIT, type = ro, define = yes; + ZEROPAGE: load = ZP, type = zp; + LOADADDR: load = LOADADDR, type = ro; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INITBSS: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes; + INIT: load = INIT, type = ro, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index 78268422b..ea7867925 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -6,7 +6,7 @@ .export __STARTUP__ : absolute = 1 ; Mark as startup .import initlib, donelib - .import moveinit, zerobss, callmain + .import zerobss, callmain .import BSOUT .import __MAIN_START__, __MAIN_SIZE__ ; Linker generated .import __STACKSIZE__ ; from configure file @@ -23,11 +23,6 @@ Start: -; Switch to the second charset. - - lda #14 - jsr BSOUT - ; Switch off the BASIC ROM. lda $01 @@ -39,22 +34,10 @@ Start: tsx stx spsave ; Save the system stack ptr -; Allow some re-entrancy by skipping the next task if it already was done. -; This sometimes can let us rerun the program without reloading it. - - ldx move_init - beq L0 - -; Move the INIT segment from where it was loaded (over the bss segments) -; into where it must be run (over the BSS segment). - - jsr moveinit - dec move_init ; Set to false - ; Save space by putting some of the start-up code in the INIT segment, ; which can be re-used by the BSS segment, the heap and the C stack. -L0: jsr runinit + jsr init ; Clear the BSS data. @@ -98,7 +81,7 @@ L2: lda zpsave,x .segment "INIT" -runinit: +init: ; Save the zero-page locations that we need. @@ -115,6 +98,11 @@ L1: lda sp,x sta sp stx sp+1 ; Set argument stack ptr +; Switch to the second charset. + + lda #14 + jsr BSOUT + ; Call the module constructors. jmp initlib @@ -123,17 +111,8 @@ L1: lda sp,x ; ------------------------------------------------------------------------ ; Data -.data - -; These two variables were moved out of the BSS segment, and into DATA, because -; we need to use them before INIT is moved off of BSS, and before BSS is zeroed. +.segment "INITBSS" mmusave:.res 1 spsave: .res 1 - -move_init: - .byte 1 - -.segment "INITBSS" - zpsave: .res zpspace diff --git a/libsrc/common/moveinit.s b/libsrc/common/moveinit.s deleted file mode 100644 index 2b22be02d..000000000 --- a/libsrc/common/moveinit.s +++ /dev/null @@ -1,45 +0,0 @@ -; -; 2015-10-07, Greg King -; - - .export moveinit - - .import __INIT_LOAD__, __INIT_RUN__, __INIT_SIZE__ ; Linker-generated - - .macpack cpu - .macpack generic - - -; Put this in the DATA segment because it is self-modifying code. - -.data - -; Move the INIT segment from where it was loaded (over the bss segments) -; into where it must be run (over the BSS segment). The two areas might overlap; -; and, the segment is moved upwards. Therefore, this code starts at the highest -; address, and decrements to the lowest address. The low bytes of the starting -; pointers are not sums. The high bytes are sums; but, they do not include the -; carry. Both the low-byte sums and the carries will be done when the pointers -; are indexed by the .Y register. - -moveinit: - -; First, move the last, partial page. -; Then, move all of the full pages. - - ldy #<__INIT_SIZE__ ; size of partial page - ldx #>__INIT_SIZE__ + (<__INIT_SIZE__ <> 0) ; number of pages, including partial - -L1: dey -init_load: - lda __INIT_LOAD__ + (__INIT_SIZE__ & $FF00) - $0100 * (<__INIT_SIZE__ = 0),y -init_run: - sta __INIT_RUN__ + (__INIT_SIZE__ & $FF00) - $0100 * (<__INIT_SIZE__ = 0),y - tya - bnz L1 ; page not finished - - dec init_load+2 - dec init_run+2 - dex - bnz L1 ; move next page - rts From f328532030db1f4e2d97ebde6607dee99e6cde0b Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 28 Feb 2016 20:12:28 +0100 Subject: [PATCH 009/407] updated docs with recently added extended memory drivers --- doc/c128.sgml | 8 ++++++++ doc/c64.sgml | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/doc/c128.sgml b/doc/c128.sgml index 4154c0a8d..2468b17e6 100644 --- a/doc/c128.sgml +++ b/doc/c128.sgml @@ -191,11 +191,19 @@ missing on VDC, and are translated to the two colors missing from the VIC palett <descrip> + <tag><tt/c128-efnram.emd (c128_georam_emd)/</tag> + Extended memory driver for the C128 External Function RAM. + Written and contributed by Marco van den Heuvel. + <tag><tt/c128-georam.emd (c128_georam_emd)/</tag> A driver for the GeoRam cartridge. The driver will always assume 2048 pages of 256 bytes each. There are no checks, so if your program knows better, just go ahead. + <tag><tt/c128-ifnram.emd (c128_georam_emd)/</tag> + Extended memory driver for the C128 Internal Function RAM. + Written and contributed by Marco van den Heuvel. + <tag><tt/c128-ram.emd (c128_ram_emd)/</tag> An extended memory driver for the RAM in page 1. The common memory area is excluded, so this driver supports 251 pages of 256 bytes each. diff --git a/doc/c64.sgml b/doc/c64.sgml index 8767d212d..4bf43453d 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -257,6 +257,10 @@ Note that the graphics drivers are incompatible with the <descrip> + <tag><tt/c64-65816.emd (c64_65816_emd)/</tag> + Extended memory driver for 65816 (eg SCPU) based extra RAM. + Written and contributed by Marco van den Heuvel. + <tag><tt/c64-c256k.emd (c64_c256k_emd)/</tag> A driver for the C64 256K memory expansion. This driver offers 768 pages of 256 bytes each. Written and contributed by Marco van den Heuvel. From 7d2969d5acf703b07a7c5e779d298d496d8192b9 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 28 Feb 2016 21:39:49 +0100 Subject: [PATCH 010/407] fixed copypaste errors --- doc/c128.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/c128.sgml b/doc/c128.sgml index 2468b17e6..a98b04f49 100644 --- a/doc/c128.sgml +++ b/doc/c128.sgml @@ -191,7 +191,7 @@ missing on VDC, and are translated to the two colors missing from the VIC palett <descrip> - <tag><tt/c128-efnram.emd (c128_georam_emd)/</tag> + <tag><tt/c128-efnram.emd (c128_efnram_emd)/</tag> Extended memory driver for the C128 External Function RAM. Written and contributed by Marco van den Heuvel. @@ -200,7 +200,7 @@ missing on VDC, and are translated to the two colors missing from the VIC palett of 256 bytes each. There are no checks, so if your program knows better, just go ahead. - <tag><tt/c128-ifnram.emd (c128_georam_emd)/</tag> + <tag><tt/c128-ifnram.emd (c128_ifnram_emd)/</tag> Extended memory driver for the C128 Internal Function RAM. Written and contributed by Marco van den Heuvel. From eb96a90e5fe642102b5b81dc1e031641ed362c29 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 28 Feb 2016 22:35:46 +0100 Subject: [PATCH 011/407] initial import from old sources --- libsrc/c128/waitvblank.s | 20 ++++++++++++++++++++ libsrc/c64/waitvblank.s | 20 ++++++++++++++++++++ libsrc/cbm510/waitvblank.s | 37 +++++++++++++++++++++++++++++++++++++ libsrc/vic20/waitvblank.s | 16 ++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 libsrc/c128/waitvblank.s create mode 100644 libsrc/c64/waitvblank.s create mode 100644 libsrc/cbm510/waitvblank.s create mode 100644 libsrc/vic20/waitvblank.s diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvblank.s new file mode 100644 index 000000000..a3904d858 --- /dev/null +++ b/libsrc/c128/waitvblank.s @@ -0,0 +1,20 @@ + + .export _waitvblank + + .include "c128/c128.inc" + +_waitvblank: + lda PALFLAG + beq @ntsc + ldx #(312-24)-256 + .byte $2c +@ntsc: + ldx #(262-4)-256 +@l1: + lda VIC_CTRL1 + and #$80 + beq @l1 +@l2: + cpx VIC_HLINE + bcs @l2 + rts diff --git a/libsrc/c64/waitvblank.s b/libsrc/c64/waitvblank.s new file mode 100644 index 000000000..09570f873 --- /dev/null +++ b/libsrc/c64/waitvblank.s @@ -0,0 +1,20 @@ + + .export _waitvblank + + .include "c64/c64.inc" + +_waitvblank: + lda PALFLAG + beq @ntsc + ldx #(312-24)-256 + .byte $2c +@ntsc: + ldx #(262-4)-256 +@l1: + lda VIC_CTRL1 + and #$80 + beq @l1 +@l2: + cpx VIC_HLINE + bcs @l2 + rts diff --git a/libsrc/cbm510/waitvblank.s b/libsrc/cbm510/waitvblank.s new file mode 100644 index 000000000..30cbf072f --- /dev/null +++ b/libsrc/cbm510/waitvblank.s @@ -0,0 +1,37 @@ + + .export _waitvblank + .import PALFLAG + .import sys_bank, restore_bank + + .importzp vic + + .include "cbm510/cbm510.inc" + +_waitvblank: + rts ; FIXME + + jsr sys_bank ; Switch to the system bank + + lda PALFLAG + beq ntsc + ldx #(312-24)-256 + .byte $2c +ntsc: + ldx #(262-2)-256 + + sei + ldy #VIC_CTRL1 +l1: + lda (vic),y + and #$80 + beq l1 + +;?!? +; ldy #VIC_HLINE +; txa +;l2: +; cmp (vic),y +; bcs l2 + + cli + jmp restore_bank diff --git a/libsrc/vic20/waitvblank.s b/libsrc/vic20/waitvblank.s new file mode 100644 index 000000000..b99c74bed --- /dev/null +++ b/libsrc/vic20/waitvblank.s @@ -0,0 +1,16 @@ + .export _waitvblank + + .include "vic20/vic20.inc" + +_waitvblank: + lda PALFLAG + beq @ntsc + ldx #(312-8)/2 + .byte $2c +@ntsc: + ldx #(262-8)/2 +@l2: + cpx VIC_HLINE + bcs @l2 + rts + From 18dec35312ebdd5dc120abeff039d032e316e256 Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Wed, 2 Mar 2016 01:58:44 -0500 Subject: [PATCH 012/407] cc65-intern sgml fixes --- doc/cc65-intern.sgml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/cc65-intern.sgml b/doc/cc65-intern.sgml index 0bcb51cba..bfbe4d78e 100644 --- a/doc/cc65-intern.sgml +++ b/doc/cc65-intern.sgml @@ -89,9 +89,9 @@ void foo(unsigned bar, unsigned char baz); lda (sp),y ; Low byte now in A </verb></tscreen> -<sect1>Epilogue, after the functiona call<p> +<sect1>Epilogue, after the function call<p> -<sect2>Return requirements</p> +<sect2>Return requirements<p> If the function has a return value, it will appear in the <tt>A/X/sreg</tt> registers. @@ -114,7 +114,7 @@ number of bytes pushed to the stack on entry, which may be added to <tt/sp/ to r The internal pseudo-register <tt/regbank/ must not be changed by the function. -<sect2>Clobbered state</p> +<sect2>Clobbered state<p> The <tt/Y/ register may be clobbered by the function. The compiler will not depend on its state after a function call. @@ -126,6 +126,7 @@ Many of the internal pseudo-registers used by cc65 are available for free use by any function called by C, and do not need to be preserved. Note that if another C function is called from your assembly function, it may clobber any of these itself: + <itemize> <item><tt>tmp1 .. tmp4</tt><p> <item><tt>ptr1 .. ptr4</tt><p> From 85a58453cb881d92ea51aa927981eae1c4137c9d Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Wed, 2 Mar 2016 02:03:23 -0500 Subject: [PATCH 013/407] cc65-intern adjusting mailing address --- doc/cc65-intern.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cc65-intern.sgml b/doc/cc65-intern.sgml index bfbe4d78e..faa2d5609 100644 --- a/doc/cc65-intern.sgml +++ b/doc/cc65-intern.sgml @@ -2,7 +2,7 @@ <article> <title>cc65 internals -<author><url url="mailto:brad@rainwarrior.ca" name="Brad Smith"> +<author><url url="mailto:bbbradsmith@users.noreply.github.com" name="Brad Smith"> <date>2016-02-27 <abstract> From 97e6a8c5698cad2a62f09b2664ea74e58830b604 Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Wed, 2 Mar 2016 21:01:46 -0500 Subject: [PATCH 014/407] cc65-intern update minor change notes from greg-king5 --- doc/cc65-intern.sgml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/cc65-intern.sgml b/doc/cc65-intern.sgml index faa2d5609..231c04544 100644 --- a/doc/cc65-intern.sgml +++ b/doc/cc65-intern.sgml @@ -27,7 +27,7 @@ There are two calling conventions used in cc65: <item><tt/cdecl/ - passes all parameters on the C-stack. <p> <item><tt/fastcall/ - passes the rightmost parameter in - registers <tt>A/X/sreg</tt> an all others on the C-stack. + registers <tt>A/X/sreg</tt> and all others on the C-stack. <p> </itemize> @@ -52,7 +52,7 @@ If the function is declared as fastcall, the rightmost argument will be loaded i the <tt>A/X/sreg</tt> registers: <itemize> - <item><tt/A/ - 8-bit parameter, or low byte of larger tyes<p> + <item><tt/A/ - 8-bit parameter, or low byte of larger types<p> <item><tt/X/ - 16-bit high byte, or second byte of 32-bits<p> <item><tt/sreg/ - Zeropage pseudo-register including high 2 bytes of 32-bit parameter<p> </itemize> @@ -68,7 +68,7 @@ the <tt/Y/ register will contain the number of bytes pushed to the stack for thi Example: <tscreen><verb> // C prototype -void foo(unsigned bar, unsigned char baz); +void cdecl foo(unsigned bar, unsigned char baz); ; C-stack layout within the function: ; From 419eb700b5cd730ecf425ed8a597e9cf41ad7208 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 6 Mar 2016 21:26:22 +0100 Subject: [PATCH 015/407] Renamed INITBSS to INIT and INIT to ONCE. The way we want to use the INITBSS segment - and especially the fact that it won't have the type bss on all ROM based targets - means that the name INITBSS is misleading. After all INIT is the best name from my perspective as it serves several purposes and therefore needs a rather generic name. Unfortunately this means that the current INIT segment needs to be renamed too. Looking for a short (ideally 4 letter) name I came up with ONCE as it contains all code (and data) accessed only once during initialization. --- cfg/apple2-overlay.cfg | 8 ++-- cfg/apple2-system.cfg | 8 ++-- cfg/apple2.cfg | 8 ++-- cfg/apple2enh-overlay.cfg | 8 ++-- cfg/apple2enh-system.cfg | 8 ++-- cfg/apple2enh.cfg | 8 ++-- cfg/atari-cart.cfg | 24 +++++------ cfg/atari-cassette.cfg | 24 +++++------ cfg/atari-overlay.cfg | 10 ++--- cfg/atari.cfg | 10 ++--- cfg/atari5200.cfg | 8 ++-- cfg/atarixl-largehimem.cfg | 11 ++--- cfg/atarixl-overlay.cfg | 11 ++--- cfg/atarixl.cfg | 11 ++--- cfg/atmos.cfg | 4 +- cfg/bbc.cfg | 6 +-- cfg/c128-overlay.cfg | 8 ++-- cfg/c128.cfg | 8 ++-- cfg/c16.cfg | 8 ++-- cfg/c64-overlay.cfg | 6 +-- cfg/c64.cfg | 6 +-- cfg/cbm510.cfg | 6 +-- cfg/cbm610.cfg | 6 +-- cfg/gamate.cfg | 64 ++++++++++++++++------------ cfg/geos-apple.cfg | 4 +- cfg/geos-cbm.cfg | 4 +- cfg/lunix.cfg | 4 +- cfg/lynx-bll.cfg | 10 ++--- cfg/lynx-coll.cfg | 10 ++--- cfg/lynx-uploader.cfg | 10 ++--- cfg/lynx.cfg | 10 ++--- cfg/module.cfg | 2 +- cfg/nes.cfg | 6 +-- cfg/none.cfg | 6 +-- cfg/osic1p-asm.cfg | 4 +- cfg/osic1p.cfg | 8 ++-- cfg/pce.cfg | 38 ++++++++--------- cfg/pet.cfg | 8 ++-- cfg/plus4.cfg | 8 ++-- cfg/sim6502.cfg | 26 +++++------ cfg/sim65c02.cfg | 26 +++++------ cfg/supervision-128k.cfg | 2 +- cfg/supervision-16k.cfg | 6 +-- cfg/supervision-64k.cfg | 2 +- cfg/supervision.cfg | 6 +-- cfg/vic20-32k.cfg | 6 +-- cfg/vic20.cfg | 8 ++-- doc/atari.sgml | 14 +++--- doc/customizing.sgml | 20 ++++----- doc/ld65.sgml | 6 +-- libsrc/apple2/cputc.s | 2 +- libsrc/apple2/crt0.s | 30 ++++++------- libsrc/apple2/dosdetect.s | 2 +- libsrc/apple2/extra/iobuf-0800.s | 2 +- libsrc/apple2/get_ostype.s | 2 +- libsrc/apple2/irq.s | 2 +- libsrc/apple2/mainargs.s | 4 +- libsrc/apple2/open.s | 2 +- libsrc/apple2/read.s | 2 +- libsrc/apple2/reboot.s | 2 +- libsrc/atari/casinit.s | 2 +- libsrc/atari/dosdetect.s | 2 +- libsrc/atari/getargs.s | 2 +- libsrc/atari/irq.s | 2 +- libsrc/atari/mcbpm.s | 2 +- libsrc/atari/shadow_ram_handlers.s | 2 +- libsrc/atari5200/conioscreen.s | 2 +- libsrc/atari5200/irq.s | 2 +- libsrc/atmos/capslock.s | 2 +- libsrc/atmos/cgetc.s | 4 +- libsrc/atmos/irq.s | 2 +- libsrc/atmos/mainargs.s | 4 +- libsrc/atmos/read.s | 2 +- libsrc/c128/cgetc.s | 2 +- libsrc/c128/crt0.s | 2 +- libsrc/c128/irq.s | 2 +- libsrc/c128/mainargs.s | 6 +-- libsrc/c128/mcbdefault.s | 2 +- libsrc/c128/systime.s | 2 +- libsrc/c16/cgetc.s | 2 +- libsrc/c16/crt0.s | 2 +- libsrc/c16/irq.s | 2 +- libsrc/c16/mainargs.s | 6 +-- libsrc/c64/crt0.s | 6 +-- libsrc/c64/irq.s | 2 +- libsrc/c64/mainargs.s | 6 +-- libsrc/c64/mcbdefault.s | 2 +- libsrc/c64/soft80_charset.s | 2 +- libsrc/c64/soft80_conio.s | 4 +- libsrc/c64/soft80mono_conio.s | 4 +- libsrc/c64/systime.s | 2 +- libsrc/cbm/filevars.s | 4 +- libsrc/cbm/mcbpointercolor.s | 2 +- libsrc/cbm/mcbpointershape.s | 2 +- libsrc/cbm/read.s | 2 +- libsrc/cbm/write.s | 2 +- libsrc/cbm510/mainargs.s | 6 +-- libsrc/cbm510/mcbdefault.s | 2 +- libsrc/cbm610/mainargs.s | 6 +-- libsrc/common/_cwd.s | 2 +- libsrc/common/_heap.s | 2 +- libsrc/gamate/clock.s | 2 +- libsrc/gamate/conio.s | 2 +- libsrc/gamate/irq.s | 2 +- libsrc/gamate/nmi.s | 2 +- libsrc/geos-common/conio/_scrsize.s | 2 +- libsrc/geos-common/system/mainargs.s | 2 +- libsrc/lynx/clock.s | 2 +- libsrc/lynx/defdir.s | 13 +++--- libsrc/lynx/irq.s | 2 +- libsrc/lynx/mainargs.s | 4 +- libsrc/nes/cputc.s | 4 +- libsrc/nes/irq.s | 2 +- libsrc/nes/mainargs.s | 4 +- libsrc/osic1p/cgetc.s | 2 +- libsrc/pce/clock.s | 2 +- libsrc/pce/conio.s | 2 +- libsrc/pce/irq.s | 2 +- libsrc/pce/psg.s | 2 +- libsrc/pce/vce.s | 2 +- libsrc/pet/crt0.s | 2 +- libsrc/pet/irq.s | 2 +- libsrc/pet/mainargs.s | 6 +-- libsrc/plus4/cgetc.s | 2 +- libsrc/plus4/crt0.s | 2 +- libsrc/plus4/mainargs.s | 6 +-- libsrc/runtime/condes.s | 2 +- libsrc/runtime/stkchk.s | 4 +- libsrc/sim6502/mainargs.s | 2 +- libsrc/vic20/crt0.s | 2 +- libsrc/vic20/irq.s | 2 +- libsrc/vic20/mainargs.s | 6 +-- 132 files changed, 402 insertions(+), 390 deletions(-) diff --git a/cfg/apple2-overlay.cfg b/cfg/apple2-overlay.cfg index 244e4582f..ef9103b49 100644 --- a/cfg/apple2-overlay.cfg +++ b/cfg/apple2-overlay.cfg @@ -18,7 +18,7 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ + + __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + __MOVE_LAST__ - __MOVE_START__; } MEMORY { @@ -45,9 +45,9 @@ SEGMENTS { CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, define = yes; + INIT: load = RAM, type = bss, define = yes; BSS: load = RAM, type = bss, define = yes; - INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; + ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; LC: load = MOVE, run = LC, type = ro, optional = yes; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; @@ -63,7 +63,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/apple2-system.cfg b/cfg/apple2-system.cfg index f07208e45..52cad960f 100644 --- a/cfg/apple2-system.cfg +++ b/cfg/apple2-system.cfg @@ -5,7 +5,7 @@ SYMBOLS { __LCSIZE__: type = weak, value = $0C00; # Rest of bank two __STACKSIZE__: type = weak, value = $0800; # 2k stack __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ + + __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + __MOVE_LAST__ - __MOVE_START__; } MEMORY { @@ -21,16 +21,16 @@ SEGMENTS { CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, define = yes; + INIT: load = RAM, type = bss, define = yes; BSS: load = RAM, type = bss, define = yes; - INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; + ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; LC: load = MOVE, run = LC, type = ro, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/apple2.cfg b/cfg/apple2.cfg index 27eb706c4..8e63090f5 100644 --- a/cfg/apple2.cfg +++ b/cfg/apple2.cfg @@ -10,7 +10,7 @@ SYMBOLS { __LCSIZE__: type = weak, value = $0C00; # Rest of bank two __STACKSIZE__: type = weak, value = $0800; # 2k stack __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ + + __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + __MOVE_LAST__ - __MOVE_START__; } MEMORY { @@ -28,16 +28,16 @@ SEGMENTS { CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, define = yes; + INIT: load = RAM, type = bss, define = yes; BSS: load = RAM, type = bss, define = yes; - INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; + ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; LC: load = MOVE, run = LC, type = ro, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/apple2enh-overlay.cfg b/cfg/apple2enh-overlay.cfg index 244e4582f..ef9103b49 100644 --- a/cfg/apple2enh-overlay.cfg +++ b/cfg/apple2enh-overlay.cfg @@ -18,7 +18,7 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ + + __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + __MOVE_LAST__ - __MOVE_START__; } MEMORY { @@ -45,9 +45,9 @@ SEGMENTS { CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, define = yes; + INIT: load = RAM, type = bss, define = yes; BSS: load = RAM, type = bss, define = yes; - INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; + ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; LC: load = MOVE, run = LC, type = ro, optional = yes; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; @@ -63,7 +63,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/apple2enh-system.cfg b/cfg/apple2enh-system.cfg index f07208e45..52cad960f 100644 --- a/cfg/apple2enh-system.cfg +++ b/cfg/apple2enh-system.cfg @@ -5,7 +5,7 @@ SYMBOLS { __LCSIZE__: type = weak, value = $0C00; # Rest of bank two __STACKSIZE__: type = weak, value = $0800; # 2k stack __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ + + __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + __MOVE_LAST__ - __MOVE_START__; } MEMORY { @@ -21,16 +21,16 @@ SEGMENTS { CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, define = yes; + INIT: load = RAM, type = bss, define = yes; BSS: load = RAM, type = bss, define = yes; - INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; + ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; LC: load = MOVE, run = LC, type = ro, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/apple2enh.cfg b/cfg/apple2enh.cfg index 27eb706c4..8e63090f5 100644 --- a/cfg/apple2enh.cfg +++ b/cfg/apple2enh.cfg @@ -10,7 +10,7 @@ SYMBOLS { __LCSIZE__: type = weak, value = $0C00; # Rest of bank two __STACKSIZE__: type = weak, value = $0800; # 2k stack __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ + + __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + __MOVE_LAST__ - __MOVE_START__; } MEMORY { @@ -28,16 +28,16 @@ SEGMENTS { CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, define = yes; + INIT: load = RAM, type = bss, define = yes; BSS: load = RAM, type = bss, define = yes; - INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; + ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; LC: load = MOVE, run = LC, type = ro, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/atari-cart.cfg b/cfg/atari-cart.cfg index 58457c606..09bf86761 100644 --- a/cfg/atari-cart.cfg +++ b/cfg/atari-cart.cfg @@ -16,23 +16,23 @@ MEMORY { CARTID: file = %O, start = $BFFA, size = $0006; } SEGMENTS { - STARTUP: load = ROM, type = ro, define = yes, optional = yes; - LOWCODE: load = ROM, type = ro, define = yes, optional = yes; - INIT: load = ROM, type = ro, optional = yes; - CODE: load = ROM, type = ro, define = yes; - RODATA: load = ROM, type = ro, optional = yes; - DATA: load = ROM, run = RAM, type = rw, define = yes, optional = yes; - INITBSS: load = RAM, type = bss, optional = yes; - BSS: load = RAM, type = bss, define = yes, optional = yes; - CARTHDR: load = CARTID, type = ro; - ZEROPAGE: load = ZP, type = zp, optional = yes; - EXTZP: load = ZP, type = zp, optional = yes; + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXTZP: load = ZP, type = zp, optional = yes; + STARTUP: load = ROM, type = ro, define = yes, optional = yes; + LOWCODE: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; + CODE: load = ROM, type = ro, define = yes; + RODATA: load = ROM, type = ro, optional = yes; + DATA: load = ROM, run = RAM, type = rw, define = yes, optional = yes; + INIT: load = RAM, type = bss, optional = yes; + BSS: load = RAM, type = bss, define = yes, optional = yes; + CARTHDR: load = CARTID, type = ro; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/atari-cassette.cfg b/cfg/atari-cassette.cfg index 80b5c695f..ad68bb8b4 100644 --- a/cfg/atari-cassette.cfg +++ b/cfg/atari-cassette.cfg @@ -12,23 +12,23 @@ MEMORY { RAM: file = %O, define = yes, start = %S, size = $BC20 - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; } SEGMENTS { - CASHDR: load = RAM, type = ro; - STARTUP: load = RAM, type = ro, define = yes, optional = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro, optional = yes; - DATA: load = RAM, type = rw, optional = yes; - INITBSS: load = RAM, type = bss, optional = yes; - BSS: load = RAM, type = bss, define = yes, optional = yes; - ZEROPAGE: load = ZP, type = zp, optional = yes; - EXTZP: load = ZP, type = zp, optional = yes; + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXTZP: load = ZP, type = zp, optional = yes; + CASHDR: load = RAM, type = ro; + STARTUP: load = RAM, type = ro, define = yes, optional = yes; + LOWCODE: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, optional = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = RAM, type = ro, optional = yes; + DATA: load = RAM, type = rw, optional = yes; + INIT: load = RAM, type = bss, optional = yes; + BSS: load = RAM, type = bss, define = yes, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/atari-overlay.cfg b/cfg/atari-overlay.cfg index b3abad988..b14a93a39 100644 --- a/cfg/atari-overlay.cfg +++ b/cfg/atari-overlay.cfg @@ -38,6 +38,8 @@ MEMORY { OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; EXEHDR: load = HEADER, type = ro; SYSCHKHDR: load = SYSCHKHDR, type = ro, optional = yes; SYSCHK: load = SYSCHKCHNK, type = rw, define = yes, optional = yes; @@ -45,14 +47,12 @@ SEGMENTS { MAINHDR: load = MAINHDR, type = ro; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, optional = yes; + ONCE: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, optional = yes; + INIT: load = RAM, type = bss, optional = yes; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, optional = yes; AUTOSTRT: load = TRAILER, type = ro; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; @@ -68,7 +68,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/atari.cfg b/cfg/atari.cfg index 97b289d7e..7460a0f66 100644 --- a/cfg/atari.cfg +++ b/cfg/atari.cfg @@ -26,6 +26,8 @@ MEMORY { TRAILER: file = %O, start = $0000, size = $0006; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; EXEHDR: load = HEADER, type = ro; SYSCHKHDR: load = SYSCHKHDR, type = ro, optional = yes; SYSCHK: load = SYSCHKCHNK, type = rw, define = yes, optional = yes; @@ -33,21 +35,19 @@ SEGMENTS { MAINHDR: load = MAINHDR, type = ro; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, optional = yes; + ONCE: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, optional = yes; + INIT: load = RAM, type = bss, optional = yes; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, optional = yes; AUTOSTRT: load = TRAILER, type = ro; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/atari5200.cfg b/cfg/atari5200.cfg index 4a90303cf..3db8765d6 100644 --- a/cfg/atari5200.cfg +++ b/cfg/atari5200.cfg @@ -13,9 +13,11 @@ MEMORY { CARTENTRY: file = %O, start = $BFFE, size = $0002; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXTZP: load = ZP, type = zp, optional = yes; STARTUP: load = ROM, type = ro, define = yes, optional = yes; LOWCODE: load = ROM, type = ro, define = yes, optional = yes; - INIT: load = ROM, type = ro, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro, define = yes; RODATA: load = ROM, type = ro, optional = yes; DATA: load = ROM, run = RAM, type = rw, define = yes, optional = yes; @@ -23,14 +25,12 @@ SEGMENTS { CARTNAME: load = CARTNAME, type = ro, define = yes; CARTYEAR: load = CARTYEAR, type = ro, define = yes; CARTENTRY: load = CARTENTRY, type = ro, define = yes; - ZEROPAGE: load = ZP, type = zp, optional = yes; - EXTZP: load = ZP, type = zp, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/atarixl-largehimem.cfg b/cfg/atarixl-largehimem.cfg index f96096995..a1ec5cf08 100644 --- a/cfg/atarixl-largehimem.cfg +++ b/cfg/atarixl-largehimem.cfg @@ -50,6 +50,9 @@ MEMORY { } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + EXEHDR: load = HEADER, type = ro; SYSCHKHDR: load = SYSCHKHDR, type = ro, optional = yes; @@ -66,21 +69,19 @@ SEGMENTS { MAINHDR: load = MAINHDR, type = ro; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, optional = yes; + ONCE: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, optional = yes; + INIT: load = RAM, type = bss, optional = yes; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, optional = yes; AUTOSTRT: load = TRAILER, type = ro; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/atarixl-overlay.cfg b/cfg/atarixl-overlay.cfg index 7356fc03e..b0b4f3b88 100644 --- a/cfg/atarixl-overlay.cfg +++ b/cfg/atarixl-overlay.cfg @@ -62,6 +62,9 @@ MEMORY { } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + EXEHDR: load = HEADER, type = ro; SYSCHKHDR: load = SYSCHKHDR, type = ro, optional = yes; @@ -78,14 +81,12 @@ SEGMENTS { MAINHDR: load = MAINHDR, type = ro; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, optional = yes; + ONCE: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, optional = yes; + INIT: load = RAM, type = bss, optional = yes; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, optional = yes; AUTOSTRT: load = TRAILER, type = ro; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; @@ -102,7 +103,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/atarixl.cfg b/cfg/atarixl.cfg index 84992a205..2f9523c59 100644 --- a/cfg/atarixl.cfg +++ b/cfg/atarixl.cfg @@ -48,6 +48,9 @@ MEMORY { } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + EXEHDR: load = HEADER, type = ro; SYSCHKHDR: load = SYSCHKHDR, type = ro, optional = yes; @@ -64,21 +67,19 @@ SEGMENTS { MAINHDR: load = MAINHDR, type = ro; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, optional = yes; + ONCE: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss, optional = yes; + INIT: load = RAM, type = bss, optional = yes; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, optional = yes; AUTOSTRT: load = TRAILER, type = ro; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/atmos.cfg b/cfg/atmos.cfg index a1f935efa..a0f7e1c3d 100644 --- a/cfg/atmos.cfg +++ b/cfg/atmos.cfg @@ -21,7 +21,7 @@ SEGMENTS { LOWCODE: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; DATA: load = RAM, type = rw; ZPSAVE1: load = RAM, type = rw, define = yes; # ZPSAVE1, ZPSAVE2 must be together ZPSAVE2: load = RAM, type = bss; # see "libsrc/atmos/crt0.s" @@ -31,7 +31,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/bbc.cfg b/cfg/bbc.cfg index 6304c309b..98779b6fd 100644 --- a/cfg/bbc.cfg +++ b/cfg/bbc.cfg @@ -6,20 +6,20 @@ MEMORY { RAM: file = %O, start = $0E00, size = $7200 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/c128-overlay.cfg b/cfg/c128-overlay.cfg index f2cc3c40c..771bd290b 100644 --- a/cfg/c128-overlay.cfg +++ b/cfg/c128-overlay.cfg @@ -30,17 +30,17 @@ MEMORY { OVL9: file = "%O.9", start = $C000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss; + INIT: load = RAM, type = bss; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; OVL1ADDR: load = OVL1ADDR, type = ro; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; OVL2ADDR: load = OVL2ADDR, type = ro; @@ -64,7 +64,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/c128.cfg b/cfg/c128.cfg index ef2aa4184..0ea6066ad 100644 --- a/cfg/c128.cfg +++ b/cfg/c128.cfg @@ -10,23 +10,23 @@ MEMORY { RAM: file = %O, define = yes, start = $1C0D, size = $A3F3 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss; + INIT: load = RAM, type = bss; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/c16.cfg b/cfg/c16.cfg index efb42991f..b4b5ccaf7 100644 --- a/cfg/c16.cfg +++ b/cfg/c16.cfg @@ -10,23 +10,23 @@ MEMORY { RAM: file = %O, start = $100D, size = $6FF3 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss; + INIT: load = RAM, type = bss; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/c64-overlay.cfg b/cfg/c64-overlay.cfg index 522a6d1a6..872fdd775 100644 --- a/cfg/c64-overlay.cfg +++ b/cfg/c64-overlay.cfg @@ -44,9 +44,9 @@ SEGMENTS { CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INITBSS: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; BSS: load = MAIN, type = bss, define = yes; - INIT: load = INIT, type = ro; + ONCE: load = INIT, type = ro; OVL1ADDR: load = OVL1ADDR, type = ro; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; OVL2ADDR: load = OVL2ADDR, type = ro; @@ -70,7 +70,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/c64.cfg b/cfg/c64.cfg index 8ff7db03c..3735a0a65 100644 --- a/cfg/c64.cfg +++ b/cfg/c64.cfg @@ -23,15 +23,15 @@ SEGMENTS { CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INITBSS: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; BSS: load = MAIN, type = bss, define = yes; - INIT: load = INIT, type = ro, define = yes; + ONCE: load = INIT, type = ro, define = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/cbm510.cfg b/cfg/cbm510.cfg index d0775b6f2..8b01dff0b 100644 --- a/cfg/cbm510.cfg +++ b/cfg/cbm510.cfg @@ -18,11 +18,11 @@ SEGMENTS { PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss; + INIT: load = RAM, type = bss; BSS: load = RAM, type = bss, define = yes; ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = rw, define = yes; @@ -31,7 +31,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/cbm610.cfg b/cfg/cbm610.cfg index ae66f4c4a..6df9f1f5a 100644 --- a/cfg/cbm610.cfg +++ b/cfg/cbm610.cfg @@ -15,11 +15,11 @@ SEGMENTS { PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss; + INIT: load = RAM, type = bss; BSS: load = RAM, type = bss, define = yes; ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = rw, define = yes; @@ -28,7 +28,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/gamate.cfg b/cfg/gamate.cfg index 90ced1ea5..f0f669f27 100644 --- a/cfg/gamate.cfg +++ b/cfg/gamate.cfg @@ -1,41 +1,51 @@ # linker config to produce simple Gamate cartridge (.bin) SYMBOLS { - __STARTUP__: type = import; - __STACKSIZE__: type = weak, value = $0080; # 1 page stack + __STARTUP__: type = import; + __STACKSIZE__: type = weak, value = $0080; # 1 page stack } MEMORY { - # 0000-03ff is RAM - # FIXME: what zp range can we actually use? - # $0a-$11 is used by IRQ/NMI, $e8 is used by NMI - ZP: start = $0012, size = $e8 - $12; - CPUSTACK: start = $0100, size =$100; - RAM: start = $0200, size = $200 - __STACKSIZE__, define = yes; + # 0000-03ff is RAM + # FIXME: what zp range can we actually use? + # $0a-$11 is used by IRQ/NMI, $e8 is used by NMI + ZP: start = $0012, size = $e8 - $12; + CPUSTACK: start = $0100, size =$100; + RAM: start = $0200, size = $200 - __STACKSIZE__, define = yes; - CARTHEADER: file = %O, define = yes, start = %S, size = $0029; - # 6000-e000 can be (Cartridge) ROM - # WARNING: fill value must be $00 else it will no more work - #ROM: start = $6000, size = $1000, fill = yes, fillval = $00, file = %O, define = yes; - #ROMFILL: start = $7000, size = $7000, fill = yes, fillval = $00, file = %O, define = yes; - # for images that have code >$6fff we must calculate the checksum! - ROM: start = $6000 + $29, size = $8000 - $29, fill = yes, fillval = $00, file = %O, define = yes; + CARTHEADER: file = %O, define = yes, start = %S, size = $0029; + # 6000-e000 can be (Cartridge) ROM + # WARNING: fill value must be $00 else it will no more work + #ROM: start = $6000, size = $1000, fill = yes, fillval = $00, file = %O, define = yes; + #ROMFILL: start = $7000, size = $7000, fill = yes, fillval = $00, file = %O, define = yes; + # for images that have code >$6fff we must calculate the checksum! + ROM: start = $6000 + $29, size = $8000 - $29, fill = yes, fillval = $00, file = %O, define = yes; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; - EXTZP: load = ZP, type = zp, define = yes, optional = yes; - APPZP: load = ZP, type = zp, define = yes, optional = yes; - STARTUP: load = CARTHEADER, type = ro, define=yes; - INIT: load = ROM, type = ro, define = yes, optional = yes; - CODE: load = ROM, type = ro, define=yes; - RODATA: load = ROM, type = ro, define=yes; - DATA: load = ROM, run=RAM, type = rw, define = yes; - BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp, define = yes; + EXTZP: load = ZP, type = zp, define = yes, optional = yes; + APPZP: load = ZP, type = zp, define = yes, optional = yes; + STARTUP: load = CARTHEADER, type = ro, define = yes; + ONCE: load = ROM, type = ro, define = yes, optional = yes; + CODE: load = ROM, type = ro, define = yes; + RODATA: load = ROM, type = ro, define = yes; + DATA: load = ROM, run = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; } FEATURES { - CONDES: segment = RODATA, type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__; - CONDES: segment = RODATA, type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__; - CONDES: segment = RODATA, type = interruptor, label = __INTERRUPTOR_TABLE__, count = __INTERRUPTOR_COUNT__, import = __CALLIRQ__; + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; } diff --git a/cfg/geos-apple.cfg b/cfg/geos-apple.cfg index 746e1f2bf..ee8b61aec 100644 --- a/cfg/geos-apple.cfg +++ b/cfg/geos-apple.cfg @@ -40,7 +40,7 @@ SEGMENTS { VLIRIDX0: type = ro, load = CVT, align = $200, optional = yes; STARTUP: type = ro, run = VLIR0, load = CVT, align_load = $200, define = yes; LOWCODE: type = ro, run = VLIR0, load = CVT, optional = yes; - INIT: type = ro, run = VLIR0, load = CVT, define = yes, optional = yes; + ONCE: type = ro, run = VLIR0, load = CVT, define = yes, optional = yes; CODE: type = ro, run = VLIR0, load = CVT; RODATA: type = ro, run = VLIR0, load = CVT; DATA: type = rw, run = VLIR0, load = CVT; @@ -88,7 +88,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/geos-cbm.cfg b/cfg/geos-cbm.cfg index ddef00a99..42cbe9a48 100644 --- a/cfg/geos-cbm.cfg +++ b/cfg/geos-cbm.cfg @@ -37,7 +37,7 @@ SEGMENTS { RECORDS: type = ro, load = CVT, align = $FE, optional = yes; STARTUP: type = ro, run = VLIR0, load = CVT, align_load = $FE, define = yes; LOWCODE: type = ro, run = VLIR0, load = CVT, optional = yes; - INIT: type = ro, run = VLIR0, load = CVT, define = yes, optional = yes; + ONCE: type = ro, run = VLIR0, load = CVT, define = yes, optional = yes; CODE: type = ro, run = VLIR0, load = CVT; RODATA: type = ro, run = VLIR0, load = CVT; DATA: type = rw, run = VLIR0, load = CVT; @@ -66,7 +66,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/lunix.cfg b/cfg/lunix.cfg index 1342c390b..aabacbeb2 100644 --- a/cfg/lunix.cfg +++ b/cfg/lunix.cfg @@ -12,7 +12,7 @@ SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; # Pseudo-registers STARTUP: load = RAM, type = ro; # First initialization code LOWCODE: load = RAM, type = ro, optional = yes; # Legacy from other platforms - INIT: load = RAM, type = ro, define = yes, optional = yes; # Library initialization code + ONCE: load = RAM, type = ro, define = yes, optional = yes; # Library initialization code CODE: load = RAM, type = ro; # Program RODATA: load = RAM, type = ro; # Literals, constants DATA: load = RAM, type = rw; # Initialized variables @@ -22,7 +22,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/lynx-bll.cfg b/cfg/lynx-bll.cfg index 21967752f..fcf6d4c60 100644 --- a/cfg/lynx-bll.cfg +++ b/cfg/lynx-bll.cfg @@ -10,23 +10,23 @@ MEMORY { RAM: file = %O, define = yes, start = $0400, size = $BC38 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + APPZP: load = ZP, type = zp, optional = yes; BLLHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro, define = yes; DATA: load = RAM, type = rw, define = yes; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, optional = yes; - APPZP: load = ZP, type = zp, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/lynx-coll.cfg b/cfg/lynx-coll.cfg index b7fd787e7..d40c18237 100644 --- a/cfg/lynx-coll.cfg +++ b/cfg/lynx-coll.cfg @@ -14,25 +14,25 @@ MEMORY { RAM: file = %O, define = yes, start = $0200, size = $9E58 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + APPZP: load = ZP, type = zp, optional = yes; EXEHDR: load = HEADER, type = ro; BOOTLDR: load = BOOT, type = ro; DIRECTORY: load = DIR, type = ro; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro, define = yes; DATA: load = RAM, type = rw, define = yes; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, optional = yes; - APPZP: load = ZP, type = zp, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/lynx-uploader.cfg b/cfg/lynx-uploader.cfg index 740a18b0a..fe6d6133d 100644 --- a/cfg/lynx-uploader.cfg +++ b/cfg/lynx-uploader.cfg @@ -16,27 +16,27 @@ MEMORY { UPLDR: file = %O, define = yes, start = $BFDC, size = $005C; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + APPZP: load = ZP, type = zp, optional = yes; EXEHDR: load = HEADER, type = ro; BOOTLDR: load = BOOT, type = ro; DIRECTORY:load = DIR, type = ro; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro, define = yes; DATA: load = RAM, type = rw, define = yes; BSS: load = RAM, type = bss, define = yes; UPCODE: load = UPLDR, type = ro, define = yes; UPDATA: load = UPLDR, type = rw, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, optional = yes; - APPZP: load = ZP, type = zp, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/lynx.cfg b/cfg/lynx.cfg index 2c9e76207..4d41c1bbf 100644 --- a/cfg/lynx.cfg +++ b/cfg/lynx.cfg @@ -14,25 +14,25 @@ MEMORY { RAM: file = %O, define = yes, start = $0200, size = $BE38 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + APPZP: load = ZP, type = zp, optional = yes; EXEHDR: load = HEADER, type = ro; BOOTLDR: load = BOOT, type = ro; DIRECTORY: load = DIR, type = ro; STARTUP: load = RAM, type = ro, define = yes; LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro, define = yes; DATA: load = RAM, type = rw, define = yes; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, optional = yes; - APPZP: load = ZP, type = zp, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/module.cfg b/cfg/module.cfg index 452491eb4..be312585c 100644 --- a/cfg/module.cfg +++ b/cfg/module.cfg @@ -6,7 +6,7 @@ SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = zp, optional = yes; HEADER: load = COMBINED, type = ro; - INIT: load = COMBINED, type = ro, optional = yes; + ONCE: load = COMBINED, type = ro, optional = yes; CODE: load = COMBINED, type = ro; RODATA: load = COMBINED, type = ro; DATA: load = COMBINED, type = rw; diff --git a/cfg/nes.cfg b/cfg/nes.cfg index 3e2f408cc..f68330425 100644 --- a/cfg/nes.cfg +++ b/cfg/nes.cfg @@ -33,23 +33,23 @@ MEMORY { RAM: file = "", start = $6000, size = $2000, define = yes; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; HEADER: load = HEADER, type = ro; STARTUP: load = ROM0, type = ro, define = yes; LOWCODE: load = ROM0, type = ro, optional = yes; - INIT: load = ROM0, type = ro, define = yes, optional = yes; + ONCE: load = ROM0, type = ro, define = yes, optional = yes; CODE: load = ROM0, type = ro, define = yes; RODATA: load = ROM0, type = ro, define = yes; DATA: load = ROM0, run = RAM, type = rw, define = yes; VECTORS: load = ROMV, type = rw; CHARS: load = ROM2, type = rw; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/none.cfg b/cfg/none.cfg index 49409a82c..54ae54eb4 100644 --- a/cfg/none.cfg +++ b/cfg/none.cfg @@ -6,19 +6,19 @@ MEMORY { RAM: file = %O, start = %S, size = $10000 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = rw; RODATA: load = RAM, type = rw; DATA: load = RAM, type = rw; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/osic1p-asm.cfg b/cfg/osic1p-asm.cfg index 4000890be..ac2e76dc9 100644 --- a/cfg/osic1p-asm.cfg +++ b/cfg/osic1p-asm.cfg @@ -15,11 +15,11 @@ MEMORY { RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; BOOT: load = HEAD, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = rw; RODATA: load = RAM, type = rw; DATA: load = RAM, type = rw; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; } diff --git a/cfg/osic1p.cfg b/cfg/osic1p.cfg index fd9aa604e..314eac0b9 100644 --- a/cfg/osic1p.cfg +++ b/cfg/osic1p.cfg @@ -15,22 +15,22 @@ MEMORY { RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, define = yes, optional = yes; BOOT: load = HEAD, type = ro, optional = yes; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = rw; RODATA: load = RAM, type = rw; DATA: load = RAM, type = rw; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = zp, define = yes, optional = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/pce.cfg b/cfg/pce.cfg index 9128eb727..219cbdec3 100644 --- a/cfg/pce.cfg +++ b/cfg/pce.cfg @@ -1,39 +1,39 @@ # linker config to produce simple NEC PC-Engine cartridge (.pce) SYMBOLS { - __STACKSIZE__: type = weak, value = $0300; # 3 pages stack + __STACKSIZE__: type = weak, value = $0300; # 3 pages stack } MEMORY { - # FIXME: is this correct? the first 3? bytes cant be used? - ZP: start = $03, size = $fd, type = rw, define = yes; + # FIXME: is this correct? the first 3? bytes cant be used? + ZP: file = "", start = $0003, size = $00FD, type = rw, define = yes; - # reset-bank and hardware vectors - ROM0: start = $e000, size = $1ff6, file = %O ,fill = yes, define = yes; - ROMV: start = $fff6, size = $a, file = %O,fill = yes; + # reset-bank and hardware vectors + ROM0: file = %O, start = $E000, size = $1FF6, fill = yes, define = yes; + ROMV: file = %O, start = $FFF6, size = $000A, fill = yes; - # first RAM page (also contains stack and zeropage) - RAM: start = $2200, size = $1e00, define = yes; + # first RAM page (also contains stack and zeropage) + RAM: file = "", start = $2200, size = $1e00, define = yes; } SEGMENTS { - STARTUP: load = ROM0, type = ro, define = yes; - INIT: load = ROM0, type = ro, define = yes, optional = yes; - CODE: load = ROM0, type = ro, define = yes; - RODATA: load = ROM0, type = ro, define = yes; - DATA: load = ROM0, run= RAM, type = rw, define = yes; - BSS: load = RAM, type = bss, define = yes; - VECTORS: load = ROMV, type = rw, define = yes; - ZEROPAGE: load = ZP, type = zp, define = yes; - EXTZP: load = ZP, type = zp, define = yes, optional = yes; - APPZP: load = ZP, type = zp, define = yes, optional = yes; + ZEROPAGE: load = ZP, type = zp, define = yes; + EXTZP: load = ZP, type = zp, define = yes, optional = yes; + APPZP: load = ZP, type = zp, define = yes, optional = yes; + STARTUP: load = ROM0, type = ro, define = yes; + ONCE: load = ROM0, type = ro, define = yes, optional = yes; + CODE: load = ROM0, type = ro, define = yes; + RODATA: load = ROM0, type = ro, define = yes; + DATA: load = ROM0, run = RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; + VECTORS: load = ROMV, type = rw, define = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/pet.cfg b/cfg/pet.cfg index 80d89ee50..aad3f579e 100644 --- a/cfg/pet.cfg +++ b/cfg/pet.cfg @@ -10,23 +10,23 @@ MEMORY { RAM: file = %O, start = $040D, size = $7BF3 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss; + INIT: load = RAM, type = bss; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/plus4.cfg b/cfg/plus4.cfg index 6eeddf12e..16e9d12c8 100644 --- a/cfg/plus4.cfg +++ b/cfg/plus4.cfg @@ -10,23 +10,23 @@ MEMORY { RAM: file = %O, define = yes, start = $100D, size = $ECF3 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss; + INIT: load = RAM, type = bss; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/sim6502.cfg b/cfg/sim6502.cfg index edb630d7f..8e78fceb2 100644 --- a/cfg/sim6502.cfg +++ b/cfg/sim6502.cfg @@ -3,26 +3,26 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack } MEMORY { - ZP: file = "", start = $0000, size = $001A; - HEADER: file = %O, start = $0000, size = $0001; - RAM: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; + ZP: file = "", start = $0000, size = $001A; + HEADER: file = %O, start = $0000, size = $0001; + RAM: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; } SEGMENTS { - EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = RAM, type = ro; + LOWCODE: load = RAM, type = ro, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; + CODE: load = RAM, type = ro; + RODATA: load = RAM, type = ro; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/sim65c02.cfg b/cfg/sim65c02.cfg index edb630d7f..8e78fceb2 100644 --- a/cfg/sim65c02.cfg +++ b/cfg/sim65c02.cfg @@ -3,26 +3,26 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack } MEMORY { - ZP: file = "", start = $0000, size = $001A; - HEADER: file = %O, start = $0000, size = $0001; - RAM: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; + ZP: file = "", start = $0000, size = $001A; + HEADER: file = %O, start = $0000, size = $0001; + RAM: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; } SEGMENTS { - EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = RAM, type = ro; + LOWCODE: load = RAM, type = ro, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; + CODE: load = RAM, type = ro; + RODATA: load = RAM, type = ro; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/supervision-128k.cfg b/cfg/supervision-128k.cfg index ce835db50..3cfdf1276 100644 --- a/cfg/supervision-128k.cfg +++ b/cfg/supervision-128k.cfg @@ -21,7 +21,7 @@ MEMORY { } SEGMENTS { LOWCODE: load = ROM, type = ro, optional = yes; - INIT: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, define = yes, optional = yes; CODE: load = ROM, type = ro; BANK1: load = BANKROM1, type = ro; BANK2: load = BANKROM2, type = ro; diff --git a/cfg/supervision-16k.cfg b/cfg/supervision-16k.cfg index e38948d5f..2e96b9a72 100644 --- a/cfg/supervision-16k.cfg +++ b/cfg/supervision-16k.cfg @@ -14,21 +14,21 @@ MEMORY { ROM: file = %O, start = $C000, size = $4000, fill = yes, fillval = $ff, define=yes; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; LOWCODE: load = ROM, type = ro, optional = yes; - INIT: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, define = yes, optional = yes; CODE: load = ROM, type = ro, define = yes; RODATA: load = ROM, type = ro, define = yes; DATA: load = ROM, run = RAM, type = rw, define = yes; FFF0: load = ROM, type = ro, offset = $3FF0; VECTOR: load = ROM, type = ro, offset = $3FFA; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp, define = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/supervision-64k.cfg b/cfg/supervision-64k.cfg index fd5370fa5..63338d1e3 100644 --- a/cfg/supervision-64k.cfg +++ b/cfg/supervision-64k.cfg @@ -17,7 +17,7 @@ MEMORY { } SEGMENTS { LOWCODE: load = ROM, type = ro, optional = yes; - INIT: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, define = yes, optional = yes; CODE: load = ROM, type = ro; RODATA: load = ROM, type = ro; BANK1: load = BANKROM1, type = ro; diff --git a/cfg/supervision.cfg b/cfg/supervision.cfg index 66fb4cfad..b7ae207b8 100644 --- a/cfg/supervision.cfg +++ b/cfg/supervision.cfg @@ -10,21 +10,21 @@ MEMORY { ROM: file = %O, start = $8000, size = $8000, fill = yes, fillval = $FF, define = yes; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; LOWCODE: load = ROM, type = ro, optional = yes; - INIT: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, define = yes, optional = yes; CODE: load = ROM, type = ro, define = yes; RODATA: load = ROM, type = ro, define = yes; DATA: load = ROM, run = RAM, type = rw, define = yes; FFF0: load = ROM, type = ro, offset = $7FF0; VECTOR: load = ROM, type = ro, offset = $7FFA; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp, define = yes; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/vic20-32k.cfg b/cfg/vic20-32k.cfg index 23cd718df..a1b609106 100644 --- a/cfg/vic20-32k.cfg +++ b/cfg/vic20-32k.cfg @@ -16,11 +16,11 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss; + INIT: load = RAM, type = bss; BSS: load = RAM, type = bss, define = yes; ZEROPAGE: load = ZP, type = zp; } @@ -28,7 +28,7 @@ FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/cfg/vic20.cfg b/cfg/vic20.cfg index 9a5ce9a63..693b356a3 100644 --- a/cfg/vic20.cfg +++ b/cfg/vic20.cfg @@ -10,23 +10,23 @@ MEMORY { RAM: file = %O, define = yes, start = $100D, size = $0DF3 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, define = yes, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; - INITBSS: load = RAM, type = bss; + INIT: load = RAM, type = bss; BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; } FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__, - segment = INIT; + segment = ONCE; CONDES: type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, diff --git a/doc/atari.sgml b/doc/atari.sgml index 47ce050e1..f37b43929 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -743,7 +743,7 @@ segments should go above $7FFF. <p> The main problem is that the EXE header generated by the cc65 runtime lib is wrong. It defines a single load chunk with the sizes/addresses -of the STARTUP, LOWCODE, INIT, CODE, RODATA, and DATA segments, in +of the STARTUP, LOWCODE, ONCE, CODE, RODATA, and DATA segments, in fact, the whole user program (we're disregarding the "system check" load chunk here). <p> @@ -796,7 +796,7 @@ SEGMENTS { NEXEHDR: load = FSTHDR, type = ro; # first load chunk STARTUP: load = RAMLO, type = ro, define = yes; LOWCODE: load = RAMLO, type = ro, define = yes, optional = yes; - INIT: load = RAMLO, type = ro, optional = yes; + ONCE: load = RAMLO, type = ro, optional = yes; CODE: load = RAMLO, type = ro, define = yes; CHKHDR: load = SECHDR, type = ro; # second load chunk @@ -808,7 +808,7 @@ SEGMENTS { AUTOSTRT: load = RAM, type = ro; # defines program entry point } FEATURES { - CONDES: segment = RODATA, + CONDES: segment = ONCE, type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__; @@ -827,7 +827,7 @@ the MAINHDR segment get discarded. <p> The newly added NEXEHDR segment defines the correct chunk header for the first intended load chunk. It -puts the STARTUP, LOWCODE, INIT, and CODE segments, which are the +puts the STARTUP, LOWCODE, ONCE, and CODE segments, which are the segments containing only code, into load chunk #1 (RAMLO memory area). <p> The header for the second load chunk comes from the new CHKHDR @@ -858,7 +858,7 @@ cl65 -t atari -C split.cfg -o prog.com prog.c split.s <sect2>Low data and high code example<p> -Goal: Put RODATA and DATA into low memory and STARTUP, LOWCODE, INIT, +Goal: Put RODATA and DATA into low memory and STARTUP, LOWCODE, ONCE, CODE, BSS, ZPSAVE into high memory (split2.cfg): <tscreen><verb> @@ -893,7 +893,7 @@ SEGMENTS { CHKHDR: load = SECHDR, type = ro; # second load chunk STARTUP: load = RAM, type = ro, define = yes; - INIT: load = RAM, type = ro, optional = yes; + ONCE: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro, define = yes; BSS: load = RAM, type = bss, define = yes; @@ -901,7 +901,7 @@ SEGMENTS { AUTOSTRT: load = RAM, type = ro; # defines program entry point } FEATURES { - CONDES: segment = RODATA, + CONDES: segment = ONCE, type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__; diff --git a/doc/customizing.sgml b/doc/customizing.sgml index 0a0b8c87e..e502f2e9d 100644 --- a/doc/customizing.sgml +++ b/doc/customizing.sgml @@ -78,15 +78,15 @@ vectors at the proper memory locations. The segment definition is: <tscreen><code> SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; - DATA: load = ROM, type = rw, define = yes, run = RAM; - BSS: load = RAM, type = bss, define = yes; - HEAP: load = RAM, type = bss, optional = yes; - STARTUP: load = ROM, type = ro; - INIT: load = ROM, type = ro, optional = yes; - CODE: load = ROM, type = ro; - RODATA: load = ROM, type = ro; - VECTORS: load = ROM, type = ro, start = $FFFA; + ZEROPAGE: load = ZP, type = zp, define = yes; + DATA: load = ROM, type = rw, define = yes, run = RAM; + BSS: load = RAM, type = bss, define = yes; + HEAP: load = RAM, type = bss, optional = yes; + STARTUP: load = ROM, type = ro; + ONCE: load = ROM, type = ro, optional = yes; + CODE: load = ROM, type = ro; + RODATA: load = ROM, type = ro; + VECTORS: load = ROM, type = ro, start = $FFFA; } </code></tscreen> @@ -97,7 +97,7 @@ The meaning of each of these segments is as follows. <p><tt> BSS: </tt>Uninitialized data stored in RAM (used for variable storage) <p><tt> HEAP: </tt>Uninitialized C-level heap storage in RAM, optional <p><tt> STARTUP: </tt>The program initialization code, stored in ROM -<p><tt> INIT: </tt>The code needed to initialize the system, stored in ROM +<p><tt> ONCE: </tt>The code run once to initialize the system, stored in ROM <p><tt> CODE: </tt>The program code, stored in ROM <p><tt> RODATA: </tt>Initialized data that cannot be modified by the program, stored in ROM <p><tt> VECTORS: </tt>The interrupt vector table, stored in ROM at location $FFFA diff --git a/doc/ld65.sgml b/doc/ld65.sgml index 329f975e1..448157ce0 100644 --- a/doc/ld65.sgml +++ b/doc/ld65.sgml @@ -1032,11 +1032,11 @@ The builtin config files do contain segments that have a special meaning for the compiler and the libraries that come with it. If you replace the builtin config files, you will need the following information. -<sect1>INIT<p> +<sect1>ONCE<p> -The INIT segment is used for initialization code that may be reused once +The ONCE segment is used for initialization code run only once before execution reaches main() - provided that the program runs in RAM. You -may for example add the INIT segment to the heap in really memory +may for example add the ONCE segment to the heap in really memory constrained systems. <sect1>LOWCODE<p> diff --git a/libsrc/apple2/cputc.s b/libsrc/apple2/cputc.s index 1cadd1f1c..2db2962f9 100644 --- a/libsrc/apple2/cputc.s +++ b/libsrc/apple2/cputc.s @@ -14,7 +14,7 @@ .include "apple2.inc" - .segment "INIT" + .segment "ONCE" .ifdef __APPLE2ENH__ initconio: diff --git a/libsrc/apple2/crt0.s b/libsrc/apple2/crt0.s index f061b212b..7eee390fa 100644 --- a/libsrc/apple2/crt0.s +++ b/libsrc/apple2/crt0.s @@ -10,8 +10,8 @@ .import initlib, donelib .import callmain .import __LC_START__, __LC_LAST__ ; Linker generated - .import __INIT_RUN__, __INIT_SIZE__ ; Linker generated - .import __INITBSS_RUN__ ; Linker generated + .import __ONCE_RUN__, __ONCE_SIZE__ ; Linker generated + .import __INIT_RUN__ ; Linker generated .include "zeropage.inc" .include "apple2.inc" @@ -29,14 +29,14 @@ bit $C081 ; Set the source start address. - lda #<(__INITBSS_RUN__ + __INIT_SIZE__) - ldy #>(__INITBSS_RUN__ + __INIT_SIZE__) + lda #<(__INIT_RUN__ + __ONCE_SIZE__) + ldy #>(__INIT_RUN__ + __ONCE_SIZE__) sta $9B sty $9C ; Set the source last address. - lda #<(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__) - ldy #>(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__) + lda #<(__INIT_RUN__ + __ONCE_SIZE__ + __LC_LAST__ - __LC_START__) + ldy #>(__INIT_RUN__ + __ONCE_SIZE__ + __LC_LAST__ - __LC_START__) sta $96 sty $97 @@ -51,25 +51,25 @@ jsr $D39A ; BLTU2 ; Set the source start address. - lda #<__INITBSS_RUN__ - ldy #>__INITBSS_RUN__ + lda #<__INIT_RUN__ + ldy #>__INIT_RUN__ sta $9B sty $9C ; Set the source last address. - lda #<(__INITBSS_RUN__ + __INIT_SIZE__) - ldy #>(__INITBSS_RUN__ + __INIT_SIZE__) + lda #<(__INIT_RUN__ + __ONCE_SIZE__) + ldy #>(__INIT_RUN__ + __ONCE_SIZE__) sta $96 sty $97 ; Set the destination last address. - lda #<(__INIT_RUN__ + __INIT_SIZE__) - ldy #>(__INIT_RUN__ + __INIT_SIZE__) + lda #<(__ONCE_RUN__ + __ONCE_SIZE__) + ldy #>(__ONCE_RUN__ + __ONCE_SIZE__) sta $94 sty $95 ; Call into Applesoft Block Transfer Up -- which handles moving - ; overlapping blocks upwards well -- to move the INIT segment. + ; overlapping blocks upwards well -- to move the ONCE segment. jsr $D39A ; BLTU2 ; Delegate all further processing, to keep the STARTUP segment small. @@ -109,7 +109,7 @@ exit: ldx #$02 ; We're done jmp done - .segment "INIT" + .segment "ONCE" ; Save the zero-page locations that we need. init: ldx #zpspace-1 @@ -201,7 +201,7 @@ q_param:.byte $04 ; param_count ; Final jump when we're done done: jmp DOSWARM ; Potentially patched at runtime - .segment "INITBSS" + .segment "INIT" zpsave: .res zpspace diff --git a/libsrc/apple2/dosdetect.s b/libsrc/apple2/dosdetect.s index 68910e3da..cedb1f3e3 100644 --- a/libsrc/apple2/dosdetect.s +++ b/libsrc/apple2/dosdetect.s @@ -30,7 +30,7 @@ ; - Apple II ProDOS 8 TechNote #23, ProDOS 8 Changes and Minutia ; - ProDOS TechRefMan, chapter 5.2.4 - .segment "INIT" + .segment "ONCE" initdostype: lda $BF00 diff --git a/libsrc/apple2/extra/iobuf-0800.s b/libsrc/apple2/extra/iobuf-0800.s index 7951ccbb0..2e5d1927e 100644 --- a/libsrc/apple2/extra/iobuf-0800.s +++ b/libsrc/apple2/extra/iobuf-0800.s @@ -14,7 +14,7 @@ .include "errno.inc" .include "../filedes.inc" - .segment "INIT" + .segment "ONCE" initiobuf: ; Convert end address highbyte to table index diff --git a/libsrc/apple2/get_ostype.s b/libsrc/apple2/get_ostype.s index 68ae865ac..cff6af9a3 100644 --- a/libsrc/apple2/get_ostype.s +++ b/libsrc/apple2/get_ostype.s @@ -10,7 +10,7 @@ ; Identify machine according to: ; Apple II Miscellaneous TechNote #7, Apple II Family Identification - .segment "INIT" + .segment "ONCE" initostype: sec diff --git a/libsrc/apple2/irq.s b/libsrc/apple2/irq.s index 0b0555695..97a1633b4 100644 --- a/libsrc/apple2/irq.s +++ b/libsrc/apple2/irq.s @@ -9,7 +9,7 @@ .include "apple2.inc" - .segment "INIT" + .segment "ONCE" initirq: ; Check for ProDOS diff --git a/libsrc/apple2/mainargs.s b/libsrc/apple2/mainargs.s index 2e809dc56..e3db8bb10 100644 --- a/libsrc/apple2/mainargs.s +++ b/libsrc/apple2/mainargs.s @@ -46,10 +46,10 @@ FNAM_LEN = $280 FNAM = $281 REM = $B2 ; BASIC token-code -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run. - .segment "INIT" + .segment "ONCE" initmainargs: diff --git a/libsrc/apple2/open.s b/libsrc/apple2/open.s index b1686df70..e47722973 100644 --- a/libsrc/apple2/open.s +++ b/libsrc/apple2/open.s @@ -19,7 +19,7 @@ .include "mli.inc" .include "filedes.inc" - .segment "INIT" + .segment "ONCE" raisefilelevel: ; Raise file level diff --git a/libsrc/apple2/read.s b/libsrc/apple2/read.s index ef994d6aa..14c80b7e2 100644 --- a/libsrc/apple2/read.s +++ b/libsrc/apple2/read.s @@ -16,7 +16,7 @@ .include "filedes.inc" .include "apple2.inc" - .segment "INIT" + .segment "ONCE" initprompt: ; Set prompt <> ']' to let DOS 3.3 know that we're diff --git a/libsrc/apple2/reboot.s b/libsrc/apple2/reboot.s index 8ee1ba067..e674ea1bc 100644 --- a/libsrc/apple2/reboot.s +++ b/libsrc/apple2/reboot.s @@ -10,7 +10,7 @@ _rebootafterexit := return - .segment "INIT" + .segment "ONCE" initreboot: ; Quit to PWRUP diff --git a/libsrc/atari/casinit.s b/libsrc/atari/casinit.s index c91989aad..668f34867 100644 --- a/libsrc/atari/casinit.s +++ b/libsrc/atari/casinit.s @@ -13,7 +13,7 @@ .import start .export _cas_init -.segment "INIT" +.segment "ONCE" _cas_init: .ifdef DEBUG diff --git a/libsrc/atari/dosdetect.s b/libsrc/atari/dosdetect.s index 654da55b5..cac9a6536 100644 --- a/libsrc/atari/dosdetect.s +++ b/libsrc/atari/dosdetect.s @@ -11,7 +11,7 @@ ; ------------------------------------------------------------------------ ; DOS type detection -.segment "INIT" +.segment "ONCE" detect: lda DOS cmp #'S' ; SpartaDOS diff --git a/libsrc/atari/getargs.s b/libsrc/atari/getargs.s index fb3b7bc03..d32c0a268 100644 --- a/libsrc/atari/getargs.s +++ b/libsrc/atari/getargs.s @@ -20,7 +20,7 @@ SPACE = 32 ; SPACE char. ; -------------------------------------------------------------------------- ; Get command line -.segment "INIT" +.segment "ONCE" initmainargs: lda #0 diff --git a/libsrc/atari/irq.s b/libsrc/atari/irq.s index 0a8efe466..1878ea0a2 100644 --- a/libsrc/atari/irq.s +++ b/libsrc/atari/irq.s @@ -13,7 +13,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: lda VVBLKD diff --git a/libsrc/atari/mcbpm.s b/libsrc/atari/mcbpm.s index c5c5dd433..9e6ccc2c5 100644 --- a/libsrc/atari/mcbpm.s +++ b/libsrc/atari/mcbpm.s @@ -180,7 +180,7 @@ update_colors: ; ------------------------------------------------------------------------ - .segment "INIT" + .segment "ONCE" pm_init: lda #0 diff --git a/libsrc/atari/shadow_ram_handlers.s b/libsrc/atari/shadow_ram_handlers.s index 53a71ab71..d65e6bd68 100644 --- a/libsrc/atari/shadow_ram_handlers.s +++ b/libsrc/atari/shadow_ram_handlers.s @@ -26,7 +26,7 @@ SHRAM_HANDLERS = 1 BUFSZ = 128 ; bounce buffer size BUFSZ_SIO = 256 -.segment "INIT" +.segment "ONCE" ; Turn off ROMs, install system and interrupt wrappers, set new chargen pointer diff --git a/libsrc/atari5200/conioscreen.s b/libsrc/atari5200/conioscreen.s index 660276675..2e86001c2 100644 --- a/libsrc/atari5200/conioscreen.s +++ b/libsrc/atari5200/conioscreen.s @@ -9,7 +9,7 @@ SCREEN_BUF = $4000 - SCREEN_BUF_SIZE .export screen_setup_20x24 - .segment "INIT" + .segment "ONCE" screen_setup_20x24: diff --git a/libsrc/atari5200/irq.s b/libsrc/atari5200/irq.s index 720113f82..263805d02 100644 --- a/libsrc/atari5200/irq.s +++ b/libsrc/atari5200/irq.s @@ -9,7 +9,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: lda VVBLKD diff --git a/libsrc/atmos/capslock.s b/libsrc/atmos/capslock.s index 0ed6e70da..91c484250 100644 --- a/libsrc/atmos/capslock.s +++ b/libsrc/atmos/capslock.s @@ -17,7 +17,7 @@ ;-------------------------------------------------------------------------- ; Put this constructor into a segment that can be re-used by programs. ; -.segment "INIT" +.segment "ONCE" ; Turn the capitals lock off. diff --git a/libsrc/atmos/cgetc.s b/libsrc/atmos/cgetc.s index e4ea15ac6..64d597bc6 100644 --- a/libsrc/atmos/cgetc.s +++ b/libsrc/atmos/cgetc.s @@ -55,10 +55,10 @@ .endproc ; ------------------------------------------------------------------------ -; Switch the cursor off. Code goes into the INIT segment +; Switch the cursor off. Code goes into the ONCE segment ; which may be reused after it is run. -.segment "INIT" +.segment "ONCE" initcgetc: lsr STATUS diff --git a/libsrc/atmos/irq.s b/libsrc/atmos/irq.s index ed443caae..751c860f2 100644 --- a/libsrc/atmos/irq.s +++ b/libsrc/atmos/irq.s @@ -9,7 +9,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: lda IRQVec diff --git a/libsrc/atmos/mainargs.s b/libsrc/atmos/mainargs.s index d6d9ed1ef..8b57d9855 100644 --- a/libsrc/atmos/mainargs.s +++ b/libsrc/atmos/mainargs.s @@ -17,10 +17,10 @@ REM = $9d ; BASIC token-code ;--------------------------------------------------------------------------- -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run -.segment "INIT" +.segment "ONCE" .proc initmainargs diff --git a/libsrc/atmos/read.s b/libsrc/atmos/read.s index 324ac789e..edf9d161d 100644 --- a/libsrc/atmos/read.s +++ b/libsrc/atmos/read.s @@ -69,7 +69,7 @@ L9: lda ptr3 ;-------------------------------------------------------------------------- ; initstdin: Reset the stdin console. -.segment "INIT" +.segment "ONCE" initstdin: ldx #<-1 diff --git a/libsrc/c128/cgetc.s b/libsrc/c128/cgetc.s index 46f13d197..7cb4c159e 100644 --- a/libsrc/c128/cgetc.s +++ b/libsrc/c128/cgetc.s @@ -42,7 +42,7 @@ L2: jsr KBDREAD ; Read char and return in A .bss keyvec: .res 2 -.segment "INIT" +.segment "ONCE" initcgetc: ; Save the old vector diff --git a/libsrc/c128/crt0.s b/libsrc/c128/crt0.s index 4c6a0f7d9..5891bacf3 100644 --- a/libsrc/c128/crt0.s +++ b/libsrc/c128/crt0.s @@ -108,7 +108,7 @@ L2: lda zpsave,x ; ------------------------------------------------------------------------ ; Data -.segment "INITBSS" +.segment "INIT" zpsave: .res zpspace diff --git a/libsrc/c128/irq.s b/libsrc/c128/irq.s index 79aa8faaa..9f6d0c6d1 100644 --- a/libsrc/c128/irq.s +++ b/libsrc/c128/irq.s @@ -9,7 +9,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: lda IRQVec diff --git a/libsrc/c128/mainargs.s b/libsrc/c128/mainargs.s index dcd5a11bd..f53ceafa0 100644 --- a/libsrc/c128/mainargs.s +++ b/libsrc/c128/mainargs.s @@ -32,10 +32,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed REM = $8f ; BASIC token-code NAME_LEN = 16 ; Maximum length of command-name -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run -.segment "INIT" +.segment "ONCE" initmainargs: @@ -127,7 +127,7 @@ done: lda #<argv stx __argv + 1 rts -.segment "INITBSS" +.segment "INIT" term: .res 1 name: .res NAME_LEN + 1 diff --git a/libsrc/c128/mcbdefault.s b/libsrc/c128/mcbdefault.s index 1951129a6..eb521eb3a 100644 --- a/libsrc/c128/mcbdefault.s +++ b/libsrc/c128/mcbdefault.s @@ -29,7 +29,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register ; -------------------------------------------------------------------------- ; Initialize the mouse sprite. -.segment "INIT" +.segment "ONCE" initmcb: diff --git a/libsrc/c128/systime.s b/libsrc/c128/systime.s index e12d016b8..b2a7f8721 100644 --- a/libsrc/c128/systime.s +++ b/libsrc/c128/systime.s @@ -63,7 +63,7 @@ BCD2dec:tax ; Constructor that writes to the 1/10 sec register of the TOD to kick it ; into action. If this is not done, the clock hangs. We will read the register ; and write it again, ignoring a possible change in between. -.segment "INIT" +.segment "ONCE" .proc initsystime diff --git a/libsrc/c16/cgetc.s b/libsrc/c16/cgetc.s index 8bcb72100..a476a5d1b 100644 --- a/libsrc/c16/cgetc.s +++ b/libsrc/c16/cgetc.s @@ -56,7 +56,7 @@ L2: jsr KBDREAD ; Read char and return in A .constructor initkbd .destructor donekbd -.segment "INIT" +.segment "ONCE" .proc initkbd diff --git a/libsrc/c16/crt0.s b/libsrc/c16/crt0.s index c4d179529..bee81a113 100644 --- a/libsrc/c16/crt0.s +++ b/libsrc/c16/crt0.s @@ -90,7 +90,7 @@ L2: lda zpsave,x ; ------------------------------------------------------------------------ -.segment "INITBSS" +.segment "INIT" zpsave: .res zpspace diff --git a/libsrc/c16/irq.s b/libsrc/c16/irq.s index 46dd75fe8..91dd8c05c 100644 --- a/libsrc/c16/irq.s +++ b/libsrc/c16/irq.s @@ -9,7 +9,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: lda IRQVec diff --git a/libsrc/c16/mainargs.s b/libsrc/c16/mainargs.s index db93ae2e6..c1d77a0e7 100644 --- a/libsrc/c16/mainargs.s +++ b/libsrc/c16/mainargs.s @@ -32,10 +32,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed REM = $8f ; BASIC token-code NAME_LEN = 16 ; Maximum length of command-name -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run -.segment "INIT" +.segment "ONCE" initmainargs: @@ -126,7 +126,7 @@ done: lda #<argv stx __argv + 1 rts -.segment "INITBSS" +.segment "INIT" term: .res 1 name: .res NAME_LEN + 1 diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index ea7867925..c8a7386cb 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -34,7 +34,7 @@ Start: tsx stx spsave ; Save the system stack ptr -; Save space by putting some of the start-up code in the INIT segment, +; Save space by putting some of the start-up code in the ONCE segment, ; which can be re-used by the BSS segment, the heap and the C stack. jsr init @@ -79,7 +79,7 @@ L2: lda zpsave,x ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" init: @@ -111,7 +111,7 @@ L1: lda sp,x ; ------------------------------------------------------------------------ ; Data -.segment "INITBSS" +.segment "INIT" mmusave:.res 1 spsave: .res 1 diff --git a/libsrc/c64/irq.s b/libsrc/c64/irq.s index 10d03aa2c..d0767d53f 100644 --- a/libsrc/c64/irq.s +++ b/libsrc/c64/irq.s @@ -9,7 +9,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: lda IRQVec diff --git a/libsrc/c64/mainargs.s b/libsrc/c64/mainargs.s index a31c1b54f..a381b49e1 100644 --- a/libsrc/c64/mainargs.s +++ b/libsrc/c64/mainargs.s @@ -32,10 +32,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed REM = $8f ; BASIC token-code NAME_LEN = 16 ; Maximum length of command-name -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run -.segment "INIT" +.segment "ONCE" initmainargs: @@ -125,7 +125,7 @@ done: lda #<argv stx __argv + 1 rts -.segment "INITBSS" +.segment "INIT" term: .res 1 name: .res NAME_LEN + 1 diff --git a/libsrc/c64/mcbdefault.s b/libsrc/c64/mcbdefault.s index cd36d8515..dd2f7cee7 100644 --- a/libsrc/c64/mcbdefault.s +++ b/libsrc/c64/mcbdefault.s @@ -30,7 +30,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register ; -------------------------------------------------------------------------- ; Initialize the mouse sprite. -.segment "INIT" +.segment "ONCE" initmcb: diff --git a/libsrc/c64/soft80_charset.s b/libsrc/c64/soft80_charset.s index 69fd3527f..1faa9f775 100644 --- a/libsrc/c64/soft80_charset.s +++ b/libsrc/c64/soft80_charset.s @@ -43,7 +43,7 @@ .export soft80_charset - .segment "INIT" + .segment "ONCE" soft80_charset: .byte $0f,$03,$0f,$00,$0f,$07,$05,$0e .byte $0f,$05,$0e,$0b,$0f,$0b,$0f,$0f diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 874d41a53..48039d288 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -56,7 +56,7 @@ soft80_shutdown: sta CIA2_PRA jmp $FF5B ; Initialize video I/O - .segment "INIT" + .segment "ONCE" firstinit: ; copy charset to RAM under I/O sei @@ -146,7 +146,7 @@ soft80_bitmapyhi_data: soft80_tables_data_end: ;------------------------------------------------------------------------------- - .segment "INITBSS" + .segment "INIT" soft80_internal_cellcolor: .res 1 soft80_internal_bgcolor: diff --git a/libsrc/c64/soft80mono_conio.s b/libsrc/c64/soft80mono_conio.s index 759b280c6..25c2fc558 100644 --- a/libsrc/c64/soft80mono_conio.s +++ b/libsrc/c64/soft80mono_conio.s @@ -60,7 +60,7 @@ soft80mono_shutdown: sta VIC_VIDEO_ADR rts - .segment "INIT" + .segment "ONCE" firstinit: ; copy charset to RAM under I/O sei @@ -150,7 +150,7 @@ soft80_bitmapyhi_data: soft80_tables_data_end: ;------------------------------------------------------------------------------- - .segment "INITBSS" + .segment "INIT" soft80mono_internal_cellcolor: .res 1 soft80mono_internal_bgcolor: diff --git a/libsrc/c64/systime.s b/libsrc/c64/systime.s index f8cd1b714..c28ace32e 100644 --- a/libsrc/c64/systime.s +++ b/libsrc/c64/systime.s @@ -63,7 +63,7 @@ BCD2dec:tax ; Constructor that writes to the 1/10 sec register of the TOD to kick it ; into action. If this is not done, the clock hangs. We will read the register ; and write it again, ignoring a possible change in between. -.segment "INIT" +.segment "ONCE" .proc initsystime diff --git a/libsrc/cbm/filevars.s b/libsrc/cbm/filevars.s index db2dec7b3..2cbf0436e 100644 --- a/libsrc/cbm/filevars.s +++ b/libsrc/cbm/filevars.s @@ -9,13 +9,13 @@ .importzp devnum -.segment "INITBSS" +.segment "INIT" curunit: .res 1 -.segment "INIT" +.segment "ONCE" .proc initcurunit diff --git a/libsrc/cbm/mcbpointercolor.s b/libsrc/cbm/mcbpointercolor.s index c9cb6330e..a52830d6b 100644 --- a/libsrc/cbm/mcbpointercolor.s +++ b/libsrc/cbm/mcbpointercolor.s @@ -3,7 +3,7 @@ .export _mouse_def_pointercolor -.segment "INIT" +.segment "ONCE" _mouse_def_pointercolor: diff --git a/libsrc/cbm/mcbpointershape.s b/libsrc/cbm/mcbpointershape.s index 7364201b1..82c7ed91d 100644 --- a/libsrc/cbm/mcbpointershape.s +++ b/libsrc/cbm/mcbpointershape.s @@ -3,7 +3,7 @@ .export _mouse_def_pointershape -.segment "INIT" +.segment "ONCE" _mouse_def_pointershape: diff --git a/libsrc/cbm/read.s b/libsrc/cbm/read.s index e0fd8d51b..87a2c7037 100644 --- a/libsrc/cbm/read.s +++ b/libsrc/cbm/read.s @@ -22,7 +22,7 @@ ;-------------------------------------------------------------------------- ; initstdin: Open the stdin file descriptors for the keyboard -.segment "INIT" +.segment "ONCE" .proc initstdin diff --git a/libsrc/cbm/write.s b/libsrc/cbm/write.s index e6da59c0f..20999d2ac 100644 --- a/libsrc/cbm/write.s +++ b/libsrc/cbm/write.s @@ -20,7 +20,7 @@ ;-------------------------------------------------------------------------- ; initstdout: Open the stdout and stderr file descriptors for the screen. -.segment "INIT" +.segment "ONCE" .proc initstdout diff --git a/libsrc/cbm510/mainargs.s b/libsrc/cbm510/mainargs.s index 0ec7d0c4c..45f35eedb 100644 --- a/libsrc/cbm510/mainargs.s +++ b/libsrc/cbm510/mainargs.s @@ -35,10 +35,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed REM = $8f ; BASIC token-code NAME_LEN = 16 ; Maximum length of command-name -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run. ; -.segment "INIT" +.segment "ONCE" initmainargs: @@ -144,7 +144,7 @@ done: lda #<argv stx __argv + 1 rts -.segment "INITBSS" +.segment "INIT" term: .res 1 name: .res NAME_LEN + 1 diff --git a/libsrc/cbm510/mcbdefault.s b/libsrc/cbm510/mcbdefault.s index 0db753e92..700dcebb1 100644 --- a/libsrc/cbm510/mcbdefault.s +++ b/libsrc/cbm510/mcbdefault.s @@ -31,7 +31,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register ; -------------------------------------------------------------------------- ; Initialize the mouse sprite. -.segment "INIT" +.segment "ONCE" initmcb: diff --git a/libsrc/cbm610/mainargs.s b/libsrc/cbm610/mainargs.s index 02461ac26..9f708698e 100644 --- a/libsrc/cbm610/mainargs.s +++ b/libsrc/cbm610/mainargs.s @@ -35,10 +35,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed REM = $8f ; BASIC token-code NAME_LEN = 16 ; Maximum length of command-name -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run. ; -.segment "INIT" +.segment "ONCE" initmainargs: @@ -142,7 +142,7 @@ done: lda #<argv stx __argv + 1 rts -.segment "INITBSS" +.segment "INIT" term: .res 1 name: .res NAME_LEN + 1 diff --git a/libsrc/common/_cwd.s b/libsrc/common/_cwd.s index 7b4031f52..92276ead9 100644 --- a/libsrc/common/_cwd.s +++ b/libsrc/common/_cwd.s @@ -19,7 +19,7 @@ cwd_init := initcwd -.segment "INITBSS" +.segment "INIT" __cwd: .res __cwd_buf_size diff --git a/libsrc/common/_heap.s b/libsrc/common/_heap.s index 5af434050..e2470577a 100644 --- a/libsrc/common/_heap.s +++ b/libsrc/common/_heap.s @@ -27,7 +27,7 @@ __heaplast: ; Initialization. Will be called from startup! -.segment "INIT" +.segment "ONCE" initheap: sec diff --git a/libsrc/gamate/clock.s b/libsrc/gamate/clock.s index 223c07967..98ad54624 100644 --- a/libsrc/gamate/clock.s +++ b/libsrc/gamate/clock.s @@ -23,7 +23,7 @@ .endproc - .segment "INIT" + .segment "ONCE" initclock: lda #0 ldx #3 diff --git a/libsrc/gamate/conio.s b/libsrc/gamate/conio.s index a43eeb1a3..18d5da674 100644 --- a/libsrc/gamate/conio.s +++ b/libsrc/gamate/conio.s @@ -8,7 +8,7 @@ .macpack longbranch - .segment "INIT" + .segment "ONCE" initconio: lda #0 sta LCD_XPOS diff --git a/libsrc/gamate/irq.s b/libsrc/gamate/irq.s index 862307f58..ddb6ce4ea 100644 --- a/libsrc/gamate/irq.s +++ b/libsrc/gamate/irq.s @@ -10,7 +10,7 @@ .include "extzp.inc" ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" ; a constructor ; diff --git a/libsrc/gamate/nmi.s b/libsrc/gamate/nmi.s index 61db62416..a09eea2e5 100644 --- a/libsrc/gamate/nmi.s +++ b/libsrc/gamate/nmi.s @@ -3,7 +3,7 @@ ; .export NMIStub - .segment "INIT" + .segment "ONCE" NMIStub: ; A is saved by the BIOS diff --git a/libsrc/geos-common/conio/_scrsize.s b/libsrc/geos-common/conio/_scrsize.s index 01aac96a4..dded4ca42 100644 --- a/libsrc/geos-common/conio/_scrsize.s +++ b/libsrc/geos-common/conio/_scrsize.s @@ -14,7 +14,7 @@ .include "geossym.inc" -.segment "INIT" +.segment "ONCE" initscrsize: .ifdef __GEOS_CBM__ diff --git a/libsrc/geos-common/system/mainargs.s b/libsrc/geos-common/system/mainargs.s index db829cc0b..14c624759 100644 --- a/libsrc/geos-common/system/mainargs.s +++ b/libsrc/geos-common/system/mainargs.s @@ -18,7 +18,7 @@ .include "const.inc" .include "geossym.inc" -.segment "INIT" +.segment "ONCE" ; Setup arguments for main diff --git a/libsrc/lynx/clock.s b/libsrc/lynx/clock.s index 881c43554..dbccb32cb 100644 --- a/libsrc/lynx/clock.s +++ b/libsrc/lynx/clock.s @@ -78,7 +78,7 @@ update_clock: ;----------------------------------------------------------------------------- ; Enable the interrupt that update_clock needs. ; - .segment "INIT" + .segment "ONCE" init_clock: lda #%10000000 tsb VTIMCTLA diff --git a/libsrc/lynx/defdir.s b/libsrc/lynx/defdir.s index 08358563b..a36848227 100644 --- a/libsrc/lynx/defdir.s +++ b/libsrc/lynx/defdir.s @@ -6,8 +6,8 @@ .include "lynx.inc" .import __STARTOFDIRECTORY__ .import __RAM_START__ - .import __CODE_SIZE__,__DATA_SIZE__,__RODATA_SIZE__ - .import __STARTUP_SIZE__,__INIT_SIZE__,__LOWCODE_SIZE__ + .import __CODE_SIZE__, __DATA_SIZE__, __RODATA_SIZE__ + .import __STARTUP_SIZE__, __ONCE_SIZE__, __LOWCODE_SIZE__ .import __BLOCKSIZE__ .export __DEFDIR__: absolute = 1 @@ -17,15 +17,14 @@ .segment "DIRECTORY" __DIRECTORY_START__: -off0=__STARTOFDIRECTORY__+(__DIRECTORY_END__-__DIRECTORY_START__) -blocka=off0/__BLOCKSIZE__ +off0 = __STARTOFDIRECTORY__ + (__DIRECTORY_END__ - __DIRECTORY_START__) +blocka = off0 / __BLOCKSIZE__ ; Entry 0 - first executable -block0=off0/__BLOCKSIZE__ -len0=__STARTUP_SIZE__+__INIT_SIZE__+__CODE_SIZE__+__DATA_SIZE__+__RODATA_SIZE__+__LOWCODE_SIZE__ +block0 = off0 / __BLOCKSIZE__ +len0 = __STARTUP_SIZE__ + __ONCE_SIZE__ + __CODE_SIZE__ + __DATA_SIZE__ + __RODATA_SIZE__ + __LOWCODE_SIZE__ .byte <block0 .word off0 & (__BLOCKSIZE__ - 1) .byte $88 .word __RAM_START__ .word len0 __DIRECTORY_END__: - diff --git a/libsrc/lynx/irq.s b/libsrc/lynx/irq.s index 4a6adfb04..d3b7976e0 100644 --- a/libsrc/lynx/irq.s +++ b/libsrc/lynx/irq.s @@ -9,7 +9,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: lda #<IRQStub diff --git a/libsrc/lynx/mainargs.s b/libsrc/lynx/mainargs.s index 8ab1b7c68..b402704c2 100644 --- a/libsrc/lynx/mainargs.s +++ b/libsrc/lynx/mainargs.s @@ -10,10 +10,10 @@ ;--------------------------------------------------------------------------- -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run -.segment "INIT" +.segment "ONCE" .proc initmainargs diff --git a/libsrc/nes/cputc.s b/libsrc/nes/cputc.s index 10915028b..5bcdc7994 100644 --- a/libsrc/nes/cputc.s +++ b/libsrc/nes/cputc.s @@ -75,10 +75,10 @@ putchar: jmp ppubuf_put ;----------------------------------------------------------------------------- -; Initialize the conio subsystem. Code goes into the INIT segment, which may +; Initialize the conio subsystem. Code goes into the ONCE segment, which may ; be reused after startup. -.segment "INIT" +.segment "ONCE" initconio: jsr ppuinit diff --git a/libsrc/nes/irq.s b/libsrc/nes/irq.s index 9c026f0ed..267d9de0a 100644 --- a/libsrc/nes/irq.s +++ b/libsrc/nes/irq.s @@ -6,7 +6,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: rts diff --git a/libsrc/nes/mainargs.s b/libsrc/nes/mainargs.s index 7ed8d46f4..def01e81d 100644 --- a/libsrc/nes/mainargs.s +++ b/libsrc/nes/mainargs.s @@ -10,10 +10,10 @@ ;--------------------------------------------------------------------------- -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run -.segment "INIT" +.segment "ONCE" .proc initmainargs diff --git a/libsrc/osic1p/cgetc.s b/libsrc/osic1p/cgetc.s index 5ddca2870..9161645c7 100644 --- a/libsrc/osic1p/cgetc.s +++ b/libsrc/osic1p/cgetc.s @@ -11,7 +11,7 @@ .include "zeropage.inc" ; Initialize one-character buffer that is filled by kbhit() - .segment "INIT" + .segment "ONCE" initcgetc: lda #$00 sta CHARBUF ; No character in buffer initially diff --git a/libsrc/pce/clock.s b/libsrc/pce/clock.s index 261739df8..828efdc1d 100644 --- a/libsrc/pce/clock.s +++ b/libsrc/pce/clock.s @@ -23,7 +23,7 @@ .endproc - .segment "INIT" + .segment "ONCE" initclock: lda #0 ldx #3 diff --git a/libsrc/pce/conio.s b/libsrc/pce/conio.s index b2bb0f9d5..674b70279 100644 --- a/libsrc/pce/conio.s +++ b/libsrc/pce/conio.s @@ -10,7 +10,7 @@ .macpack longbranch - .segment "INIT" + .segment "ONCE" initconio: jsr vce_init jsr psg_init diff --git a/libsrc/pce/irq.s b/libsrc/pce/irq.s index f34303d07..e0fb68556 100644 --- a/libsrc/pce/irq.s +++ b/libsrc/pce/irq.s @@ -10,7 +10,7 @@ .include "extzp.inc" ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" ; a constructor ; diff --git a/libsrc/pce/psg.s b/libsrc/pce/psg.s index b1d610fa1..c3392d9ff 100644 --- a/libsrc/pce/psg.s +++ b/libsrc/pce/psg.s @@ -2,7 +2,7 @@ .export psg_init - .segment "INIT" + .segment "ONCE" psg_init: clx stz PSG_GLOBAL_PAN ; Clear global balance diff --git a/libsrc/pce/vce.s b/libsrc/pce/vce.s index af69c5ed1..70f4d376a 100644 --- a/libsrc/pce/vce.s +++ b/libsrc/pce/vce.s @@ -2,7 +2,7 @@ .export vce_init - .segment "INIT" + .segment "ONCE" vce_init: ; Set CTA to zero stz VCE_ADDR_LO diff --git a/libsrc/pet/crt0.s b/libsrc/pet/crt0.s index c1c805308..520a147f7 100644 --- a/libsrc/pet/crt0.s +++ b/libsrc/pet/crt0.s @@ -94,7 +94,7 @@ L2: lda zpsave,x ; ------------------------------------------------------------------------ -.segment "INITBSS" +.segment "INIT" zpsave: .res zpspace diff --git a/libsrc/pet/irq.s b/libsrc/pet/irq.s index ddaf43ca5..9da45f1df 100644 --- a/libsrc/pet/irq.s +++ b/libsrc/pet/irq.s @@ -9,7 +9,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: lda IRQVec diff --git a/libsrc/pet/mainargs.s b/libsrc/pet/mainargs.s index 8ba6e3117..bc685b699 100644 --- a/libsrc/pet/mainargs.s +++ b/libsrc/pet/mainargs.s @@ -16,10 +16,10 @@ NAME_LEN = 16 ; Maximum length of command-name ;--------------------------------------------------------------------------- -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run -.segment "INIT" +.segment "ONCE" .proc initmainargs @@ -111,7 +111,7 @@ done: lda #<argv .endproc -.segment "INITBSS" +.segment "INIT" term: .res 1 name: .res NAME_LEN + 1 diff --git a/libsrc/plus4/cgetc.s b/libsrc/plus4/cgetc.s index 7ff568101..25a63c053 100644 --- a/libsrc/plus4/cgetc.s +++ b/libsrc/plus4/cgetc.s @@ -59,7 +59,7 @@ L2: sta ENABLE_ROM ; Bank in the ROM .constructor initkbd .destructor donekbd -.segment "INIT" ; Special init code segment may get overwritten +.segment "ONCE" ; Special init code segment may get overwritten .proc initkbd diff --git a/libsrc/plus4/crt0.s b/libsrc/plus4/crt0.s index ae3297562..9696d50f4 100644 --- a/libsrc/plus4/crt0.s +++ b/libsrc/plus4/crt0.s @@ -195,7 +195,7 @@ spsave: .res 1 irqcount: .byte 0 -.segment "INITBSS" +.segment "INIT" zpsave: .res zpspace diff --git a/libsrc/plus4/mainargs.s b/libsrc/plus4/mainargs.s index 59879978e..42e2ba029 100644 --- a/libsrc/plus4/mainargs.s +++ b/libsrc/plus4/mainargs.s @@ -32,10 +32,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed REM = $8f ; BASIC token-code NAME_LEN = 16 ; Maximum length of command-name -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run -.segment "INIT" +.segment "ONCE" initmainargs: @@ -125,7 +125,7 @@ done: lda #<argv stx __argv + 1 rts -.segment "INITBSS" +.segment "INIT" term: .res 1 name: .res NAME_LEN + 1 diff --git a/libsrc/runtime/condes.s b/libsrc/runtime/condes.s index c04f71808..a99b713f5 100644 --- a/libsrc/runtime/condes.s +++ b/libsrc/runtime/condes.s @@ -23,7 +23,7 @@ ; -------------------------------------------------------------------------- ; Initialize library modules -.segment "INIT" +.segment "ONCE" .proc initlib diff --git a/libsrc/runtime/stkchk.s b/libsrc/runtime/stkchk.s index 6186fe4e2..ceab4c703 100644 --- a/libsrc/runtime/stkchk.s +++ b/libsrc/runtime/stkchk.s @@ -28,7 +28,7 @@ ; Initialization code. This is a constructor, so it is called on startup if ; the linker has detected references to this module. -.segment "INIT" +.segment "ONCE" .proc initstkchk @@ -101,7 +101,7 @@ Fail: lda #4 ; ---------------------------------------------------------------------------- ; Data -.segment "INITBSS" +.segment "INIT" ; Initial stack pointer value. Stack is reset to this in case of overflows to ; allow program exit processing. diff --git a/libsrc/sim6502/mainargs.s b/libsrc/sim6502/mainargs.s index 1daa23ace..a3c8dee6d 100644 --- a/libsrc/sim6502/mainargs.s +++ b/libsrc/sim6502/mainargs.s @@ -5,7 +5,7 @@ .constructor initmainargs, 24 .import __argc, __argv, args - .segment "INIT" + .segment "ONCE" initmainargs: lda #<__argv diff --git a/libsrc/vic20/crt0.s b/libsrc/vic20/crt0.s index 6a0f94a03..723971168 100644 --- a/libsrc/vic20/crt0.s +++ b/libsrc/vic20/crt0.s @@ -86,7 +86,7 @@ L2: lda zpsave,x ; ------------------------------------------------------------------------ -.segment "INITBSS" +.segment "INIT" zpsave: .res zpspace diff --git a/libsrc/vic20/irq.s b/libsrc/vic20/irq.s index ca47347f8..4c7c832ac 100644 --- a/libsrc/vic20/irq.s +++ b/libsrc/vic20/irq.s @@ -9,7 +9,7 @@ ; ------------------------------------------------------------------------ -.segment "INIT" +.segment "ONCE" initirq: lda IRQVec diff --git a/libsrc/vic20/mainargs.s b/libsrc/vic20/mainargs.s index a41a1c495..b24745c08 100644 --- a/libsrc/vic20/mainargs.s +++ b/libsrc/vic20/mainargs.s @@ -32,10 +32,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed REM = $8f ; BASIC token-code NAME_LEN = 16 ; Maximum length of command-name -; Get possible command-line arguments. Goes into the special INIT segment, +; Get possible command-line arguments. Goes into the special ONCE segment, ; which may be reused after the startup code is run -.segment "INIT" +.segment "ONCE" initmainargs: @@ -125,7 +125,7 @@ done: lda #<argv stx __argv + 1 rts -.segment "INITBSS" +.segment "INIT" term: .res 1 name: .res NAME_LEN + 1 From d8c31cf1d3b724b83bd411736472e1c16fb1b0c0 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 7 Mar 2016 01:28:55 +0100 Subject: [PATCH 016/407] Renamed RAM to MAIN for all disk based targets. The name RAM doesn't make much sense in general for a memeory area because i.e. the zero page is for sure RAM but is not part of the memory area named RAM. For disk based targets it makes sense to put the disk file more into focus and here MAIN means the main part of the file - in contrast to some header. Only for ROM based targets the name RAM is kept as it makes sense to focus on the difference between RAM and ROM. --- cfg/apple2-asm.cfg | 10 ++--- cfg/apple2-overlay.cfg | 42 +++++++++---------- cfg/apple2-system.cfg | 16 +++---- cfg/apple2.cfg | 24 +++++------ cfg/apple2enh-asm.cfg | 10 ++--- cfg/apple2enh-overlay.cfg | 42 +++++++++---------- cfg/apple2enh-system.cfg | 22 +++++----- cfg/apple2enh.cfg | 24 +++++------ cfg/atari-asm.cfg | 34 +++++++-------- cfg/atari-cart.cfg | 30 ++++++------- cfg/atari-cassette.cfg | 26 ++++++------ cfg/atari-overlay.cfg | 50 +++++++++++----------- cfg/atari.cfg | 32 +++++++------- cfg/atarixl-largehimem.cfg | 60 +++++++++++++------------- cfg/atarixl-overlay.cfg | 86 +++++++++++++++++++------------------- cfg/atarixl.cfg | 62 +++++++++++++-------------- cfg/atmos.cfg | 20 ++++----- cfg/bbc.cfg | 20 ++++----- cfg/c128-overlay.cfg | 18 ++++---- cfg/c128.cfg | 18 ++++---- cfg/c16.cfg | 22 +++++----- cfg/c64-asm.cfg | 12 +++--- cfg/cbm510.cfg | 20 ++++----- cfg/cbm610.cfg | 20 ++++----- cfg/gamate.cfg | 14 +++---- cfg/lunix.cfg | 20 ++++----- cfg/lynx-bll.cfg | 16 +++---- cfg/lynx-coll.cfg | 16 +++---- cfg/lynx-uploader.cfg | 16 +++---- cfg/lynx.cfg | 16 +++---- cfg/none.cfg | 18 ++++---- cfg/osic1p-asm.cfg | 16 +++---- cfg/osic1p.cfg | 20 ++++----- cfg/plus4.cfg | 18 ++++---- cfg/sim6502.cfg | 16 +++---- cfg/sim65c02.cfg | 16 +++---- cfg/vic20-32k.cfg | 20 ++++----- cfg/vic20.cfg | 18 ++++---- doc/atari.sgml | 4 +- libsrc/atari/crt0.s | 8 ++-- libsrc/atari/exehdr.s | 4 +- libsrc/atmos/crt0.s | 8 ++-- libsrc/c128/crt0.s | 8 ++-- libsrc/gamate/crt0.s | 6 +-- libsrc/lynx/bllhdr.s | 7 ++-- libsrc/lynx/crt0.s | 8 ++-- libsrc/lynx/defdir.s | 4 +- libsrc/osic1p/bootstrap.s | 12 +++--- libsrc/osic1p/crt0.s | 8 ++-- libsrc/plus4/crt0.s | 10 ++--- libsrc/sim6502/crt0.s | 6 +-- libsrc/vic20/crt0.s | 8 ++-- 52 files changed, 530 insertions(+), 531 deletions(-) diff --git a/cfg/apple2-asm.cfg b/cfg/apple2-asm.cfg index 1e187764c..b9095cf0c 100644 --- a/cfg/apple2-asm.cfg +++ b/cfg/apple2-asm.cfg @@ -10,13 +10,13 @@ SYMBOLS { MEMORY { ZP: start = $0080, size = $001A, define = yes; HEADER: file = %O, start = $0000, size = $0004; - RAM: file = %O, start = %S, size = $C000 - %S; + MAIN: file = %O, start = %S, size = $C000 - %S; } SEGMENTS { ZEROPAGE: load = ZP, type = zp, optional = yes; EXEHDR: load = HEADER, type = ro, optional = yes; - CODE: load = RAM, type = rw, optional = yes, define = yes; - RODATA: load = RAM, type = ro, optional = yes; - DATA: load = RAM, type = rw, optional = yes; - BSS: load = RAM, type = bss, optional = yes, define = yes; + CODE: load = MAIN, type = rw, optional = yes, define = yes; + RODATA: load = MAIN, type = ro, optional = yes; + DATA: load = MAIN, type = rw, optional = yes; + BSS: load = MAIN, type = bss, optional = yes, define = yes; } diff --git a/cfg/apple2-overlay.cfg b/cfg/apple2-overlay.cfg index ef9103b49..1e34b6250 100644 --- a/cfg/apple2-overlay.cfg +++ b/cfg/apple2-overlay.cfg @@ -24,7 +24,7 @@ SYMBOLS { MEMORY { ZP: define = yes, start = $0080, size = $001A; HEADER: file = %O, start = $0000, size = $0004; - RAM: file = %O, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __STACKSIZE__ - __OVERLAYSIZE__ - %S; + MAIN: file = %O, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __STACKSIZE__ - __OVERLAYSIZE__ - %S; MOVE: file = %O, define = yes, start = $0000, size = $FFFF; LC: define = yes, start = __LCADDR__, size = __LCSIZE__; OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; @@ -38,26 +38,26 @@ MEMORY { OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, define = yes; - BSS: load = RAM, type = bss, define = yes; - ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; - OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; - OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; - OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; - OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; - OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; - OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; - OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; - OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; - OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; + ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; + LC: load = MOVE, run = LC, type = ro, optional = yes; + OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; + OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; + OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; + OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; + OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; + OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; + OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; + OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; + OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/apple2-system.cfg b/cfg/apple2-system.cfg index 52cad960f..960be378c 100644 --- a/cfg/apple2-system.cfg +++ b/cfg/apple2-system.cfg @@ -10,19 +10,19 @@ SYMBOLS { } MEMORY { ZP: define = yes, start = $0080, size = $001A; - RAM: file = %O, start = $2000, size = $9F00 - __STACKSIZE__; + MAIN: file = %O, start = $2000, size = $9F00 - __STACKSIZE__; MOVE: file = %O, define = yes, start = $0000, size = $FFFF; LC: define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, define = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; LC: load = MOVE, run = LC, type = ro, optional = yes; } diff --git a/cfg/apple2.cfg b/cfg/apple2.cfg index 8e63090f5..875103041 100644 --- a/cfg/apple2.cfg +++ b/cfg/apple2.cfg @@ -16,22 +16,22 @@ SYMBOLS { MEMORY { ZP: define = yes, start = $0080, size = $001A; HEADER: file = %O, start = $0000, size = $0004; - RAM: file = %O, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; + MAIN: file = %O, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; MOVE: file = %O, define = yes, start = $0000, size = $FFFF; LC: define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, define = yes; - BSS: load = RAM, type = bss, define = yes; - ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; + ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; + LC: load = MOVE, run = LC, type = ro, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/apple2enh-asm.cfg b/cfg/apple2enh-asm.cfg index e70ed4484..f7ede1bfe 100644 --- a/cfg/apple2enh-asm.cfg +++ b/cfg/apple2enh-asm.cfg @@ -9,12 +9,12 @@ SYMBOLS { } MEMORY { HEADER: file = %O, start = $0000, size = $0004; - RAM: file = %O, start = %S, size = $C000 - %S; + MAIN: file = %O, start = %S, size = $C000 - %S; } SEGMENTS { EXEHDR: load = HEADER, type = ro, optional = yes; - CODE: load = RAM, type = rw, optional = yes, define = yes; - RODATA: load = RAM, type = ro, optional = yes; - DATA: load = RAM, type = rw, optional = yes; - BSS: load = RAM, type = bss, optional = yes, define = yes; + CODE: load = MAIN, type = rw, optional = yes, define = yes; + RODATA: load = MAIN, type = ro, optional = yes; + DATA: load = MAIN, type = rw, optional = yes; + BSS: load = MAIN, type = bss, optional = yes, define = yes; } diff --git a/cfg/apple2enh-overlay.cfg b/cfg/apple2enh-overlay.cfg index ef9103b49..1e34b6250 100644 --- a/cfg/apple2enh-overlay.cfg +++ b/cfg/apple2enh-overlay.cfg @@ -24,7 +24,7 @@ SYMBOLS { MEMORY { ZP: define = yes, start = $0080, size = $001A; HEADER: file = %O, start = $0000, size = $0004; - RAM: file = %O, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __STACKSIZE__ - __OVERLAYSIZE__ - %S; + MAIN: file = %O, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __STACKSIZE__ - __OVERLAYSIZE__ - %S; MOVE: file = %O, define = yes, start = $0000, size = $FFFF; LC: define = yes, start = __LCADDR__, size = __LCSIZE__; OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; @@ -38,26 +38,26 @@ MEMORY { OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, define = yes; - BSS: load = RAM, type = bss, define = yes; - ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; - OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; - OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; - OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; - OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; - OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; - OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; - OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; - OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; - OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; + ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; + LC: load = MOVE, run = LC, type = ro, optional = yes; + OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; + OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; + OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; + OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; + OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; + OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; + OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; + OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; + OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/apple2enh-system.cfg b/cfg/apple2enh-system.cfg index 52cad960f..6134851f0 100644 --- a/cfg/apple2enh-system.cfg +++ b/cfg/apple2enh-system.cfg @@ -10,21 +10,21 @@ SYMBOLS { } MEMORY { ZP: define = yes, start = $0080, size = $001A; - RAM: file = %O, start = $2000, size = $9F00 - __STACKSIZE__; + MAIN: file = %O, start = $2000, size = $9F00 - __STACKSIZE__; MOVE: file = %O, define = yes, start = $0000, size = $FFFF; LC: define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, define = yes; - BSS: load = RAM, type = bss, define = yes; - ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; + ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; + ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; + LC: load = MOVE, run = LC, type = ro, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/apple2enh.cfg b/cfg/apple2enh.cfg index 8e63090f5..875103041 100644 --- a/cfg/apple2enh.cfg +++ b/cfg/apple2enh.cfg @@ -16,22 +16,22 @@ SYMBOLS { MEMORY { ZP: define = yes, start = $0080, size = $001A; HEADER: file = %O, start = $0000, size = $0004; - RAM: file = %O, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; + MAIN: file = %O, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; MOVE: file = %O, define = yes, start = $0000, size = $FFFF; LC: define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, define = yes; - BSS: load = RAM, type = bss, define = yes; - ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; + ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; + LC: load = MOVE, run = LC, type = ro, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/atari-asm.cfg b/cfg/atari-asm.cfg index 4ff7c3173..bea547765 100644 --- a/cfg/atari-asm.cfg +++ b/cfg/atari-asm.cfg @@ -2,29 +2,29 @@ FEATURES { STARTADDRESS: default = $2E00; } SYMBOLS { - __EXEHDR__: type = import; - __AUTOSTART__: type = import; # force inclusion of autostart "trailer" - __STARTADDRESS__: type = export, value = %S; + __EXEHDR__: type = import; + __AUTOSTART__: type = import; # force inclusion of autostart "trailer" + __STARTADDRESS__: type = export, value = %S; } MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # file header, just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - RAM: file = %O, define = yes, start = %S, size = $BC20 - %S; - TRAILER: file = %O, start = $0000, size = $0006; + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S, size = $BC20 - %S; + TRAILER: file = %O, start = $0000, size = $0006; } SEGMENTS { - EXEHDR: load = HEADER, type = ro, optional = yes; - MAINHDR: load = MAINHDR, type = ro, optional = yes; - CODE: load = RAM, type = ro, define = yes, optional = yes; - RODATA: load = RAM, type = ro optional = yes; - DATA: load = RAM, type = rw optional = yes; - BSS: load = RAM, type = bss, define = yes, optional = yes; - ZEROPAGE: load = ZP, type = zp, optional = yes; - EXTZP: load = ZP, type = zp, optional = yes; # to enable modules to be able to link to C and assembler programs - AUTOSTRT: load = TRAILER, type = ro, optional = yes; + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXTZP: load = ZP, type = zp, optional = yes; # to enable modules to be able to link to C and assembler programs + EXEHDR: load = HEADER, type = ro, optional = yes; + MAINHDR: load = MAINHDR, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes, optional = yes; + RODATA: load = MAIN, type = ro optional = yes; + DATA: load = MAIN, type = rw optional = yes; + BSS: load = MAIN, type = bss, define = yes, optional = yes; + AUTOSTRT: load = TRAILER, type = ro, optional = yes; } diff --git a/cfg/atari-cart.cfg b/cfg/atari-cart.cfg index 09bf86761..31d2cb1b9 100644 --- a/cfg/atari-cart.cfg +++ b/cfg/atari-cart.cfg @@ -10,23 +10,23 @@ SYMBOLS { __CARTFLAGS__: type = weak, value = $01; # see documentation for other possible values } MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; - RAM: file = "", define = yes, start = %S, size = __CARTSIZE__; - ROM: file = %O, define = yes, start = $C000 - __CARTSIZE__, size = __CARTSIZE__ - 6, fill = yes, fillval = $FF; - CARTID: file = %O, start = $BFFA, size = $0006; + ZP: file = "", define = yes, start = $0082, size = $007E; + MAIN: file = "", define = yes, start = %S, size = __CARTSIZE__; + ROM: file = %O, define = yes, start = $C000 - __CARTSIZE__, size = __CARTSIZE__ - 6, fill = yes, fillval = $FF; + CARTID: file = %O, start = $BFFA, size = $0006; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, optional = yes; - EXTZP: load = ZP, type = zp, optional = yes; - STARTUP: load = ROM, type = ro, define = yes, optional = yes; - LOWCODE: load = ROM, type = ro, define = yes, optional = yes; - ONCE: load = ROM, type = ro, optional = yes; - CODE: load = ROM, type = ro, define = yes; - RODATA: load = ROM, type = ro, optional = yes; - DATA: load = ROM, run = RAM, type = rw, define = yes, optional = yes; - INIT: load = RAM, type = bss, optional = yes; - BSS: load = RAM, type = bss, define = yes, optional = yes; - CARTHDR: load = CARTID, type = ro; + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXTZP: load = ZP, type = zp, optional = yes; + STARTUP: load = ROM, type = ro, define = yes, optional = yes; + LOWCODE: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; + CODE: load = ROM, type = ro, define = yes; + RODATA: load = ROM, type = ro, optional = yes; + DATA: load = ROM, run = MAIN, type = rw, define = yes, optional = yes; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes, optional = yes; + CARTHDR: load = CARTID, type = ro; } FEATURES { CONDES: type = constructor, diff --git a/cfg/atari-cassette.cfg b/cfg/atari-cassette.cfg index ad68bb8b4..b138b8f0e 100644 --- a/cfg/atari-cassette.cfg +++ b/cfg/atari-cassette.cfg @@ -8,21 +8,21 @@ SYMBOLS { _cas_hdr: type = import; } MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; - RAM: file = %O, define = yes, start = %S, size = $BC20 - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; + ZP: file = "", define = yes, start = $0082, size = $007E; + MAIN: file = %O, define = yes, start = %S, size = $BC20 - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, optional = yes; - EXTZP: load = ZP, type = zp, optional = yes; - CASHDR: load = RAM, type = ro; - STARTUP: load = RAM, type = ro, define = yes, optional = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro, optional = yes; - DATA: load = RAM, type = rw, optional = yes; - INIT: load = RAM, type = bss, optional = yes; - BSS: load = RAM, type = bss, define = yes, optional = yes; + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXTZP: load = ZP, type = zp, optional = yes; + CASHDR: load = MAIN, type = ro; + STARTUP: load = MAIN, type = ro, define = yes, optional = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro, optional = yes; + DATA: load = MAIN, type = rw, optional = yes; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/atari-overlay.cfg b/cfg/atari-overlay.cfg index b14a93a39..1dec49b7d 100644 --- a/cfg/atari-overlay.cfg +++ b/cfg/atari-overlay.cfg @@ -11,31 +11,31 @@ SYMBOLS { __RESERVED_MEMORY__: type = weak, value = $0000; } MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # file header, just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "system check" load chunk - SYSCHKHDR: file = %O, start = $0000, size = $0004; - SYSCHKCHNK: file = %O, start = $2E00, size = $0300; - SYSCHKTRL: file = %O, start = $0000, size = $0006; + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - RAM: file = %O, define = yes, start = %S + __OVERLAYSIZE__, + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = $BC20 - __OVERLAYSIZE__ - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; - TRAILER: file = %O, start = $0000, size = $0006; + TRAILER: file = %O, start = $0000, size = $0006; - OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; - OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; - OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; - OVL4: file = "%O.4", start = %S, size = __OVERLAYSIZE__; - OVL5: file = "%O.5", start = %S, size = __OVERLAYSIZE__; - OVL6: file = "%O.6", start = %S, size = __OVERLAYSIZE__; - OVL7: file = "%O.7", start = %S, size = __OVERLAYSIZE__; - OVL8: file = "%O.8", start = %S, size = __OVERLAYSIZE__; - OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; + OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; + OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; + OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; + OVL4: file = "%O.4", start = %S, size = __OVERLAYSIZE__; + OVL5: file = "%O.5", start = %S, size = __OVERLAYSIZE__; + OVL6: file = "%O.6", start = %S, size = __OVERLAYSIZE__; + OVL7: file = "%O.7", start = %S, size = __OVERLAYSIZE__; + OVL8: file = "%O.8", start = %S, size = __OVERLAYSIZE__; + OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; @@ -45,14 +45,14 @@ SEGMENTS { SYSCHK: load = SYSCHKCHNK, type = rw, define = yes, optional = yes; SYSCHKTRL: load = SYSCHKTRL, type = ro, optional = yes; MAINHDR: load = MAINHDR, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, optional = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; diff --git a/cfg/atari.cfg b/cfg/atari.cfg index 7460a0f66..959a07e4c 100644 --- a/cfg/atari.cfg +++ b/cfg/atari.cfg @@ -10,20 +10,20 @@ SYMBOLS { __RESERVED_MEMORY__: type = weak, value = $0000; } MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # file header, just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "system check" load chunk - SYSCHKHDR: file = %O, start = $0000, size = $0004; - SYSCHKCHNK: file = %O, start = $2E00, size = $0300; - SYSCHKTRL: file = %O, start = $0000, size = $0006; + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - RAM: file = %O, define = yes, start = %S, size = $BC20 - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; - TRAILER: file = %O, start = $0000, size = $0006; + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S, size = $BC20 - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; + TRAILER: file = %O, start = $0000, size = $0006; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; @@ -33,14 +33,14 @@ SEGMENTS { SYSCHK: load = SYSCHKCHNK, type = rw, define = yes, optional = yes; SYSCHKTRL: load = SYSCHKTRL, type = ro, optional = yes; MAINHDR: load = MAINHDR, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, optional = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; } FEATURES { diff --git a/cfg/atarixl-largehimem.cfg b/cfg/atarixl-largehimem.cfg index a1ec5cf08..94405fce2 100644 --- a/cfg/atarixl-largehimem.cfg +++ b/cfg/atarixl-largehimem.cfg @@ -8,45 +8,45 @@ FEATURES { } SYMBOLS { - __EXEHDR__: type = import; - __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk - __AUTOSTART__: type = import; # force inclusion of autostart "trailer" - __STACKSIZE__: type = weak, value = $0800; # 2k stack - __STARTADDRESS__: type = export, value = %S; + __EXEHDR__: type = import; + __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk + __AUTOSTART__: type = import; # force inclusion of autostart "trailer" + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STARTADDRESS__: type = export, value = %S; } MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "system check" load chunk - SYSCHKHDR: file = %O, start = $0000, size = $0004; - SYSCHKCHNK: file = %O, start = $2E00, size = $0300; - SYSCHKTRL: file = %O, start = $0000, size = $0006; + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; # "shadow RAM preparation" load chunk - SRPREPHDR: file = %O, start = $0000, size = $0004; - SRPREPCHNK: file = %O, define = yes, start = %S, size = $7C20 - %S - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned - SRPREPTRL: file = %O, start = $0000, size = $0006; + SRPREPHDR: file = %O, start = $0000, size = $0004; + SRPREPCHNK: file = %O, define = yes, start = %S, size = $7C20 - %S - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned + SRPREPTRL: file = %O, start = $0000, size = $0006; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - RAM: file = %O, define = yes, start = %S + - __LOWBSS_SIZE__, size = $D000 - - __STACKSIZE__ - - %S - - __LOWBSS_SIZE__; + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S + + __LOWBSS_SIZE__, size = $D000 - + __STACKSIZE__ - + %S - + __LOWBSS_SIZE__; # defines entry point into program - TRAILER: file = %O, start = $0000, size = $0006; + TRAILER: file = %O, start = $0000, size = $0006; # address of relocated character generator - CHARGEN: file = "", define = yes, start = $D800, size = $0400; + CHARGEN: file = "", define = yes, start = $D800, size = $0400; # memory beneath the ROM - HIDDEN_RAM: file = "", define = yes, start = $DC00, size = $FFFA - $DC00; + HIDDEN_RAM: file = "", define = yes, start = $DC00, size = $FFFA - $DC00; } SEGMENTS { @@ -67,14 +67,14 @@ SEGMENTS { SRPREPTRL: load = SRPREPTRL, type = ro; MAINHDR: load = MAINHDR, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, optional = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; } FEATURES { diff --git a/cfg/atarixl-overlay.cfg b/cfg/atarixl-overlay.cfg index b0b4f3b88..89240170b 100644 --- a/cfg/atarixl-overlay.cfg +++ b/cfg/atarixl-overlay.cfg @@ -3,62 +3,62 @@ FEATURES { } SYMBOLS { - __EXEHDR__: type = import; - __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk - __AUTOSTART__: type = import; # force inclusion of autostart "trailer" - __STACKSIZE__: type = weak, value = $0800; # 2k stack - __OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay - __STARTADDRESS__: type = export, value = %S; + __EXEHDR__: type = import; + __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk + __AUTOSTART__: type = import; # force inclusion of autostart "trailer" + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay + __STARTADDRESS__: type = export, value = %S; } MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "system check" load chunk - SYSCHKHDR: file = %O, start = $0000, size = $0004; - SYSCHKCHNK: file = %O, start = $2E00, size = $0300; - SYSCHKTRL: file = %O, start = $0000, size = $0006; + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; # "shadow RAM preparation" load chunk - SRPREPHDR: file = %O, start = $0000, size = $0004; - SRPREPCHNK: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = $7C20 - %S - __OVERLAYSIZE__ - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned - SRPREPTRL: file = %O, start = $0000, size = $0006; + SRPREPHDR: file = %O, start = $0000, size = $0004; + SRPREPCHNK: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = $7C20 - %S - __OVERLAYSIZE__ - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned + SRPREPTRL: file = %O, start = $0000, size = $0006; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - RAM: file = %O, define = yes, start = %S + - __OVERLAYSIZE__ + - __LOWBSS_SIZE__, size = $D000 - - __STACKSIZE__ - - %S - - __OVERLAYSIZE__ - - __LOWBSS_SIZE__; + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S + + __OVERLAYSIZE__ + + __LOWBSS_SIZE__, size = $D000 - + __STACKSIZE__ - + %S - + __OVERLAYSIZE__ - + __LOWBSS_SIZE__; # defines entry point into program - TRAILER: file = %O, start = $0000, size = $0006; + TRAILER: file = %O, start = $0000, size = $0006; # memory beneath the ROM preceeding the character generator - HIDDEN_RAM2: file = "", define = yes, start = $D800, size = $0800; + HIDDEN_RAM2: file = "", define = yes, start = $D800, size = $0800; # address of relocated character generator (same addess as ROM version) - CHARGEN: file = "", define = yes, start = $E000, size = $0400; + CHARGEN: file = "", define = yes, start = $E000, size = $0400; # memory beneath the ROM - HIDDEN_RAM: file = "", define = yes, start = $E400, size = $FFFA - $E400; + HIDDEN_RAM: file = "", define = yes, start = $E400, size = $FFFA - $E400; # overlays - OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; - OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; - OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; - OVL4: file = "%O.4", start = %S, size = __OVERLAYSIZE__; - OVL5: file = "%O.5", start = %S, size = __OVERLAYSIZE__; - OVL6: file = "%O.6", start = %S, size = __OVERLAYSIZE__; - OVL7: file = "%O.7", start = %S, size = __OVERLAYSIZE__; - OVL8: file = "%O.8", start = %S, size = __OVERLAYSIZE__; - OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; + OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; + OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; + OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; + OVL4: file = "%O.4", start = %S, size = __OVERLAYSIZE__; + OVL5: file = "%O.5", start = %S, size = __OVERLAYSIZE__; + OVL6: file = "%O.6", start = %S, size = __OVERLAYSIZE__; + OVL7: file = "%O.7", start = %S, size = __OVERLAYSIZE__; + OVL8: file = "%O.8", start = %S, size = __OVERLAYSIZE__; + OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; } SEGMENTS { @@ -79,14 +79,14 @@ SEGMENTS { SRPREPTRL: load = SRPREPTRL, type = ro; MAINHDR: load = MAINHDR, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, optional = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; diff --git a/cfg/atarixl.cfg b/cfg/atarixl.cfg index 2f9523c59..9573fc78c 100644 --- a/cfg/atarixl.cfg +++ b/cfg/atarixl.cfg @@ -3,48 +3,48 @@ FEATURES { } SYMBOLS { - __EXEHDR__: type = import; - __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk - __AUTOSTART__: type = import; # force inclusion of autostart "trailer" - __STACKSIZE__: type = weak, value = $0800; # 2k stack - __STARTADDRESS__: type = export, value = %S; + __EXEHDR__: type = import; + __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk + __AUTOSTART__: type = import; # force inclusion of autostart "trailer" + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STARTADDRESS__: type = export, value = %S; } MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "system check" load chunk - SYSCHKHDR: file = %O, start = $0000, size = $0004; - SYSCHKCHNK: file = %O, start = $2E00, size = $0300; - SYSCHKTRL: file = %O, start = $0000, size = $0006; + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; # "shadow RAM preparation" load chunk - SRPREPHDR: file = %O, start = $0000, size = $0004; - SRPREPCHNK: file = %O, define = yes, start = %S, size = $7C20 - %S - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned - SRPREPTRL: file = %O, start = $0000, size = $0006; + SRPREPHDR: file = %O, start = $0000, size = $0004; + SRPREPCHNK: file = %O, define = yes, start = %S, size = $7C20 - %S - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned + SRPREPTRL: file = %O, start = $0000, size = $0006; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - RAM: file = %O, define = yes, start = %S + - __LOWBSS_SIZE__, size = $D000 - - __STACKSIZE__ - - %S - - __LOWBSS_SIZE__; + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S + + __LOWBSS_SIZE__, size = $D000 - + __STACKSIZE__ - + %S - + __LOWBSS_SIZE__; # defines entry point into program - TRAILER: file = %O, start = $0000, size = $0006; + TRAILER: file = %O, start = $0000, size = $0006; # memory beneath the ROM preceeding the character generator - HIDDEN_RAM2: file = "", define = yes, start = $D800, size = $0800; + HIDDEN_RAM2: file = "", define = yes, start = $D800, size = $0800; # address of relocated character generator (same addess as ROM version) - CHARGEN: file = "", define = yes, start = $E000, size = $0400; + CHARGEN: file = "", define = yes, start = $E000, size = $0400; # memory beneath the ROM - HIDDEN_RAM: file = "", define = yes, start = $E400, size = $FFFA - $E400; + HIDDEN_RAM: file = "", define = yes, start = $E400, size = $FFFA - $E400; } SEGMENTS { @@ -65,14 +65,14 @@ SEGMENTS { SRPREPTRL: load = SRPREPTRL, type = ro; MAINHDR: load = MAINHDR, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss, optional = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; } FEATURES { diff --git a/cfg/atmos.cfg b/cfg/atmos.cfg index a0f7e1c3d..e5a574f0a 100644 --- a/cfg/atmos.cfg +++ b/cfg/atmos.cfg @@ -11,21 +11,21 @@ MEMORY { ZP: file = "", define = yes, start = $00E2, size = $001A; TAPEHDR: file = %O, type = ro, start = $0000, size = $001F; BASHEAD: file = %O, define = yes, start = $0501, size = $000D; - RAM: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __RAM_START__ - __STACKSIZE__; + MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __RAM_START__ - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; TAPEHDR: load = TAPEHDR, type = ro; BASHDR: load = BASHEAD, type = ro, define = yes, optional = yes; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - DATA: load = RAM, type = rw; - ZPSAVE1: load = RAM, type = rw, define = yes; # ZPSAVE1, ZPSAVE2 must be together - ZPSAVE2: load = RAM, type = bss; # see "libsrc/atmos/crt0.s" - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + DATA: load = MAIN, type = rw; + ZPSAVE1: load = MAIN, type = rw, define = yes; # ZPSAVE1, ZPSAVE2 must be together + ZPSAVE2: load = MAIN, type = bss; # see "libsrc/atmos/crt0.s" + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/bbc.cfg b/cfg/bbc.cfg index 98779b6fd..c451951ad 100644 --- a/cfg/bbc.cfg +++ b/cfg/bbc.cfg @@ -2,18 +2,18 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack } MEMORY { - ZP: file = "", define = yes, start = $0070, size = $0020; - RAM: file = %O, start = $0E00, size = $7200 - __STACKSIZE__; + ZP: file = "", define = yes, start = $0070, size = $0020; + MAIN: file = %O, start = $0E00, size = $7200 - __STACKSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/c128-overlay.cfg b/cfg/c128-overlay.cfg index 771bd290b..8f60fa347 100644 --- a/cfg/c128-overlay.cfg +++ b/cfg/c128-overlay.cfg @@ -9,7 +9,7 @@ MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; LOADADDR: file = %O, start = $1BFF, size = $0002; HEADER: file = %O, start = $1C01, size = $000C; - RAM: file = %O, define = yes, start = $1C0D, size = $A3F3 - __OVERLAYSIZE__ - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $1C0D, size = $A3F3 - __OVERLAYSIZE__ - __STACKSIZE__; OVL1ADDR: file = "%O.1", start = $BFFE - __OVERLAYSIZE__, size = $0002; OVL1: file = "%O.1", start = $C000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__; OVL2ADDR: file = "%O.2", start = $BFFE - __OVERLAYSIZE__, size = $0002; @@ -33,14 +33,14 @@ SEGMENTS { ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss; + BSS: load = MAIN, type = bss, define = yes; OVL1ADDR: load = OVL1ADDR, type = ro; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; OVL2ADDR: load = OVL2ADDR, type = ro; diff --git a/cfg/c128.cfg b/cfg/c128.cfg index 0ea6066ad..6a98dc5cf 100644 --- a/cfg/c128.cfg +++ b/cfg/c128.cfg @@ -7,20 +7,20 @@ MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; LOADADDR: file = %O, start = $1BFF, size = $0002; HEADER: file = %O, start = $1C01, size = $000C; - RAM: file = %O, define = yes, start = $1C0D, size = $A3F3 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $1C0D, size = $A3F3 - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/c16.cfg b/cfg/c16.cfg index b4b5ccaf7..f1ab747cd 100644 --- a/cfg/c16.cfg +++ b/cfg/c16.cfg @@ -7,20 +7,20 @@ MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; LOADADDR: file = %O, start = $0FFF, size = $0002; HEADER: file = %O, start = $1001, size = $000C; - RAM: file = %O, start = $100D, size = $6FF3 - __STACKSIZE__; + MAIN: file = %O, start = $100D, size = $6FF3 - __STACKSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; + ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/c64-asm.cfg b/cfg/c64-asm.cfg index 1ab80be8e..224bd704a 100644 --- a/cfg/c64-asm.cfg +++ b/cfg/c64-asm.cfg @@ -7,14 +7,14 @@ SYMBOLS { MEMORY { ZP: file = "", start = $0002, size = $001A, define = yes; LOADADDR: file = %O, start = %S - 2, size = $0002; - RAM: file = %O, start = %S, size = $D000 - %S; + MAIN: file = %O, start = %S, size = $D000 - %S; } SEGMENTS { LOADADDR: load = LOADADDR, type = ro; - EXEHDR: load = RAM, type = ro, optional = yes; - CODE: load = RAM, type = rw, optional = yes; - RODATA: load = RAM, type = ro, optional = yes; - DATA: load = RAM, type = rw, optional = yes; - BSS: load = RAM, type = bss, optional = yes; + EXEHDR: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = rw, optional = yes; + RODATA: load = MAIN, type = ro, optional = yes; + DATA: load = MAIN, type = rw, optional = yes; + BSS: load = MAIN, type = bss, optional = yes; ZEROPAGE: load = ZP, type = zp, optional = yes; } diff --git a/cfg/cbm510.cfg b/cfg/cbm510.cfg index 8b01dff0b..5f73174f3 100644 --- a/cfg/cbm510.cfg +++ b/cfg/cbm510.cfg @@ -8,24 +8,24 @@ MEMORY { STARTUP: file = %O, start = $00FE, size = $0102, fill = yes; PAGE2: file = %O, start = $0200, size = $0100, fill = yes; PAGE3: file = %O, start = $0300, size = $0100, fill = yes; - RAM: file = %O, start = $0400, size = $DC00; + MAIN: file = %O, start = $0400, size = $DC00; CHARRAM: file = "", define = yes, start = $E000, size = $1000; VIDRAM: file = "", define = yes, start = $F000, size = $0400; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = rw, define = yes; EXEHDR: load = HEADER, type = rw; STARTUP: load = STARTUP, type = rw; PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = rw, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/cbm610.cfg b/cfg/cbm610.cfg index 6df9f1f5a..fb4349dba 100644 --- a/cfg/cbm610.cfg +++ b/cfg/cbm610.cfg @@ -7,22 +7,22 @@ MEMORY { STARTUP: file = %O, start = $00FE, size = $0102, fill = yes; PAGE2: file = %O, start = $0200, size = $0100, fill = yes; PAGE3: file = %O, start = $0300, size = $0100, fill = yes; - RAM: file = %O, start = $0400, size = $FECB - __STACKSIZE__; + MAIN: file = %O, start = $0400, size = $FECB - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = rw, define = yes; EXEHDR: load = HEADER, type = rw; STARTUP: load = STARTUP, type = rw; PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = rw, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/gamate.cfg b/cfg/gamate.cfg index f0f669f27..4e4253194 100644 --- a/cfg/gamate.cfg +++ b/cfg/gamate.cfg @@ -9,17 +9,17 @@ MEMORY { # 0000-03ff is RAM # FIXME: what zp range can we actually use? # $0a-$11 is used by IRQ/NMI, $e8 is used by NMI - ZP: start = $0012, size = $e8 - $12; - CPUSTACK: start = $0100, size =$100; - RAM: start = $0200, size = $200 - __STACKSIZE__, define = yes; + ZP: start = $0012, size = $00E8 - $0012; + CPUSTACK: start = $0100, size = $0100; + RAM: start = $0200, size = $0200 - __STACKSIZE__, define = yes; - CARTHEADER: file = %O, define = yes, start = %S, size = $0029; + CARTHEADER: file = %O, define = yes, start = %S, size = $0029; # 6000-e000 can be (Cartridge) ROM # WARNING: fill value must be $00 else it will no more work - #ROM: start = $6000, size = $1000, fill = yes, fillval = $00, file = %O, define = yes; - #ROMFILL: start = $7000, size = $7000, fill = yes, fillval = $00, file = %O, define = yes; + #ROM: start = $6000, size = $1000, fill = yes, fillval = $00, file = %O, define = yes; + #ROMFILL: start = $7000, size = $7000, fill = yes, fillval = $00, file = %O, define = yes; # for images that have code >$6fff we must calculate the checksum! - ROM: start = $6000 + $29, size = $8000 - $29, fill = yes, fillval = $00, file = %O, define = yes; + ROM: start = $6000 + $0029, size = $8000 - $0029, fill = yes, fillval = $00, file = %O, define = yes; } SEGMENTS { diff --git a/cfg/lunix.cfg b/cfg/lunix.cfg index aabacbeb2..3a11cc5d4 100644 --- a/cfg/lunix.cfg +++ b/cfg/lunix.cfg @@ -5,18 +5,18 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0400; # 1k stack (do typical LUnix apps. need 2k?) } MEMORY { - ZP: start = $0080, size = $0040; - RAM: start = %S, size = $7600 - __STACKSIZE__; + ZP: start = $0080, size = $0040; + MAIN: start = %S, size = $7600 - __STACKSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; # Pseudo-registers - STARTUP: load = RAM, type = ro; # First initialization code - LOWCODE: load = RAM, type = ro, optional = yes; # Legacy from other platforms - ONCE: load = RAM, type = ro, define = yes, optional = yes; # Library initialization code - CODE: load = RAM, type = ro; # Program - RODATA: load = RAM, type = ro; # Literals, constants - DATA: load = RAM, type = rw; # Initialized variables - BSS: load = RAM, type = bss, define = yes; # Uninitialized variables + ZEROPAGE: load = ZP, type = zp, define = yes; # Pseudo-registers + STARTUP: load = MAIN, type = ro; # First initialization code + LOWCODE: load = MAIN, type = ro, optional = yes; # Legacy from other platforms + ONCE: load = MAIN, type = ro, define = yes, optional = yes; # Library initialization code + CODE: load = MAIN, type = ro; # Program + RODATA: load = MAIN, type = ro; # Literals, constants + DATA: load = MAIN, type = rw; # Initialized variables + BSS: load = MAIN, type = bss, define = yes; # Uninitialized variables } FEATURES { CONDES: type = constructor, diff --git a/cfg/lynx-bll.cfg b/cfg/lynx-bll.cfg index fcf6d4c60..a1687b423 100644 --- a/cfg/lynx-bll.cfg +++ b/cfg/lynx-bll.cfg @@ -7,20 +7,20 @@ SYMBOLS { MEMORY { ZP: file = "", define = yes, start = $0000, size = $0100; HEADER: file = %O, start = $0000, size = $000a; - RAM: file = %O, define = yes, start = $0400, size = $BC38 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $0400, size = $BC38 - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = zp, optional = yes; APPZP: load = ZP, type = zp, optional = yes; BLLHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro, define = yes; - DATA: load = RAM, type = rw, define = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro, define = yes; + DATA: load = MAIN, type = rw, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/lynx-coll.cfg b/cfg/lynx-coll.cfg index d40c18237..9467c3c92 100644 --- a/cfg/lynx-coll.cfg +++ b/cfg/lynx-coll.cfg @@ -11,7 +11,7 @@ MEMORY { HEADER: file = %O, start = $0000, size = $0040; BOOT: file = %O, start = $0200, size = __STARTOFDIRECTORY__; DIR: file = %O, start = $0000, size = 8; - RAM: file = %O, define = yes, start = $0200, size = $9E58 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $0200, size = $9E58 - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; @@ -20,13 +20,13 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; BOOTLDR: load = BOOT, type = ro; DIRECTORY: load = DIR, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro, define = yes; - DATA: load = RAM, type = rw, define = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro, define = yes; + DATA: load = MAIN, type = rw, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/lynx-uploader.cfg b/cfg/lynx-uploader.cfg index fe6d6133d..c32e3583f 100644 --- a/cfg/lynx-uploader.cfg +++ b/cfg/lynx-uploader.cfg @@ -12,7 +12,7 @@ MEMORY { HEADER: file = %O, start = $0000, size = $0040; BOOT: file = %O, start = $0200, size = __STARTOFDIRECTORY__; DIR: file = %O, start = $0000, size = 8; - RAM: file = %O, define = yes, start = $0200, size = $BD38 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $0200, size = $BD38 - __STACKSIZE__; UPLDR: file = %O, define = yes, start = $BFDC, size = $005C; } SEGMENTS { @@ -22,13 +22,13 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; BOOTLDR: load = BOOT, type = ro; DIRECTORY:load = DIR, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro, define = yes; - DATA: load = RAM, type = rw, define = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro, define = yes; + DATA: load = MAIN, type = rw, define = yes; + BSS: load = MAIN, type = bss, define = yes; UPCODE: load = UPLDR, type = ro, define = yes; UPDATA: load = UPLDR, type = rw, define = yes; } diff --git a/cfg/lynx.cfg b/cfg/lynx.cfg index 4d41c1bbf..5140b342f 100644 --- a/cfg/lynx.cfg +++ b/cfg/lynx.cfg @@ -11,7 +11,7 @@ MEMORY { HEADER: file = %O, start = $0000, size = $0040; BOOT: file = %O, start = $0200, size = __STARTOFDIRECTORY__; DIR: file = %O, start = $0000, size = 8; - RAM: file = %O, define = yes, start = $0200, size = $BE38 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $0200, size = $BE38 - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; @@ -20,13 +20,13 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; BOOTLDR: load = BOOT, type = ro; DIRECTORY: load = DIR, type = ro; - STARTUP: load = RAM, type = ro, define = yes; - LOWCODE: load = RAM, type = ro, define = yes, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro, define = yes; - RODATA: load = RAM, type = ro, define = yes; - DATA: load = RAM, type = rw, define = yes; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro, define = yes; + RODATA: load = MAIN, type = ro, define = yes; + DATA: load = MAIN, type = rw, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/none.cfg b/cfg/none.cfg index 54ae54eb4..dcee60419 100644 --- a/cfg/none.cfg +++ b/cfg/none.cfg @@ -2,17 +2,17 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack } MEMORY { - ZP: file = "", define = yes, start = $0000, size = $0001F; - RAM: file = %O, start = %S, size = $10000 - __STACKSIZE__; + ZP: file = "", define = yes, start = $0000, size = $0001F; + MAIN: file = %O, start = %S, size = $10000 - __STACKSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = rw; - RODATA: load = RAM, type = rw; - DATA: load = RAM, type = rw; - BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = rw; + RODATA: load = MAIN, type = rw; + DATA: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/osic1p-asm.cfg b/cfg/osic1p-asm.cfg index ac2e76dc9..3c1b1bda3 100644 --- a/cfg/osic1p-asm.cfg +++ b/cfg/osic1p-asm.cfg @@ -10,16 +10,16 @@ SYMBOLS { } MEMORY { # for size of ZP, see runtime/zeropage.s and c1p/extzp.s - ZP: file = "", define = yes, start = $0002, size = $001A + $0006; - HEAD: file = %O, start = $0000, size = $00B6; - RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; + ZP: file = "", define = yes, start = $0002, size = $001A + $0006; + HEAD: file = %O, start = $0000, size = $00B6; + MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; BOOT: load = HEAD, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = rw; - RODATA: load = RAM, type = rw; - DATA: load = RAM, type = rw; - BSS: load = RAM, type = bss, define = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = rw; + RODATA: load = MAIN, type = rw; + DATA: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes; } diff --git a/cfg/osic1p.cfg b/cfg/osic1p.cfg index 314eac0b9..3507ebeba 100644 --- a/cfg/osic1p.cfg +++ b/cfg/osic1p.cfg @@ -10,21 +10,21 @@ SYMBOLS { } MEMORY { # for size of ZP, see runtime/zeropage.s and c1p/extzp.s - ZP: file = "", define = yes, start = $0002, size = $001A + $0020; - HEAD: file = %O, start = $0000, size = $00B6; - RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; + ZP: file = "", define = yes, start = $0002, size = $001A + $0020; + HEAD: file = %O, start = $0000, size = $00B6; + MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = zp, define = yes, optional = yes; BOOT: load = HEAD, type = ro, optional = yes; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = rw; - RODATA: load = RAM, type = rw; - DATA: load = RAM, type = rw; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = rw; + RODATA: load = MAIN, type = rw; + DATA: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/plus4.cfg b/cfg/plus4.cfg index 16e9d12c8..4f73e40c2 100644 --- a/cfg/plus4.cfg +++ b/cfg/plus4.cfg @@ -7,20 +7,20 @@ MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; LOADADDR: file = %O, start = $0FFF, size = $0002; HEADER: file = %O, start = $1001, size = $000C; - RAM: file = %O, define = yes, start = $100D, size = $ECF3 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $100D, size = $ECF3 - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/sim6502.cfg b/cfg/sim6502.cfg index 8e78fceb2..b50703bab 100644 --- a/cfg/sim6502.cfg +++ b/cfg/sim6502.cfg @@ -5,18 +5,18 @@ SYMBOLS { MEMORY { ZP: file = "", start = $0000, size = $001A; HEADER: file = %O, start = $0000, size = $0001; - RAM: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/sim65c02.cfg b/cfg/sim65c02.cfg index 8e78fceb2..b50703bab 100644 --- a/cfg/sim65c02.cfg +++ b/cfg/sim65c02.cfg @@ -5,18 +5,18 @@ SYMBOLS { MEMORY { ZP: file = "", start = $0000, size = $001A; HEADER: file = %O, start = $0000, size = $0001; - RAM: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/vic20-32k.cfg b/cfg/vic20-32k.cfg index a1b609106..4f4225825 100644 --- a/cfg/vic20-32k.cfg +++ b/cfg/vic20-32k.cfg @@ -9,20 +9,20 @@ MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; LOADADDR: file = %O, start = $11FF, size = $0002; HEADER: file = %O, start = $1201, size = $000C; - RAM: file = %O, define = yes, start = $120D, size = $6DF3 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $120D, size = $6DF3 - __STACKSIZE__; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/vic20.cfg b/cfg/vic20.cfg index 693b356a3..4eba7bfa9 100644 --- a/cfg/vic20.cfg +++ b/cfg/vic20.cfg @@ -7,20 +7,20 @@ MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; LOADADDR: file = %O, start = $0FFF, size = $0002; HEADER: file = %O, start = $1001, size = $000C; - RAM: file = %O, define = yes, start = $100D, size = $0DF3 - __STACKSIZE__; + MAIN: file = %O, define = yes, start = $100D, size = $0DF3 - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - INIT: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, define = yes, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/doc/atari.sgml b/doc/atari.sgml index f37b43929..2087a8541 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -148,7 +148,7 @@ Special locations: ($58). <tag/Stack/ - The C runtime stack is located at end of the RAM memory area ($CFFF) + The C runtime stack is located at end of the MAIN memory area ($CFFF) and grows downwards. <tag/Heap/ @@ -561,7 +561,7 @@ The contents of this chunk come from the SYSCHKCHNK memory area of the linker co <item>main program&nl; This load chunk is loaded at the selected program start address (default $2000) and contains all of the code and data of the program.&nl; -The contents of this chunk come from the RAM memory area of the linker config file. +The contents of this chunk come from the MAIN memory area of the linker config file. </enum> diff --git a/libsrc/atari/crt0.s b/libsrc/atari/crt0.s index 0ea6e390f..317fe5697 100644 --- a/libsrc/atari/crt0.s +++ b/libsrc/atari/crt0.s @@ -14,7 +14,7 @@ .import initlib, donelib .import callmain, zerobss .import __RESERVED_MEMORY__ - .import __RAM_START__, __RAM_SIZE__ + .import __MAIN_START__, __MAIN_SIZE__ .ifdef __ATARIXL__ .import __STACKSIZE__ .import sram_init @@ -55,10 +55,10 @@ start: .ifdef __ATARIXL__ - lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - sta sp+1 + stx sp+1 .else diff --git a/libsrc/atari/exehdr.s b/libsrc/atari/exehdr.s index ea9fa95d7..7abb7c1ac 100644 --- a/libsrc/atari/exehdr.s +++ b/libsrc/atari/exehdr.s @@ -1,11 +1,11 @@ ; This file defines the EXE header and main chunk load header for Atari executables .export __EXEHDR__: absolute = 1 - .import __RAM_START__, __BSS_LOAD__ + .import __MAIN_START__, __BSS_LOAD__ .segment "EXEHDR" .word $FFFF .segment "MAINHDR" - .word __RAM_START__ + .word __MAIN_START__ .word __BSS_LOAD__ - 1 diff --git a/libsrc/atmos/crt0.s b/libsrc/atmos/crt0.s index e789b28c2..6ad7a3ff3 100644 --- a/libsrc/atmos/crt0.s +++ b/libsrc/atmos/crt0.s @@ -9,7 +9,7 @@ .export __STARTUP__ : absolute = 1 ; Mark as startup .import initlib, donelib .import callmain, zerobss - .import __RAM_START__, __RAM_SIZE__, __STACKSIZE__ + .import __MAIN_START__, __MAIN_SIZE__, __STACKSIZE__ .include "zeropage.inc" .include "atmos.inc" @@ -44,10 +44,10 @@ L1: lda sp,x tsx stx spsave ; Save system stk ptr - lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - sta sp+1 ; Set argument stack ptr + stx sp+1 ; Set argument stack ptr ; Call the module constructors. diff --git a/libsrc/c128/crt0.s b/libsrc/c128/crt0.s index 5891bacf3..ba6a78ac5 100644 --- a/libsrc/c128/crt0.s +++ b/libsrc/c128/crt0.s @@ -8,7 +8,7 @@ .import zerobss .import push0, callmain .import RESTOR, BSOUT, CLRCH - .import __RAM_START__, __RAM_SIZE__, __STACKSIZE__ + .import __MAIN_START__, __MAIN_SIZE__, __STACKSIZE__ .importzp ST .include "zeropage.inc" @@ -56,10 +56,10 @@ L1: lda sp,x tsx stx spsave ; Save the system stack pointer - lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - sta sp+1 ; Set argument stack ptr + stx sp+1 ; Set argument stack ptr ; Call the module constructors. diff --git a/libsrc/gamate/crt0.s b/libsrc/gamate/crt0.s index ead45b7ea..99af9b2d9 100644 --- a/libsrc/gamate/crt0.s +++ b/libsrc/gamate/crt0.s @@ -33,16 +33,16 @@ Start: ; setup the stack lda #<(__RAM_START__+__RAM_SIZE__) + ldx #>(__RAM_START__+__RAM_SIZE__) sta sp - lda #>(__RAM_START__+__RAM_SIZE__) - sta sp + 1 + stx sp + 1 ; Call module constructors jsr initlib lda #1 sta ZP_IRQ_CTRL ; enable calling cartridge IRQ/NMI handler - cli ; allow IRQ only after constructors have run + cli ; allow IRQ only after constructors have run ; Pass an empty command line jsr push0 ; argc diff --git a/libsrc/lynx/bllhdr.s b/libsrc/lynx/bllhdr.s index 60fc87725..07ed06ffb 100644 --- a/libsrc/lynx/bllhdr.s +++ b/libsrc/lynx/bllhdr.s @@ -4,7 +4,7 @@ ; This header is required for BLL builds. ; .import __BSS_LOAD__ - .import __RAM_START__ + .import __MAIN_START__ .export __BLLHDR__: absolute = 1 ; ------------------------------------------------------------------------ @@ -12,8 +12,7 @@ .segment "BLLHDR" .word $0880 - .dbyt __RAM_START__ - .dbyt __BSS_LOAD__ - __RAM_START__ + 10 + .dbyt __MAIN_START__ + .dbyt __BSS_LOAD__ - __MAIN_START__ + 10 .byte $42,$53 .byte $39,$33 - diff --git a/libsrc/lynx/crt0.s b/libsrc/lynx/crt0.s index 725f74ebd..c924f742f 100644 --- a/libsrc/lynx/crt0.s +++ b/libsrc/lynx/crt0.s @@ -22,7 +22,7 @@ .import zerobss .import callmain .import _main - .import __RAM_START__, __RAM_SIZE__, __STACKSIZE__ + .import __MAIN_START__, __MAIN_SIZE__, __STACKSIZE__ .include "zeropage.inc" .include "extzp.inc" @@ -79,10 +79,10 @@ MikeyInitData: .byte $9e,$18,$68,$1f,$00,$00,$00,$00,$00,$ff,$1a,$1b,$04,$0d,$2 ; Set up the stack. - lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - sta sp+1 + stx sp+1 ; Init Mickey. diff --git a/libsrc/lynx/defdir.s b/libsrc/lynx/defdir.s index a36848227..2930edf4b 100644 --- a/libsrc/lynx/defdir.s +++ b/libsrc/lynx/defdir.s @@ -5,7 +5,7 @@ ; .include "lynx.inc" .import __STARTOFDIRECTORY__ - .import __RAM_START__ + .import __MAIN_START__ .import __CODE_SIZE__, __DATA_SIZE__, __RODATA_SIZE__ .import __STARTUP_SIZE__, __ONCE_SIZE__, __LOWCODE_SIZE__ .import __BLOCKSIZE__ @@ -25,6 +25,6 @@ len0 = __STARTUP_SIZE__ + __ONCE_SIZE__ + __CODE_SIZE__ + __DATA_SIZE__ + __RODA .byte <block0 .word off0 & (__BLOCKSIZE__ - 1) .byte $88 - .word __RAM_START__ + .word __MAIN_START__ .word len0 __DIRECTORY_END__: diff --git a/libsrc/osic1p/bootstrap.s b/libsrc/osic1p/bootstrap.s index 2a501b980..ed2ade222 100644 --- a/libsrc/osic1p/bootstrap.s +++ b/libsrc/osic1p/bootstrap.s @@ -6,16 +6,16 @@ ; add "-u __BOOT__" to the cl65/ld65 command line. Then, the linker ; will import this symbol name; and, link this module at the front ; of your program file. -; - .export __BOOT__:abs = 1 - .import __RAM_START__, __RAM_SIZE__, __BSS_RUN__ + .export __BOOT__ : abs = 1 + + .import __MAIN_START__, __MAIN_SIZE__, __BSS_RUN__ ; ------------------------------------------------------------------------ -load_addr := __RAM_START__ -load_size = __BSS_RUN__ - __RAM_START__ -ram_top := __RAM_START__ + __RAM_SIZE__ +load_addr := __MAIN_START__ +load_size = __BSS_RUN__ - __MAIN_START__ +ram_top := __MAIN_START__ + __MAIN_SIZE__ .segment "BOOT" diff --git a/libsrc/osic1p/crt0.s b/libsrc/osic1p/crt0.s index 62342c206..56abb7cdb 100644 --- a/libsrc/osic1p/crt0.s +++ b/libsrc/osic1p/crt0.s @@ -8,7 +8,7 @@ .import _main .export __STARTUP__ : absolute = 1 ; Mark as startup -.import __RAM_START__, __RAM_SIZE__ ; Linker generated +.import __MAIN_START__, __MAIN_SIZE__ ; Linker generated .import __STACKSIZE__ .import zerobss, initlib, donelib @@ -32,10 +32,10 @@ _init: ldx #$FF ; Initialize stack pointer to $01FF ; --------------------------------------------------------------------------- ; Set cc65 argument stack pointer - lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - sta sp+1 + stx sp+1 ; --------------------------------------------------------------------------- ; Initialize memory storage diff --git a/libsrc/plus4/crt0.s b/libsrc/plus4/crt0.s index 9696d50f4..2262b4c42 100644 --- a/libsrc/plus4/crt0.s +++ b/libsrc/plus4/crt0.s @@ -9,7 +9,7 @@ .import callirq_y, initlib, donelib .import callmain, zerobss .import __INTERRUPTOR_COUNT__ - .import __RAM_START__, __RAM_SIZE__ ; Linker generated + .import __MAIN_START__, __MAIN_SIZE__ ; Linker generated .import __STACKSIZE__ ; Linker generated .importzp ST @@ -50,12 +50,12 @@ L1: lda sp,x ; of the usable RAM. tsx - stx spsave ; save system stk ptr + stx spsave ; Save system stk ptr - lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - sta sp+1 + stx sp+1 ; Set up the IRQ vector in the banked RAM; and, switch off the ROM. diff --git a/libsrc/sim6502/crt0.s b/libsrc/sim6502/crt0.s index d1831ad81..bd02f0e42 100644 --- a/libsrc/sim6502/crt0.s +++ b/libsrc/sim6502/crt0.s @@ -9,7 +9,7 @@ .import zerobss, callmain .import initlib, donelib .import exit - .import __RAM_START__, __RAM_SIZE__ ; Linker generated + .import __MAIN_START__, __MAIN_SIZE__ ; Linker generated .import __STACKSIZE__ ; Linker generated .include "zeropage.inc" @@ -19,8 +19,8 @@ cld ldx #$FF txs - lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - ldx #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) sta sp stx sp+1 jsr zerobss diff --git a/libsrc/vic20/crt0.s b/libsrc/vic20/crt0.s index 723971168..68ab3ed12 100644 --- a/libsrc/vic20/crt0.s +++ b/libsrc/vic20/crt0.s @@ -8,7 +8,7 @@ .import zerobss, push0 .import callmain .import RESTOR, BSOUT, CLRCH - .import __RAM_START__, __RAM_SIZE__ ; Linker generated + .import __MAIN_START__, __MAIN_SIZE__ ; Linker generated .import __STACKSIZE__ ; Linker generated .importzp ST @@ -44,10 +44,10 @@ L1: lda sp,x tsx stx spsave ; Save the system stack ptr - lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - sta sp+1 ; Set argument stack ptr + stx sp+1 ; Set argument stack ptr ; Call the module constructors. From 69fbcb30fd393277c93eade43737a52d20582c47 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 7 Mar 2016 01:44:19 +0100 Subject: [PATCH 017/407] Use AX paradigm for stack initalization. --- libsrc/atari5200/crt0.s | 4 ++-- libsrc/gamate/crt0.s | 4 ++-- libsrc/nes/crt0.s | 4 ++-- libsrc/pce/crt0.s | 17 ++++++++--------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/libsrc/atari5200/crt0.s b/libsrc/atari5200/crt0.s index 7073bb2a7..ee3d0de4f 100644 --- a/libsrc/atari5200/crt0.s +++ b/libsrc/atari5200/crt0.s @@ -27,9 +27,9 @@ start: ; Set up the stack. lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__) + ldx #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__) - sta sp+1 ; Set argument stack ptr + stx sp+1 ; Set argument stack ptr ; Call the module constructors. diff --git a/libsrc/gamate/crt0.s b/libsrc/gamate/crt0.s index 99af9b2d9..5a5bb3aa0 100644 --- a/libsrc/gamate/crt0.s +++ b/libsrc/gamate/crt0.s @@ -20,7 +20,7 @@ Start: ldx #0 stx ZP_IRQ_CTRL ; disable calling cartridge IRQ/NMI handler - ; Setup stack and memory mapping + ; Set up stack and memory mapping ;ldx #$FF ; Stack top ($01FF) dex txs @@ -31,7 +31,7 @@ Start: ; Copy the .data segment to RAM jsr copydata - ; setup the stack + ; Set up the stack lda #<(__RAM_START__+__RAM_SIZE__) ldx #>(__RAM_START__+__RAM_SIZE__) sta sp diff --git a/libsrc/nes/crt0.s b/libsrc/nes/crt0.s index de874d363..4d258ff9e 100644 --- a/libsrc/nes/crt0.s +++ b/libsrc/nes/crt0.s @@ -100,9 +100,9 @@ start: ; Set up the stack. lda #<(__SRAM_START__ + __SRAM_SIZE__) + ldx #>(__SRAM_START__ + __SRAM_SIZE__) sta sp - lda #>(__SRAM_START__ + __SRAM_SIZE__) - sta sp+1 ; Set argument stack ptr + stx sp+1 ; Set argument stack ptr ; Call the module constructors. diff --git a/libsrc/pce/crt0.s b/libsrc/pce/crt0.s index e92e9eca3..80b32c089 100644 --- a/libsrc/pce/crt0.s +++ b/libsrc/pce/crt0.s @@ -39,22 +39,21 @@ start: - ; setup the CPU and System-IRQ + ; Set up the CPU and System-IRQ ; Initialize CPU - sei nop - csh ; set high speed CPU mode + csh ; Set high speed CPU mode nop cld nop - ; Setup stack and memory mapping + ; Set up stack and memory mapping ldx #$FF ; Stack top ($21FF) txs - ; at startup all MPRs are set to 0, so init them + ; At startup all MPRs are set to 0, so init them lda #$ff tam #%00000001 ; 0000-1FFF = Hardware page lda #$F8 @@ -98,11 +97,11 @@ start: ; Copy the .data segment to RAM tii __DATA_LOAD__, __DATA_RUN__, __DATA_SIZE__ - ; setup the stack + ; Set up the stack lda #<(__RAM_START__+__RAM_SIZE__) + ldx #>(__RAM_START__+__RAM_SIZE__) sta sp - lda #>(__RAM_START__+__RAM_SIZE__) - sta sp + 1 + stx sp + 1 ; Call module constructors jsr initlib @@ -114,7 +113,7 @@ start: jsr push0 ; argv ldy #4 ; Argument size - jsr _main ; call the users code + jsr _main ; Call the users code ; Call module destructors. This is also the _exit entry. _exit: From 084453ba57307131dc4465196d177f83a79e0068 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 10 Mar 2016 10:07:09 +0100 Subject: [PATCH 018/407] Don't presume the stack size to be a multiple of pages. --- libsrc/supervision/crt0.s | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libsrc/supervision/crt0.s b/libsrc/supervision/crt0.s index d78bfeab5..6c1287868 100644 --- a/libsrc/supervision/crt0.s +++ b/libsrc/supervision/crt0.s @@ -31,9 +31,10 @@ reset: ; Initialize data. jsr copydata - lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - sta sp+1 ; Set argument stack ptr - stz sp ; #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + ldx #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) + sta sp + stx sp+1 ; Set argument stack ptr jsr initlib jsr _main _exit: jsr donelib From a3a22733f8f83f0cf8547a9d2cf34d8056b97c97 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 13 Mar 2016 14:32:07 +0100 Subject: [PATCH 019/407] Cleaned up C64 linker configs. The BSS segment and the ONCE segment share the same start address. So they need to be placed in two different memory areas. So far BSS was placed in the MAIN memory area and ONCE was placed in an additional memory area. Both memory areas were written to the output file. They just "happened" to be loadable and runnable at a stretch. Now ONCE is placed in the MAIN memory area and BSS is placed in an additional memory area. Only MAIN is written to the output file. It becomes more obvious that BSS is "just" defined to share memory with ONCE. --- cfg/c64-asm.cfg | 2 +- cfg/c64-overlay.cfg | 10 +++++----- cfg/c64.cfg | 16 ++++++++-------- libsrc/c64/crt0.s | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cfg/c64-asm.cfg b/cfg/c64-asm.cfg index 224bd704a..25d12ee71 100644 --- a/cfg/c64-asm.cfg +++ b/cfg/c64-asm.cfg @@ -10,11 +10,11 @@ MEMORY { MAIN: file = %O, start = %S, size = $D000 - %S; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp, optional = yes; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = rw, optional = yes; RODATA: load = MAIN, type = ro, optional = yes; DATA: load = MAIN, type = rw, optional = yes; BSS: load = MAIN, type = bss, optional = yes; - ZEROPAGE: load = ZP, type = zp, optional = yes; } diff --git a/cfg/c64-overlay.cfg b/cfg/c64-overlay.cfg index 872fdd775..e88bffe00 100644 --- a/cfg/c64-overlay.cfg +++ b/cfg/c64-overlay.cfg @@ -1,5 +1,5 @@ FEATURES { - STARTADDRESS: default = $0801; + STARTADDRESS: default = $0801; } SYMBOLS { __LOADADDR__: type = import; @@ -14,8 +14,8 @@ MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; LOADADDR: file = %O, start = %S - 2, size = $0002; HEADER: file = %O, define = yes, start = %S, size = $000D; - MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __OVERLAYSTART__ - __STACKSIZE__ - __HEADER_LAST__; - INIT: file = %O, start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__; + MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __HEADER_LAST__; + BSS: file = "", start = __ONCE_RUN__, size = __OVERLAYSTART__ - __STACKSIZE__ - __ONCE_RUN__; OVL1ADDR: file = "%O.1", start = __OVERLAYSTART__ - 2, size = $0002; OVL1: file = "%O.1", start = __OVERLAYSTART__, size = __OVERLAYSIZE__; OVL2ADDR: file = "%O.2", start = __OVERLAYSTART__ - 2, size = $0002; @@ -45,8 +45,8 @@ SEGMENTS { RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; INIT: load = MAIN, type = rw; - BSS: load = MAIN, type = bss, define = yes; - ONCE: load = INIT, type = ro; + ONCE: load = MAIN, type = ro, define = yes; + BSS: load = BSS, type = bss, define = yes; OVL1ADDR: load = OVL1ADDR, type = ro; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; OVL2ADDR: load = OVL2ADDR, type = ro; diff --git a/cfg/c64.cfg b/cfg/c64.cfg index 3735a0a65..43ccce2ca 100644 --- a/cfg/c64.cfg +++ b/cfg/c64.cfg @@ -1,5 +1,5 @@ FEATURES { - STARTADDRESS: default = $0801; + STARTADDRESS: default = $0801; } SYMBOLS { __LOADADDR__: type = import; @@ -8,11 +8,11 @@ SYMBOLS { __HIMEM__: type = weak, value = $D000; } MEMORY { - ZP: file = "", define = yes, start = $0002, size = $001A; - LOADADDR: file = %O, start = %S - 2, size = $0002; - HEADER: file = %O, define = yes, start = %S, size = $000D; - MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __STACKSIZE__ - __HEADER_LAST__; - INIT: file = %O, start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__; + ZP: file = "", define = yes, start = $0002, size = $001A; + LOADADDR: file = %O, start = %S - 2, size = $0002; + HEADER: file = %O, define = yes, start = %S, size = $000D; + MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __HEADER_LAST__; + BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; @@ -24,8 +24,8 @@ SEGMENTS { RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; INIT: load = MAIN, type = rw; - BSS: load = MAIN, type = bss, define = yes; - ONCE: load = INIT, type = ro, define = yes; + ONCE: load = MAIN, type = ro, define = yes; + BSS: load = BSS, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index c8a7386cb..7bd294ca7 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -93,8 +93,8 @@ L1: lda sp,x ; Set up the stack. - lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__) sta sp stx sp+1 ; Set argument stack ptr From 56a8c69b14496d6b8d32e3e7c55aaff6a2f0d9a9 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 13 Mar 2016 21:23:45 +0100 Subject: [PATCH 020/407] Use AX paradigm. --- libsrc/atari/crt0.s | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libsrc/atari/crt0.s b/libsrc/atari/crt0.s index 317fe5697..87d7d036f 100644 --- a/libsrc/atari/crt0.s +++ b/libsrc/atari/crt0.s @@ -65,9 +65,9 @@ start: ; Report the memory usage. lda APPMHI + ldx APPMHI+1 sta APPMHI_save ; remember old APPMHI value - lda APPMHI+1 - sta APPMHI_save+1 + stx APPMHI_save+1 sec lda MEMTOP @@ -129,9 +129,9 @@ _exit: jsr donelib ; Run module destructors ; Restore APPMHI. lda APPMHI_save + ldx APPMHI_save+1 sta APPMHI - lda APPMHI_save+1 - sta APPMHI+1 + stx APPMHI+1 .ifdef __ATARIXL__ @@ -142,9 +142,9 @@ _exit: jsr donelib ; Run module destructors lda RAMTOP_save sta RAMTOP lda MEMTOP_save + ldx MEMTOP_save+1 sta MEMTOP - lda MEMTOP_save+1 - sta MEMTOP+1 + stx MEMTOP+1 ; Issue a GRAPHICS 0 call (copied'n'pasted from the TGI drivers), in From 692f96409d4e809d8d0db6adba6eddd549861e8f Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 13 Mar 2016 22:13:41 +0100 Subject: [PATCH 021/407] Fixed BSS properties. The cassette boot file header references __BSS_RUN__ so BSS must be the first bss type segment (and for sure isn't optional). --- cfg/atari-cassette.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfg/atari-cassette.cfg b/cfg/atari-cassette.cfg index b138b8f0e..84bb5ad02 100644 --- a/cfg/atari-cassette.cfg +++ b/cfg/atari-cassette.cfg @@ -21,8 +21,8 @@ SEGMENTS { CODE: load = MAIN, type = ro, define = yes; RODATA: load = MAIN, type = ro, optional = yes; DATA: load = MAIN, type = rw, optional = yes; + BSS: load = MAIN, type = bss, define = yes; INIT: load = MAIN, type = bss, optional = yes; - BSS: load = MAIN, type = bss, define = yes, optional = yes; } FEATURES { CONDES: type = constructor, From c768de156ad67e2df769fc7c36ee37b989f15ddf Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 13 Mar 2016 22:18:51 +0100 Subject: [PATCH 022/407] Fixed INIT properties. The main chunk load header references __BSS_LOAD__ so BSS must be the first bss type segment. Subsequent changes will move ONCE to share its address with the BSS. Then it'll be necessary to load INIT from disk. Therefore we do it right now. --- cfg/atari-overlay.cfg | 38 ++++++++++++------------- cfg/atari.cfg | 2 +- cfg/atarixl-largehimem.cfg | 35 +++++++++-------------- cfg/atarixl-overlay.cfg | 58 ++++++++++++++++---------------------- cfg/atarixl.cfg | 37 ++++++++++-------------- 5 files changed, 74 insertions(+), 96 deletions(-) diff --git a/cfg/atari-overlay.cfg b/cfg/atari-overlay.cfg index 1dec49b7d..87e62d764 100644 --- a/cfg/atari-overlay.cfg +++ b/cfg/atari-overlay.cfg @@ -11,31 +11,31 @@ SYMBOLS { __RESERVED_MEMORY__: type = weak, value = $0000; } MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # file header, just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "system check" load chunk - SYSCHKHDR: file = %O, start = $0000, size = $0004; - SYSCHKCHNK: file = %O, start = $2E00, size = $0300; - SYSCHKTRL: file = %O, start = $0000, size = $0006; + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, - size = $BC20 - __OVERLAYSIZE__ - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; - TRAILER: file = %O, start = $0000, size = $0006; + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = $BC20 - __OVERLAYSIZE__ - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; + TRAILER: file = %O, start = $0000, size = $0006; - OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; - OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; - OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; - OVL4: file = "%O.4", start = %S, size = __OVERLAYSIZE__; - OVL5: file = "%O.5", start = %S, size = __OVERLAYSIZE__; - OVL6: file = "%O.6", start = %S, size = __OVERLAYSIZE__; - OVL7: file = "%O.7", start = %S, size = __OVERLAYSIZE__; - OVL8: file = "%O.8", start = %S, size = __OVERLAYSIZE__; - OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; +# overlays + OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; + OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; + OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; + OVL4: file = "%O.4", start = %S, size = __OVERLAYSIZE__; + OVL5: file = "%O.5", start = %S, size = __OVERLAYSIZE__; + OVL6: file = "%O.6", start = %S, size = __OVERLAYSIZE__; + OVL7: file = "%O.7", start = %S, size = __OVERLAYSIZE__; + OVL8: file = "%O.8", start = %S, size = __OVERLAYSIZE__; + OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; @@ -51,7 +51,7 @@ SEGMENTS { CODE: load = MAIN, type = ro, define = yes; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, optional = yes; + INIT: load = MAIN, type = rw, optional = yes; BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; diff --git a/cfg/atari.cfg b/cfg/atari.cfg index 959a07e4c..4680a89ed 100644 --- a/cfg/atari.cfg +++ b/cfg/atari.cfg @@ -39,7 +39,7 @@ SEGMENTS { CODE: load = MAIN, type = ro, define = yes; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, optional = yes; + INIT: load = MAIN, type = rw, optional = yes; BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; } diff --git a/cfg/atarixl-largehimem.cfg b/cfg/atarixl-largehimem.cfg index 94405fce2..56d2af15b 100644 --- a/cfg/atarixl-largehimem.cfg +++ b/cfg/atarixl-largehimem.cfg @@ -6,7 +6,6 @@ FEATURES { STARTADDRESS: default = $2400; } - SYMBOLS { __EXEHDR__: type = import; __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk @@ -14,41 +13,35 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTADDRESS__: type = export, value = %S; } - MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "system check" load chunk - SYSCHKHDR: file = %O, start = $0000, size = $0004; - SYSCHKCHNK: file = %O, start = $2E00, size = $0300; - SYSCHKTRL: file = %O, start = $0000, size = $0006; + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; # "shadow RAM preparation" load chunk - SRPREPHDR: file = %O, start = $0000, size = $0004; - SRPREPCHNK: file = %O, define = yes, start = %S, size = $7C20 - %S - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned - SRPREPTRL: file = %O, start = $0000, size = $0006; + SRPREPHDR: file = %O, start = $0000, size = $0004; + SRPREPCHNK: file = %O, define = yes, start = %S, size = $7C20 - %S - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned + SRPREPTRL: file = %O, start = $0000, size = $0006; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - MAIN: file = %O, define = yes, start = %S + - __LOWBSS_SIZE__, size = $D000 - - __STACKSIZE__ - - %S - - __LOWBSS_SIZE__; + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S + __LOWBSS_SIZE__, size = $D000 - __STACKSIZE__ - %S - __LOWBSS_SIZE__; # defines entry point into program - TRAILER: file = %O, start = $0000, size = $0006; + TRAILER: file = %O, start = $0000, size = $0006; # address of relocated character generator - CHARGEN: file = "", define = yes, start = $D800, size = $0400; + CHARGEN: file = "", define = yes, start = $D800, size = $0400; # memory beneath the ROM - HIDDEN_RAM: file = "", define = yes, start = $DC00, size = $FFFA - $DC00; + HIDDEN_RAM: file = "", define = yes, start = $DC00, size = $FFFA - $DC00; } - SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = zp, optional = yes; @@ -73,7 +66,7 @@ SEGMENTS { CODE: load = MAIN, type = ro, define = yes; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, optional = yes; + INIT: load = MAIN, type = rw, optional = yes; BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; } diff --git a/cfg/atarixl-overlay.cfg b/cfg/atarixl-overlay.cfg index 89240170b..923436497 100644 --- a/cfg/atarixl-overlay.cfg +++ b/cfg/atarixl-overlay.cfg @@ -1,7 +1,6 @@ FEATURES { STARTADDRESS: default = $2400; } - SYMBOLS { __EXEHDR__: type = import; __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk @@ -10,57 +9,50 @@ SYMBOLS { __OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay __STARTADDRESS__: type = export, value = %S; } - MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "system check" load chunk - SYSCHKHDR: file = %O, start = $0000, size = $0004; - SYSCHKCHNK: file = %O, start = $2E00, size = $0300; - SYSCHKTRL: file = %O, start = $0000, size = $0006; + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; # "shadow RAM preparation" load chunk - SRPREPHDR: file = %O, start = $0000, size = $0004; - SRPREPCHNK: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = $7C20 - %S - __OVERLAYSIZE__ - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned - SRPREPTRL: file = %O, start = $0000, size = $0006; + SRPREPHDR: file = %O, start = $0000, size = $0004; + SRPREPCHNK: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = $7C20 - %S - __OVERLAYSIZE__ - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned + SRPREPTRL: file = %O, start = $0000, size = $0006; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - MAIN: file = %O, define = yes, start = %S + - __OVERLAYSIZE__ + - __LOWBSS_SIZE__, size = $D000 - - __STACKSIZE__ - - %S - - __OVERLAYSIZE__ - - __LOWBSS_SIZE__; + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__ + + __LOWBSS_SIZE__, size = $D000 - __STACKSIZE__ - %S - __OVERLAYSIZE__ - __LOWBSS_SIZE__; # defines entry point into program - TRAILER: file = %O, start = $0000, size = $0006; + TRAILER: file = %O, start = $0000, size = $0006; # memory beneath the ROM preceeding the character generator - HIDDEN_RAM2: file = "", define = yes, start = $D800, size = $0800; + HIDDEN_RAM2: file = "", define = yes, start = $D800, size = $0800; # address of relocated character generator (same addess as ROM version) - CHARGEN: file = "", define = yes, start = $E000, size = $0400; + CHARGEN: file = "", define = yes, start = $E000, size = $0400; # memory beneath the ROM - HIDDEN_RAM: file = "", define = yes, start = $E400, size = $FFFA - $E400; + HIDDEN_RAM: file = "", define = yes, start = $E400, size = $FFFA - $E400; # overlays - OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; - OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; - OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; - OVL4: file = "%O.4", start = %S, size = __OVERLAYSIZE__; - OVL5: file = "%O.5", start = %S, size = __OVERLAYSIZE__; - OVL6: file = "%O.6", start = %S, size = __OVERLAYSIZE__; - OVL7: file = "%O.7", start = %S, size = __OVERLAYSIZE__; - OVL8: file = "%O.8", start = %S, size = __OVERLAYSIZE__; - OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; + OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; + OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; + OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; + OVL4: file = "%O.4", start = %S, size = __OVERLAYSIZE__; + OVL5: file = "%O.5", start = %S, size = __OVERLAYSIZE__; + OVL6: file = "%O.6", start = %S, size = __OVERLAYSIZE__; + OVL7: file = "%O.7", start = %S, size = __OVERLAYSIZE__; + OVL8: file = "%O.8", start = %S, size = __OVERLAYSIZE__; + OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; } - SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = zp, optional = yes; @@ -85,7 +77,7 @@ SEGMENTS { CODE: load = MAIN, type = ro, define = yes; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, optional = yes; + INIT: load = MAIN, type = rw, optional = yes; BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; diff --git a/cfg/atarixl.cfg b/cfg/atarixl.cfg index 9573fc78c..197daace6 100644 --- a/cfg/atarixl.cfg +++ b/cfg/atarixl.cfg @@ -1,7 +1,6 @@ FEATURES { STARTADDRESS: default = $2400; } - SYMBOLS { __EXEHDR__: type = import; __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk @@ -9,44 +8,38 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTADDRESS__: type = export, value = %S; } - MEMORY { - ZP: file = "", define = yes, start = $0082, size = $007E; + ZP: file = "", define = yes, start = $0082, size = $007E; # just $FFFF - HEADER: file = %O, start = $0000, size = $0002; + HEADER: file = %O, start = $0000, size = $0002; # "system check" load chunk - SYSCHKHDR: file = %O, start = $0000, size = $0004; - SYSCHKCHNK: file = %O, start = $2E00, size = $0300; - SYSCHKTRL: file = %O, start = $0000, size = $0006; + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; # "shadow RAM preparation" load chunk - SRPREPHDR: file = %O, start = $0000, size = $0004; - SRPREPCHNK: file = %O, define = yes, start = %S, size = $7C20 - %S - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned - SRPREPTRL: file = %O, start = $0000, size = $0006; + SRPREPHDR: file = %O, start = $0000, size = $0004; + SRPREPCHNK: file = %O, define = yes, start = %S, size = $7C20 - %S - $07FF; # $07FF: space for temp. chargen buffer, 1K aligned + SRPREPTRL: file = %O, start = $0000, size = $0006; # "main program" load chunk - MAINHDR: file = %O, start = $0000, size = $0004; - MAIN: file = %O, define = yes, start = %S + - __LOWBSS_SIZE__, size = $D000 - - __STACKSIZE__ - - %S - - __LOWBSS_SIZE__; + MAINHDR: file = %O, start = $0000, size = $0004; + MAIN: file = %O, define = yes, start = %S + __LOWBSS_SIZE__, size = $D000 - __STACKSIZE__ - %S - __LOWBSS_SIZE__; # defines entry point into program - TRAILER: file = %O, start = $0000, size = $0006; + TRAILER: file = %O, start = $0000, size = $0006; # memory beneath the ROM preceeding the character generator - HIDDEN_RAM2: file = "", define = yes, start = $D800, size = $0800; + HIDDEN_RAM2: file = "", define = yes, start = $D800, size = $0800; # address of relocated character generator (same addess as ROM version) - CHARGEN: file = "", define = yes, start = $E000, size = $0400; + CHARGEN: file = "", define = yes, start = $E000, size = $0400; # memory beneath the ROM - HIDDEN_RAM: file = "", define = yes, start = $E400, size = $FFFA - $E400; + HIDDEN_RAM: file = "", define = yes, start = $E400, size = $FFFA - $E400; } - SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = zp, optional = yes; @@ -71,7 +64,7 @@ SEGMENTS { CODE: load = MAIN, type = ro, define = yes; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, optional = yes; + INIT: load = MAIN, type = rw, optional = yes; BSS: load = MAIN, type = bss, define = yes; AUTOSTRT: load = TRAILER, type = ro; } From 46d4307bbb5e7f536e9ddf5c11f8ff700524ca7e Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 15 Mar 2016 21:19:25 +0100 Subject: [PATCH 023/407] Removed ONCE segment. Pure assembler programs don't have constructors. Therefore constructor code ending up in an assembler program should trigger an error. --- cfg/osic1p-asm.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/cfg/osic1p-asm.cfg b/cfg/osic1p-asm.cfg index 3c1b1bda3..88ab69062 100644 --- a/cfg/osic1p-asm.cfg +++ b/cfg/osic1p-asm.cfg @@ -17,7 +17,6 @@ MEMORY { SEGMENTS { ZEROPAGE: load = ZP, type = zp; BOOT: load = HEAD, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; CODE: load = MAIN, type = rw; RODATA: load = MAIN, type = rw; DATA: load = MAIN, type = rw; From 0edd05b4bf425e3327e7aec7435a18e593707800 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 15 Mar 2016 21:25:22 +0100 Subject: [PATCH 024/407] Removed symbol definition for ONCE. Almost all targets don't need symbols for the ONCE segment. Likely their definition was a C&P error in the first place. --- cfg/bbc.cfg | 2 +- cfg/c128-overlay.cfg | 2 +- cfg/c128.cfg | 2 +- cfg/c16.cfg | 2 +- cfg/gamate.cfg | 2 +- cfg/geos-apple.cfg | 2 +- cfg/geos-cbm.cfg | 2 +- cfg/lunix.cfg | 2 +- cfg/nes.cfg | 2 +- cfg/none.cfg | 2 +- cfg/osic1p.cfg | 2 +- cfg/pce.cfg | 2 +- cfg/pet.cfg | 2 +- cfg/plus4.cfg | 2 +- cfg/sim6502.cfg | 2 +- cfg/sim65c02.cfg | 2 +- cfg/supervision-128k.cfg | 2 +- cfg/supervision-16k.cfg | 2 +- cfg/supervision-64k.cfg | 2 +- cfg/supervision.cfg | 2 +- cfg/vic20-32k.cfg | 2 +- cfg/vic20.cfg | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/cfg/bbc.cfg b/cfg/bbc.cfg index c451951ad..f1aa4a877 100644 --- a/cfg/bbc.cfg +++ b/cfg/bbc.cfg @@ -9,7 +9,7 @@ SEGMENTS { ZEROPAGE: load = ZP, type = zp; STARTUP: load = MAIN, type = ro, define = yes; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; diff --git a/cfg/c128-overlay.cfg b/cfg/c128-overlay.cfg index 8f60fa347..e2cff8b7c 100644 --- a/cfg/c128-overlay.cfg +++ b/cfg/c128-overlay.cfg @@ -35,7 +35,7 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; diff --git a/cfg/c128.cfg b/cfg/c128.cfg index 6a98dc5cf..7546e7921 100644 --- a/cfg/c128.cfg +++ b/cfg/c128.cfg @@ -15,7 +15,7 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; diff --git a/cfg/c16.cfg b/cfg/c16.cfg index f1ab747cd..1aae78824 100644 --- a/cfg/c16.cfg +++ b/cfg/c16.cfg @@ -15,7 +15,7 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; diff --git a/cfg/gamate.cfg b/cfg/gamate.cfg index 4e4253194..74ae9f3e3 100644 --- a/cfg/gamate.cfg +++ b/cfg/gamate.cfg @@ -27,7 +27,7 @@ SEGMENTS { EXTZP: load = ZP, type = zp, define = yes, optional = yes; APPZP: load = ZP, type = zp, define = yes, optional = yes; STARTUP: load = CARTHEADER, type = ro, define = yes; - ONCE: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro, define = yes; RODATA: load = ROM, type = ro, define = yes; DATA: load = ROM, run = RAM, type = rw, define = yes; diff --git a/cfg/geos-apple.cfg b/cfg/geos-apple.cfg index ee8b61aec..9fc7024e1 100644 --- a/cfg/geos-apple.cfg +++ b/cfg/geos-apple.cfg @@ -40,7 +40,7 @@ SEGMENTS { VLIRIDX0: type = ro, load = CVT, align = $200, optional = yes; STARTUP: type = ro, run = VLIR0, load = CVT, align_load = $200, define = yes; LOWCODE: type = ro, run = VLIR0, load = CVT, optional = yes; - ONCE: type = ro, run = VLIR0, load = CVT, define = yes, optional = yes; + ONCE: type = ro, run = VLIR0, load = CVT, optional = yes; CODE: type = ro, run = VLIR0, load = CVT; RODATA: type = ro, run = VLIR0, load = CVT; DATA: type = rw, run = VLIR0, load = CVT; diff --git a/cfg/geos-cbm.cfg b/cfg/geos-cbm.cfg index 42cbe9a48..f9bea76a0 100644 --- a/cfg/geos-cbm.cfg +++ b/cfg/geos-cbm.cfg @@ -37,7 +37,7 @@ SEGMENTS { RECORDS: type = ro, load = CVT, align = $FE, optional = yes; STARTUP: type = ro, run = VLIR0, load = CVT, align_load = $FE, define = yes; LOWCODE: type = ro, run = VLIR0, load = CVT, optional = yes; - ONCE: type = ro, run = VLIR0, load = CVT, define = yes, optional = yes; + ONCE: type = ro, run = VLIR0, load = CVT, optional = yes; CODE: type = ro, run = VLIR0, load = CVT; RODATA: type = ro, run = VLIR0, load = CVT; DATA: type = rw, run = VLIR0, load = CVT; diff --git a/cfg/lunix.cfg b/cfg/lunix.cfg index 3a11cc5d4..0b7b9c8ff 100644 --- a/cfg/lunix.cfg +++ b/cfg/lunix.cfg @@ -12,7 +12,7 @@ SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; # Pseudo-registers STARTUP: load = MAIN, type = ro; # First initialization code LOWCODE: load = MAIN, type = ro, optional = yes; # Legacy from other platforms - ONCE: load = MAIN, type = ro, define = yes, optional = yes; # Library initialization code + ONCE: load = MAIN, type = ro, optional = yes; # Library initialization code CODE: load = MAIN, type = ro; # Program RODATA: load = MAIN, type = ro; # Literals, constants DATA: load = MAIN, type = rw; # Initialized variables diff --git a/cfg/nes.cfg b/cfg/nes.cfg index f68330425..0cc2ce334 100644 --- a/cfg/nes.cfg +++ b/cfg/nes.cfg @@ -37,7 +37,7 @@ SEGMENTS { HEADER: load = HEADER, type = ro; STARTUP: load = ROM0, type = ro, define = yes; LOWCODE: load = ROM0, type = ro, optional = yes; - ONCE: load = ROM0, type = ro, define = yes, optional = yes; + ONCE: load = ROM0, type = ro, optional = yes; CODE: load = ROM0, type = ro, define = yes; RODATA: load = ROM0, type = ro, define = yes; DATA: load = ROM0, run = RAM, type = rw, define = yes; diff --git a/cfg/none.cfg b/cfg/none.cfg index dcee60419..8cd9c4f95 100644 --- a/cfg/none.cfg +++ b/cfg/none.cfg @@ -8,7 +8,7 @@ MEMORY { SEGMENTS { ZEROPAGE: load = ZP, type = zp; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = rw; RODATA: load = MAIN, type = rw; DATA: load = MAIN, type = rw; diff --git a/cfg/osic1p.cfg b/cfg/osic1p.cfg index 3507ebeba..f7ca08344 100644 --- a/cfg/osic1p.cfg +++ b/cfg/osic1p.cfg @@ -20,7 +20,7 @@ SEGMENTS { BOOT: load = HEAD, type = ro, optional = yes; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = rw; RODATA: load = MAIN, type = rw; DATA: load = MAIN, type = rw; diff --git a/cfg/pce.cfg b/cfg/pce.cfg index 219cbdec3..6332f8eff 100644 --- a/cfg/pce.cfg +++ b/cfg/pce.cfg @@ -21,7 +21,7 @@ SEGMENTS { EXTZP: load = ZP, type = zp, define = yes, optional = yes; APPZP: load = ZP, type = zp, define = yes, optional = yes; STARTUP: load = ROM0, type = ro, define = yes; - ONCE: load = ROM0, type = ro, define = yes, optional = yes; + ONCE: load = ROM0, type = ro, optional = yes; CODE: load = ROM0, type = ro, define = yes; RODATA: load = ROM0, type = ro, define = yes; DATA: load = ROM0, run = RAM, type = rw, define = yes; diff --git a/cfg/pet.cfg b/cfg/pet.cfg index aad3f579e..efde48efe 100644 --- a/cfg/pet.cfg +++ b/cfg/pet.cfg @@ -15,7 +15,7 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, define = yes, optional = yes; + ONCE: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; diff --git a/cfg/plus4.cfg b/cfg/plus4.cfg index 4f73e40c2..610a7c23c 100644 --- a/cfg/plus4.cfg +++ b/cfg/plus4.cfg @@ -15,7 +15,7 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; diff --git a/cfg/sim6502.cfg b/cfg/sim6502.cfg index b50703bab..5e7402262 100644 --- a/cfg/sim6502.cfg +++ b/cfg/sim6502.cfg @@ -12,7 +12,7 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; diff --git a/cfg/sim65c02.cfg b/cfg/sim65c02.cfg index b50703bab..5e7402262 100644 --- a/cfg/sim65c02.cfg +++ b/cfg/sim65c02.cfg @@ -12,7 +12,7 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; diff --git a/cfg/supervision-128k.cfg b/cfg/supervision-128k.cfg index 3cfdf1276..6cfde6551 100644 --- a/cfg/supervision-128k.cfg +++ b/cfg/supervision-128k.cfg @@ -21,7 +21,7 @@ MEMORY { } SEGMENTS { LOWCODE: load = ROM, type = ro, optional = yes; - ONCE: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro; BANK1: load = BANKROM1, type = ro; BANK2: load = BANKROM2, type = ro; diff --git a/cfg/supervision-16k.cfg b/cfg/supervision-16k.cfg index 2e96b9a72..e42677304 100644 --- a/cfg/supervision-16k.cfg +++ b/cfg/supervision-16k.cfg @@ -16,7 +16,7 @@ MEMORY { SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; LOWCODE: load = ROM, type = ro, optional = yes; - ONCE: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro, define = yes; RODATA: load = ROM, type = ro, define = yes; DATA: load = ROM, run = RAM, type = rw, define = yes; diff --git a/cfg/supervision-64k.cfg b/cfg/supervision-64k.cfg index 63338d1e3..18c7b4a45 100644 --- a/cfg/supervision-64k.cfg +++ b/cfg/supervision-64k.cfg @@ -17,7 +17,7 @@ MEMORY { } SEGMENTS { LOWCODE: load = ROM, type = ro, optional = yes; - ONCE: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro; RODATA: load = ROM, type = ro; BANK1: load = BANKROM1, type = ro; diff --git a/cfg/supervision.cfg b/cfg/supervision.cfg index b7ae207b8..da701b511 100644 --- a/cfg/supervision.cfg +++ b/cfg/supervision.cfg @@ -12,7 +12,7 @@ MEMORY { SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; LOWCODE: load = ROM, type = ro, optional = yes; - ONCE: load = ROM, type = ro, define = yes, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro, define = yes; RODATA: load = ROM, type = ro, define = yes; DATA: load = ROM, run = RAM, type = rw, define = yes; diff --git a/cfg/vic20-32k.cfg b/cfg/vic20-32k.cfg index 4f4225825..f592d7bd0 100644 --- a/cfg/vic20-32k.cfg +++ b/cfg/vic20-32k.cfg @@ -17,7 +17,7 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; diff --git a/cfg/vic20.cfg b/cfg/vic20.cfg index 4eba7bfa9..98f6f82b3 100644 --- a/cfg/vic20.cfg +++ b/cfg/vic20.cfg @@ -15,7 +15,7 @@ SEGMENTS { EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; From a2c9cb021a396c8e8771ad6bfb00fbed6e47cc87 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 15 Mar 2016 21:36:38 +0100 Subject: [PATCH 025/407] Moved things into ONCE. Code and or data used only during initialization belongs into the ONCE segment. --- libsrc/c16/cgetc.s | 11 +++-------- libsrc/nes/ppu.s | 5 +++-- libsrc/plus4/cgetc.s | 11 +++-------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/libsrc/c16/cgetc.s b/libsrc/c16/cgetc.s index a476a5d1b..3ee31a757 100644 --- a/libsrc/c16/cgetc.s +++ b/libsrc/c16/cgetc.s @@ -69,6 +69,9 @@ L2: jsr KBDREAD ; Read char and return in A .endproc +fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01 + .byte 133, 137, 134, 138, 135, 139, 136, 140 + .code @@ -82,11 +85,3 @@ L2: jsr KBDREAD ; Read char and return in A rts .endproc - - -; Function key table, readonly - -.rodata -fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01 - .byte 133, 137, 134, 138, 135, 139, 136, 140 - diff --git a/libsrc/nes/ppu.s b/libsrc/nes/ppu.s index 06dc10a65..07b6842f7 100644 --- a/libsrc/nes/ppu.s +++ b/libsrc/nes/ppu.s @@ -68,6 +68,8 @@ ;----------------------------------------------------------------------------- +.segment "ONCE" + .proc ppuinit lda #%10101000 @@ -104,7 +106,6 @@ .endproc - ;----------------------------------------------------------------------------- .proc paletteinit @@ -126,7 +127,7 @@ bne @loop rts - + .endproc ;----------------------------------------------------------------------------- diff --git a/libsrc/plus4/cgetc.s b/libsrc/plus4/cgetc.s index 25a63c053..784bac267 100644 --- a/libsrc/plus4/cgetc.s +++ b/libsrc/plus4/cgetc.s @@ -72,6 +72,9 @@ L2: sta ENABLE_ROM ; Bank in the ROM .endproc +fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01 + .byte 133, 137, 134, 138, 135, 139, 136, 140 + .segment "LOWCODE" ; Accesses the ROM - must go into low mem @@ -87,11 +90,3 @@ L2: sta ENABLE_ROM ; Bank in the ROM rts .endproc - - -; Function key table, readonly - -.rodata -fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01 - .byte 133, 137, 134, 138, 135, 139, 136, 140 - From 4270b8a96c9cdad5c20cc9760070c23e5e07d9a1 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 15 Mar 2016 21:48:44 +0100 Subject: [PATCH 026/407] Fixed segment properties. The CBMx10 targets don't use the INIT segment in the startup code. So it may turn out to be not necessary at all for certain programs. The CBMx10 targets don't need symbols for the ONCE segment. Likely their definition was a C&P error in the first place. --- cfg/cbm510.cfg | 4 ++-- cfg/cbm610.cfg | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cfg/cbm510.cfg b/cfg/cbm510.cfg index 5f73174f3..b4e228fdd 100644 --- a/cfg/cbm510.cfg +++ b/cfg/cbm510.cfg @@ -20,11 +20,11 @@ SEGMENTS { PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss; + INIT: load = MAIN, type = bss, optional = yes; BSS: load = MAIN, type = bss, define = yes; } FEATURES { diff --git a/cfg/cbm610.cfg b/cfg/cbm610.cfg index fb4349dba..431734cd2 100644 --- a/cfg/cbm610.cfg +++ b/cfg/cbm610.cfg @@ -17,11 +17,11 @@ SEGMENTS { PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss; + INIT: load = MAIN, type = bss, optional = yes; BSS: load = MAIN, type = bss, define = yes; } FEATURES { From 3d6cbec6a1e52340ce9459eea7d9bdc2dcd4717b Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 16 Mar 2016 16:00:09 +0100 Subject: [PATCH 027/407] Adjust linker config to match startup code. Apply https://github.com/cc65/cc65/commit/aaf90c1252a09346deb1ccdab96546368afdbbdd to the Supervision default configuration. --- cfg/supervision.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cfg/supervision.cfg b/cfg/supervision.cfg index da701b511..c96351e5f 100644 --- a/cfg/supervision.cfg +++ b/cfg/supervision.cfg @@ -2,10 +2,13 @@ # make sure the halves are mirrored in the 64kbyte cartridge image # or reset from code >0xc000 and switch bank to the 3rd bank +SYMBOLS { + __STACKSIZE__: type = weak, value = $0100; # 1 page stack +} MEMORY { ZP: file = "", start = $0000, size = $0100; CPUSTACK: file = "", start = $0100, size = $0100; - RAM: file = "", start = $0200, size = $1E00, define = yes; + RAM: file = "", start = $0200, size = $1E00 - __STACKSIZE__; VRAM: file = "", start = $4000, size = $2000; ROM: file = %O, start = $8000, size = $8000, fill = yes, fillval = $FF, define = yes; } From 1d1ba3ed3bf0b0b31e34601b7f40201589887537 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 16 Mar 2016 16:28:32 +0100 Subject: [PATCH 028/407] Adjusted constructors. The constructors are _NOT_ allowed anymore to access the BSS. Rather they must use the DATA segment or the INIT segment. The latter isn't cleared at any point so the constructors may use it to expose values to the main program. However they must make sure to always write the values as they are not pre-initialized. --- cfg/atmos.cfg | 11 +++++---- cfg/geos-apple.cfg | 1 + cfg/geos-cbm.cfg | 1 + libsrc/apple2/dosdetect.s | 4 ++-- libsrc/apple2/extra/iobuf-0800.s | 2 +- libsrc/apple2/get_ostype.s | 2 +- libsrc/apple2/mainargs.s | 8 +++---- libsrc/atari/dosdetect.s | 4 ++-- libsrc/atari/getargs.s | 10 ++------ libsrc/atmos/capslock.s | 2 +- libsrc/atmos/mainargs.s | 34 +++++++++++++++------------- libsrc/atmos/read.s | 3 +-- libsrc/c128/cgetc.s | 8 +++---- libsrc/common/_environ.s | 8 +++---- libsrc/geos-common/conio/_scrsize.s | 2 +- libsrc/geos-common/system/mainargs.s | 4 ++-- 16 files changed, 49 insertions(+), 55 deletions(-) diff --git a/cfg/atmos.cfg b/cfg/atmos.cfg index e5a574f0a..bb79a1e8a 100644 --- a/cfg/atmos.cfg +++ b/cfg/atmos.cfg @@ -8,10 +8,10 @@ SYMBOLS { __RAMEND__: type = weak, value = $9800 + $1C00 * __GRAB__; } MEMORY { - ZP: file = "", define = yes, start = $00E2, size = $001A; - TAPEHDR: file = %O, type = ro, start = $0000, size = $001F; - BASHEAD: file = %O, define = yes, start = $0501, size = $000D; - MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __RAM_START__ - __STACKSIZE__; + ZP: file = "", define = yes, start = $00E2, size = $001A; + TAPEHDR: file = %O, type = ro, start = $0000, size = $001F; + BASHEAD: file = %O, define = yes, start = $0501, size = $000D; + MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__ - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; @@ -21,8 +21,9 @@ SEGMENTS { LOWCODE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; - ONCE: load = MAIN, type = ro, define = yes, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw, optional = yes; ZPSAVE1: load = MAIN, type = rw, define = yes; # ZPSAVE1, ZPSAVE2 must be together ZPSAVE2: load = MAIN, type = bss; # see "libsrc/atmos/crt0.s" BSS: load = MAIN, type = bss, define = yes; diff --git a/cfg/geos-apple.cfg b/cfg/geos-apple.cfg index 9fc7024e1..b39cf1ebe 100644 --- a/cfg/geos-apple.cfg +++ b/cfg/geos-apple.cfg @@ -44,6 +44,7 @@ SEGMENTS { CODE: type = ro, run = VLIR0, load = CVT; RODATA: type = ro, run = VLIR0, load = CVT; DATA: type = rw, run = VLIR0, load = CVT; + INIT: type = bss, load = VLIR0, optional = yes; BSS: type = bss, load = VLIR0, define = yes; VLIRIDX1: type = ro, load = CVT, align = $200, optional = yes; OVERLAY1: type = ro, run = VLIR1, load = CVT, align_load = $200, optional = yes; diff --git a/cfg/geos-cbm.cfg b/cfg/geos-cbm.cfg index f9bea76a0..0269dbacb 100644 --- a/cfg/geos-cbm.cfg +++ b/cfg/geos-cbm.cfg @@ -41,6 +41,7 @@ SEGMENTS { CODE: type = ro, run = VLIR0, load = CVT; RODATA: type = ro, run = VLIR0, load = CVT; DATA: type = rw, run = VLIR0, load = CVT; + INIT: type = bss, load = VLIR0, optional = yes; BSS: type = bss, load = VLIR0, define = yes; OVERLAY1: type = ro, run = VLIR1, load = CVT, align_load = $FE, optional = yes; OVERLAY2: type = ro, run = VLIR2, load = CVT, align_load = $FE, optional = yes; diff --git a/libsrc/apple2/dosdetect.s b/libsrc/apple2/dosdetect.s index cedb1f3e3..46fbb5484 100644 --- a/libsrc/apple2/dosdetect.s +++ b/libsrc/apple2/dosdetect.s @@ -43,6 +43,6 @@ initdostype: : sta __dos_type done: rts - .bss + .data -__dos_type: .res 1 +__dos_type: .byte $00 diff --git a/libsrc/apple2/extra/iobuf-0800.s b/libsrc/apple2/extra/iobuf-0800.s index 2e5d1927e..0ad7a751f 100644 --- a/libsrc/apple2/extra/iobuf-0800.s +++ b/libsrc/apple2/extra/iobuf-0800.s @@ -90,6 +90,6 @@ iobuf_free: ; ------------------------------------------------------------------------ - .bss + .data table: .res MAX_FDS diff --git a/libsrc/apple2/get_ostype.s b/libsrc/apple2/get_ostype.s index cff6af9a3..b54e38d63 100644 --- a/libsrc/apple2/get_ostype.s +++ b/libsrc/apple2/get_ostype.s @@ -65,6 +65,6 @@ _get_ostype: ldx #$00 rts - .bss + .segment "INIT" ostype: .res 1 diff --git a/libsrc/apple2/mainargs.s b/libsrc/apple2/mainargs.s index e3db8bb10..de2f385f1 100644 --- a/libsrc/apple2/mainargs.s +++ b/libsrc/apple2/mainargs.s @@ -83,6 +83,7 @@ initmainargs: ; destroyed. ldy #$00 + sty buffer + BUF_LEN - 1 : lda BASIC_BUF,x sta buffer,y inx @@ -166,14 +167,13 @@ done: lda #<argv stx __argv+1 rts -; This array is zeroed before initmainargs is called. -; char* argv[MAXARGS+1] = {FNAM}; - .data +; char* argv[MAXARGS+1] = {FNAM}; + argv: .addr FNAM .res MAXARGS * 2 - .bss + .segment "INIT" buffer: .res BUF_LEN diff --git a/libsrc/atari/dosdetect.s b/libsrc/atari/dosdetect.s index cac9a6536..c2888d888 100644 --- a/libsrc/atari/dosdetect.s +++ b/libsrc/atari/dosdetect.s @@ -48,6 +48,6 @@ done: rts ; ------------------------------------------------------------------------ ; Data - .bss + .data -__dos_type: .res 1 ; default to ATARIDOS +__dos_type: .byte 0 ; default to ATARIDOS diff --git a/libsrc/atari/getargs.s b/libsrc/atari/getargs.s index d32c0a268..e3b18b2f9 100644 --- a/libsrc/atari/getargs.s +++ b/libsrc/atari/getargs.s @@ -23,12 +23,6 @@ SPACE = 32 ; SPACE char. .segment "ONCE" initmainargs: - lda #0 - sta __argc - sta __argc+1 - sta __argv - sta __argv+1 - lda __dos_type ; which DOS? cmp #ATARIDOS beq nargdos ; DOS does not support arguments @@ -120,7 +114,7 @@ eopar: finargs: lda __argc - asl + asl tax lda #0 sta argv,x @@ -134,7 +128,7 @@ finargs: ; -------------------------------------------------------------------------- ; Data -.bss +.segment "INIT" argv: .res (1 + MAXARGS) * 2 diff --git a/libsrc/atmos/capslock.s b/libsrc/atmos/capslock.s index 91c484250..0260b3f9f 100644 --- a/libsrc/atmos/capslock.s +++ b/libsrc/atmos/capslock.s @@ -43,7 +43,7 @@ restore_caps: ;-------------------------------------------------------------------------- -.bss +.segment "INIT" capsave: .res 1 diff --git a/libsrc/atmos/mainargs.s b/libsrc/atmos/mainargs.s index 8b57d9855..3ab353c15 100644 --- a/libsrc/atmos/mainargs.s +++ b/libsrc/atmos/mainargs.s @@ -13,7 +13,7 @@ .macpack generic MAXARGS = 10 ; Maximum number of arguments allowed -REM = $9d ; BASIC token-code +REM = $9D ; BASIC token-code ;--------------------------------------------------------------------------- @@ -26,21 +26,21 @@ REM = $9d ; BASIC token-code ; Assume that the program was loaded, a moment ago, by the traditional LOAD ; statement. Save the "most-recent filename" as argument #0. -; Because the buffer, that we're copying into, was zeroed out, -; we don't need to add a NUL character. -; - ldy #FNAME_LEN - 1 ; limit the length + + ldy #FNAME_LEN ; Limit the length + lda #0 ; The terminating NUL character + beq L1 ; Branch always L0: lda CFOUND_NAME,y - sta name,y +L1: sta name,y dey bpl L0 inc __argc ; argc always is equal to, at least, 1 ; Find the "rem" token. -; + ldx #0 L2: lda BASIC_BUF,x - beq done ; no "rem", no args. + beq done ; No "rem", no args. inx cmp #REM bne L2 @@ -62,7 +62,7 @@ next: lda BASIC_BUF,x beq done ; End of line reached inx cmp #' ' ; Skip leading spaces - beq next ; + beq next ; Found start of next argument. We've incremented the pointer in X already, so ; it points to the second character of the argument. This is useful since we @@ -79,7 +79,7 @@ setterm:sta term ; Set end of argument marker txa ; Get low byte add #<args - sta argv,y ; argv[y]= &arg + sta argv,y ; argv[y]=&arg lda #>$0000 adc #>args sta argv+1,y @@ -99,7 +99,7 @@ argloop:lda BASIC_BUF,x ; A contains the terminating character. To make the argument a valid C string, ; replace the terminating character by a zero. - lda #$00 + lda #0 sta args-1,x ; Check if the maximum number of command line arguments is reached. If not, @@ -120,14 +120,16 @@ done: lda #<argv .endproc ; These arrays are zeroed before initmainargs is called. -; char name[16+1]; -; char* argv[MAXARGS+1]={name}; -; -.bss + +.segment "INIT" + term: .res 1 name: .res FNAME_LEN + 1 args: .res SCREEN_XSIZE * 2 - 1 .data + +; char* argv[MAXARGS+1]={name}; + argv: .addr name - .res MAXARGS * 2, $00 + .res MAXARGS * 2 diff --git a/libsrc/atmos/read.s b/libsrc/atmos/read.s index edf9d161d..c44dc8584 100644 --- a/libsrc/atmos/read.s +++ b/libsrc/atmos/read.s @@ -79,8 +79,7 @@ initstdin: ;-------------------------------------------------------------------------- -.bss +.segment "INIT" text_count: .res 1 - diff --git a/libsrc/c128/cgetc.s b/libsrc/c128/cgetc.s index 7cb4c159e..bc9d8da7f 100644 --- a/libsrc/c128/cgetc.s +++ b/libsrc/c128/cgetc.s @@ -39,7 +39,7 @@ L2: jsr KBDREAD ; Read char and return in A ;-------------------------------------------------------------------------- ; Module constructor/destructor -.bss +.segment "INIT" keyvec: .res 2 .segment "ONCE" @@ -48,9 +48,9 @@ initcgetc: ; Save the old vector lda KeyStoreVec + ldx KeyStoreVec+1 sta keyvec - lda KeyStoreVec+1 - sta keyvec+1 + stx keyvec+1 ; Set the new vector. I can only hope that this works for other C128 ; versions... @@ -68,5 +68,3 @@ SetVec: sei stx KeyStoreVec+1 cli rts - - diff --git a/libsrc/common/_environ.s b/libsrc/common/_environ.s index 6a53f80a8..f9a349e67 100644 --- a/libsrc/common/_environ.s +++ b/libsrc/common/_environ.s @@ -15,10 +15,10 @@ .export __environ, __envcount, __envsize .import initenv .constructor env_init - + env_init := initenv - -.bss + +.data __environ: .addr 0 @@ -26,5 +26,3 @@ __envcount: .byte 0 __envsize: .byte 0 - - diff --git a/libsrc/geos-common/conio/_scrsize.s b/libsrc/geos-common/conio/_scrsize.s index dded4ca42..494182b9d 100644 --- a/libsrc/geos-common/conio/_scrsize.s +++ b/libsrc/geos-common/conio/_scrsize.s @@ -43,7 +43,7 @@ screensize: ldy ysize rts -.bss +.segment "INIT" xsize: .res 1 diff --git a/libsrc/geos-common/system/mainargs.s b/libsrc/geos-common/system/mainargs.s index 14c624759..f38beab34 100644 --- a/libsrc/geos-common/system/mainargs.s +++ b/libsrc/geos-common/system/mainargs.s @@ -5,7 +5,7 @@ ; Setup arguments for main ; ; There is always either 1 or 3 arguments: -; <program name>,0 +; <program name>, 0 ; or ; <program name>, <data file name>, <data disk name>, 0 ; the 2nd case is when using DeskTop user drags an icon of a file and drops it @@ -71,7 +71,7 @@ argv: .word dataDiskName ; dataDiskName .word $0000 ; last one must be NULL -.bss +.segment "INIT" argv0: .res 17 ; Program name From e3cbc7e8b8e1cbb294934cd3d80f9a9f01a2cf28 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 17 Mar 2016 21:07:19 +0100 Subject: [PATCH 029/407] Moved run location of ONCE segment. Make the same changes to the Apple II that were done with https://github.com/cc65/cc65/commit/0ee9b2e446198746c3a05b142ecd00784becf727 to the C64. Notes: - The startup code deliberately doesn't make use of symbols defined for the LC segment as that segment is optional. - The <...>-asm.cfg configs move the segment BSS to an own memory area BSS although this doesn't seem necessary. However the benefit is that the size of the memeory area MAIN is identical to the number of bytes loaded from disk into RAM. To keep this an invariant for all Apple II configs allows to simplify the EXEHDR to just refer to the symbols defined for MAIN. --- cfg/apple2-asm.cfg | 15 ++--- cfg/apple2-overlay.cfg | 55 ++++++++-------- cfg/apple2-system.cfg | 33 +++++----- cfg/apple2.cfg | 37 +++++------ cfg/apple2enh-asm.cfg | 21 +++--- cfg/apple2enh-overlay.cfg | 55 ++++++++-------- cfg/apple2enh-system.cfg | 33 +++++----- cfg/apple2enh.cfg | 37 +++++------ libsrc/apple2/crt0.s | 131 ++++++++++++++++++-------------------- libsrc/apple2/exehdr.s | 6 +- 10 files changed, 196 insertions(+), 227 deletions(-) diff --git a/cfg/apple2-asm.cfg b/cfg/apple2-asm.cfg index b9095cf0c..151ba84c4 100644 --- a/cfg/apple2-asm.cfg +++ b/cfg/apple2-asm.cfg @@ -3,20 +3,17 @@ FEATURES { STARTADDRESS: default = $0803; } -SYMBOLS { - __LOADADDR__: type = weak, value = __CODE_RUN__; - __LOADSIZE__: type = weak, value = __BSS_RUN__ - __CODE_RUN__; -} MEMORY { - ZP: start = $0080, size = $001A, define = yes; - HEADER: file = %O, start = $0000, size = $0004; - MAIN: file = %O, start = %S, size = $C000 - %S; + ZP: file = "", start = $0000, size = $00FF; + HEADER: file = %O, start = %S - 4, size = $0004; + MAIN: file = %O, define = yes, start = %S, size = $C000 - %S; + BSS: file = "", start = __MAIN_LAST__, size = $C000 - __MAIN_LAST__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp, optional = yes; EXEHDR: load = HEADER, type = ro, optional = yes; - CODE: load = MAIN, type = rw, optional = yes, define = yes; + CODE: load = MAIN, type = rw, optional = yes; RODATA: load = MAIN, type = ro, optional = yes; DATA: load = MAIN, type = rw, optional = yes; - BSS: load = MAIN, type = bss, optional = yes, define = yes; + BSS: load = BSS, type = bss, optional = yes, define = yes; } diff --git a/cfg/apple2-overlay.cfg b/cfg/apple2-overlay.cfg index 1e34b6250..e6a5ae25c 100644 --- a/cfg/apple2-overlay.cfg +++ b/cfg/apple2-overlay.cfg @@ -12,21 +12,18 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; + __STACKSIZE__: type = weak, value = $0800; # 2k stack __HIMEM__: type = weak, value = $9600; # Presumed RAM end __LCADDR__: type = weak, value = $D400; # Behind quit code __LCSIZE__: type = weak, value = $0C00; # Rest of bank two - __STACKSIZE__: type = weak, value = $0800; # 2k stack __OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay - __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + - __MOVE_LAST__ - __MOVE_START__; } MEMORY { - ZP: define = yes, start = $0080, size = $001A; - HEADER: file = %O, start = $0000, size = $0004; - MAIN: file = %O, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __STACKSIZE__ - __OVERLAYSIZE__ - %S; - MOVE: file = %O, define = yes, start = $0000, size = $FFFF; - LC: define = yes, start = __LCADDR__, size = __LCSIZE__; + ZP: file = "", define = yes, start = $0080, size = $001A; + HEADER: file = %O, start = %S - 4, size = $0004; + MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __OVERLAYSIZE__ - %S; + BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; @@ -38,26 +35,26 @@ MEMORY { OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = MAIN, type = ro, define = yes; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, define = yes; - BSS: load = MAIN, type = bss, define = yes; - ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; - OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; - OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; - OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; - OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; - OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; - OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; - OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; - OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; - OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + LC: load = MAIN, run = LC, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; + OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; + OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; + OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; + OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; + OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; + OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; + OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; + OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; + OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/apple2-system.cfg b/cfg/apple2-system.cfg index 960be378c..f4684d9c2 100644 --- a/cfg/apple2-system.cfg +++ b/cfg/apple2-system.cfg @@ -1,30 +1,27 @@ # Configuration for ProDOS 8 system programs (without the header) SYMBOLS { + __STACKSIZE__: type = weak, value = $0800; # 2k stack __LCADDR__: type = weak, value = $D400; # Behind quit code __LCSIZE__: type = weak, value = $0C00; # Rest of bank two - __STACKSIZE__: type = weak, value = $0800; # 2k stack - __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + - __MOVE_LAST__ - __MOVE_START__; } MEMORY { - ZP: define = yes, start = $0080, size = $001A; - MAIN: file = %O, start = $2000, size = $9F00 - __STACKSIZE__; - MOVE: file = %O, define = yes, start = $0000, size = $FFFF; - LC: define = yes, start = __LCADDR__, size = __LCSIZE__; + ZP: file = "", define = yes, start = $0080, size = $001A; + MAIN: file = %O, start = $2000, size = $BF00 - $2000; + BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - STARTUP: load = MAIN, type = ro, define = yes; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, define = yes; - BSS: load = MAIN, type = bss, define = yes; - ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; + ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + LC: load = MAIN, run = LC, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/apple2.cfg b/cfg/apple2.cfg index 875103041..eba2a0e66 100644 --- a/cfg/apple2.cfg +++ b/cfg/apple2.cfg @@ -5,33 +5,30 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; + __STACKSIZE__: type = weak, value = $0800; # 2k stack __HIMEM__: type = weak, value = $9600; # Presumed RAM end __LCADDR__: type = weak, value = $D400; # Behind quit code __LCSIZE__: type = weak, value = $0C00; # Rest of bank two - __STACKSIZE__: type = weak, value = $0800; # 2k stack - __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + - __MOVE_LAST__ - __MOVE_START__; } MEMORY { - ZP: define = yes, start = $0080, size = $001A; - HEADER: file = %O, start = $0000, size = $0004; - MAIN: file = %O, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; - MOVE: file = %O, define = yes, start = $0000, size = $FFFF; - LC: define = yes, start = __LCADDR__, size = __LCSIZE__; + ZP: file = "", define = yes, start = $0080, size = $001A; + HEADER: file = %O, start = %S - 4, size = $0004; + MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S; + BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = MAIN, type = ro, define = yes; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, define = yes; - BSS: load = MAIN, type = bss, define = yes; - ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + LC: load = MAIN, run = LC, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/apple2enh-asm.cfg b/cfg/apple2enh-asm.cfg index f7ede1bfe..151ba84c4 100644 --- a/cfg/apple2enh-asm.cfg +++ b/cfg/apple2enh-asm.cfg @@ -3,18 +3,17 @@ FEATURES { STARTADDRESS: default = $0803; } -SYMBOLS { - __LOADADDR__: type = weak, value = __CODE_RUN__; - __LOADSIZE__: type = weak, value = __BSS_RUN__ - __CODE_RUN__; -} MEMORY { - HEADER: file = %O, start = $0000, size = $0004; - MAIN: file = %O, start = %S, size = $C000 - %S; + ZP: file = "", start = $0000, size = $00FF; + HEADER: file = %O, start = %S - 4, size = $0004; + MAIN: file = %O, define = yes, start = %S, size = $C000 - %S; + BSS: file = "", start = __MAIN_LAST__, size = $C000 - __MAIN_LAST__; } SEGMENTS { - EXEHDR: load = HEADER, type = ro, optional = yes; - CODE: load = MAIN, type = rw, optional = yes, define = yes; - RODATA: load = MAIN, type = ro, optional = yes; - DATA: load = MAIN, type = rw, optional = yes; - BSS: load = MAIN, type = bss, optional = yes, define = yes; + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXEHDR: load = HEADER, type = ro, optional = yes; + CODE: load = MAIN, type = rw, optional = yes; + RODATA: load = MAIN, type = ro, optional = yes; + DATA: load = MAIN, type = rw, optional = yes; + BSS: load = BSS, type = bss, optional = yes, define = yes; } diff --git a/cfg/apple2enh-overlay.cfg b/cfg/apple2enh-overlay.cfg index 1e34b6250..e6a5ae25c 100644 --- a/cfg/apple2enh-overlay.cfg +++ b/cfg/apple2enh-overlay.cfg @@ -12,21 +12,18 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; + __STACKSIZE__: type = weak, value = $0800; # 2k stack __HIMEM__: type = weak, value = $9600; # Presumed RAM end __LCADDR__: type = weak, value = $D400; # Behind quit code __LCSIZE__: type = weak, value = $0C00; # Rest of bank two - __STACKSIZE__: type = weak, value = $0800; # 2k stack __OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay - __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + - __MOVE_LAST__ - __MOVE_START__; } MEMORY { - ZP: define = yes, start = $0080, size = $001A; - HEADER: file = %O, start = $0000, size = $0004; - MAIN: file = %O, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __STACKSIZE__ - __OVERLAYSIZE__ - %S; - MOVE: file = %O, define = yes, start = $0000, size = $FFFF; - LC: define = yes, start = __LCADDR__, size = __LCSIZE__; + ZP: file = "", define = yes, start = $0080, size = $001A; + HEADER: file = %O, start = %S - 4, size = $0004; + MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __OVERLAYSIZE__ - %S; + BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__; OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__; OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__; @@ -38,26 +35,26 @@ MEMORY { OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = MAIN, type = ro, define = yes; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, define = yes; - BSS: load = MAIN, type = bss, define = yes; - ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; - OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; - OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; - OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; - OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; - OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; - OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; - OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; - OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; - OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + LC: load = MAIN, run = LC, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; + OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes; + OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes; + OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes; + OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes; + OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes; + OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes; + OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes; + OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes; + OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/apple2enh-system.cfg b/cfg/apple2enh-system.cfg index 6134851f0..f4684d9c2 100644 --- a/cfg/apple2enh-system.cfg +++ b/cfg/apple2enh-system.cfg @@ -1,30 +1,27 @@ # Configuration for ProDOS 8 system programs (without the header) SYMBOLS { + __STACKSIZE__: type = weak, value = $0800; # 2k stack __LCADDR__: type = weak, value = $D400; # Behind quit code __LCSIZE__: type = weak, value = $0C00; # Rest of bank two - __STACKSIZE__: type = weak, value = $0800; # 2k stack - __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + - __MOVE_LAST__ - __MOVE_START__; } MEMORY { - ZP: define = yes, start = $0080, size = $001A; - MAIN: file = %O, start = $2000, size = $9F00 - __STACKSIZE__; - MOVE: file = %O, define = yes, start = $0000, size = $FFFF; - LC: define = yes, start = __LCADDR__, size = __LCSIZE__; + ZP: file = "", define = yes, start = $0080, size = $001A; + MAIN: file = %O, start = $2000, size = $BF00 - $2000; + BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - STARTUP: load = MAIN, type = ro, define = yes; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, define = yes; - BSS: load = MAIN, type = bss, define = yes; - ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; + ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + LC: load = MAIN, run = LC, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/apple2enh.cfg b/cfg/apple2enh.cfg index 875103041..eba2a0e66 100644 --- a/cfg/apple2enh.cfg +++ b/cfg/apple2enh.cfg @@ -5,33 +5,30 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; + __STACKSIZE__: type = weak, value = $0800; # 2k stack __HIMEM__: type = weak, value = $9600; # Presumed RAM end __LCADDR__: type = weak, value = $D400; # Behind quit code __LCSIZE__: type = weak, value = $0C00; # Rest of bank two - __STACKSIZE__: type = weak, value = $0800; # 2k stack - __LOADADDR__: type = weak, value = __STARTUP_RUN__; - __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ + - __MOVE_LAST__ - __MOVE_START__; } MEMORY { - ZP: define = yes, start = $0080, size = $001A; - HEADER: file = %O, start = $0000, size = $0004; - MAIN: file = %O, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; - MOVE: file = %O, define = yes, start = $0000, size = $FFFF; - LC: define = yes, start = __LCADDR__, size = __LCSIZE__; + ZP: file = "", define = yes, start = $0080, size = $001A; + HEADER: file = %O, start = %S - 4, size = $0004; + MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S; + BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; - STARTUP: load = MAIN, type = ro, define = yes; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, define = yes; - BSS: load = MAIN, type = bss, define = yes; - ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes; - LC: load = MOVE, run = LC, type = ro, optional = yes; + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + LC: load = MAIN, run = LC, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/libsrc/apple2/crt0.s b/libsrc/apple2/crt0.s index 7eee390fa..60a8516d1 100644 --- a/libsrc/apple2/crt0.s +++ b/libsrc/apple2/crt0.s @@ -6,16 +6,17 @@ .export _exit, done, return .export __STARTUP__ : absolute = 1 ; Mark as startup - .import zerobss + .import initlib, donelib - .import callmain + .import zerobss, callmain + .import __ONCE_LOAD__, __ONCE_SIZE__ ; Linker generated .import __LC_START__, __LC_LAST__ ; Linker generated - .import __ONCE_RUN__, __ONCE_SIZE__ ; Linker generated - .import __INIT_RUN__ ; Linker generated .include "zeropage.inc" .include "apple2.inc" +; ------------------------------------------------------------------------ + .segment "STARTUP" ; ProDOS TechRefMan, chapter 5.2.1: @@ -24,57 +25,16 @@ ldx #$FF txs ; Init stack pointer - ; Switch in LC bank 2 for W/O. - bit $C081 - bit $C081 - - ; Set the source start address. - lda #<(__INIT_RUN__ + __ONCE_SIZE__) - ldy #>(__INIT_RUN__ + __ONCE_SIZE__) - sta $9B - sty $9C - - ; Set the source last address. - lda #<(__INIT_RUN__ + __ONCE_SIZE__ + __LC_LAST__ - __LC_START__) - ldy #>(__INIT_RUN__ + __ONCE_SIZE__ + __LC_LAST__ - __LC_START__) - sta $96 - sty $97 - - ; Set the destination last address. - lda #<__LC_LAST__ - ldy #>__LC_LAST__ - sta $94 - sty $95 - - ; Call into Applesoft Block Transfer Up -- which handles zero- - ; sized blocks well -- to move the content of the LC memory area. - jsr $D39A ; BLTU2 - - ; Set the source start address. - lda #<__INIT_RUN__ - ldy #>__INIT_RUN__ - sta $9B - sty $9C - - ; Set the source last address. - lda #<(__INIT_RUN__ + __ONCE_SIZE__) - ldy #>(__INIT_RUN__ + __ONCE_SIZE__) - sta $96 - sty $97 - - ; Set the destination last address. - lda #<(__ONCE_RUN__ + __ONCE_SIZE__) - ldy #>(__ONCE_RUN__ + __ONCE_SIZE__) - sta $94 - sty $95 - - ; Call into Applesoft Block Transfer Up -- which handles moving - ; overlapping blocks upwards well -- to move the ONCE segment. - jsr $D39A ; BLTU2 - - ; Delegate all further processing, to keep the STARTUP segment small. + ; Save space by putting some of the start-up code in the ONCE segment, + ; which can be re-used by the BSS segment, the heap and the C stack. jsr init + ; Clear the BSS data. + jsr zerobss + + ; Push the command-line arguments; and, call main(). + jsr callmain + ; Avoid a re-entrance of donelib. This is also the exit() entry. _exit: ldx #<exit lda #>exit @@ -109,6 +69,8 @@ exit: ldx #$02 ; We're done jmp done +; ------------------------------------------------------------------------ + .segment "ONCE" ; Save the zero-page locations that we need. @@ -118,9 +80,6 @@ init: ldx #zpspace-1 dex bpl :- - ; Clear the BSS data. - jsr zerobss - ; Save the original RESET vector. ldx #$02 : lda SOFTEV,x @@ -128,13 +87,6 @@ init: ldx #zpspace-1 dex bpl :- - ; ProDOS TechRefMan, chapter 5.3.5: - ; "Your system program should place in the RESET vector the - ; address of a routine that ... closes the files." - ldx #<_exit - lda #>_exit - jsr reset ; Setup RESET vector - ; Check for ProDOS. ldy $BF00 ; MLI call entry point cpy #$4C ; Is MLI present? (JMP opcode) @@ -164,14 +116,50 @@ basic: lda HIMEM : sta sp stx sp+1 + ; ProDOS TechRefMan, chapter 5.3.5: + ; "Your system program should place in the RESET vector the + ; address of a routine that ... closes the files." + ldx #<_exit + lda #>_exit + jsr reset ; Setup RESET vector + ; Call the module constructors. jsr initlib - ; Switch in LC bank 2 for R/O. - bit $C080 + ; Switch in LC bank 2 for W/O. + bit $C081 + bit $C081 - ; Push the command-line arguments; and, call main(). - jmp callmain + ; Set the source start address. + ; Aka __LC_LOAD__ iff segment LC exists. + lda #<(__ONCE_LOAD__ + __ONCE_SIZE__) + ldy #>(__ONCE_LOAD__ + __ONCE_SIZE__) + sta $9B + sty $9C + + ; Set the source last address. + ; Aka __LC_LOAD__ + __LC_SIZE__ iff segment LC exists. + lda #<((__ONCE_LOAD__ + __ONCE_SIZE__) + (__LC_LAST__ - __LC_START__)) + ldy #>((__ONCE_LOAD__ + __ONCE_SIZE__) + (__LC_LAST__ - __LC_START__)) + sta $96 + sty $97 + + ; Set the destination last address. + ; Aka __LC_RUN__ + __LC_SIZE__ iff segment LC exists. + lda #<__LC_LAST__ + ldy #>__LC_LAST__ + sta $94 + sty $95 + + ; Call into Applesoft Block Transfer Up -- which handles zero- + ; sized blocks well -- to move the content of the LC memory area. + jsr $D39A ; BLTU2 + + ; Switch in LC bank 2 for R/O and return. + bit $C080 + rts + +; ------------------------------------------------------------------------ .code @@ -187,6 +175,8 @@ quit: jsr $BF00 ; MLI call entry point .byte $65 ; Quit .word q_param +; ------------------------------------------------------------------------ + .rodata ; MLI parameter list for quit @@ -196,15 +186,16 @@ q_param:.byte $04 ; param_count .byte $00 ; reserved .word $0000 ; reserved +; ------------------------------------------------------------------------ + .data ; Final jump when we're done done: jmp DOSWARM ; Potentially patched at runtime +; ------------------------------------------------------------------------ + .segment "INIT" zpsave: .res zpspace - - .bss - rvsave: .res 3 diff --git a/libsrc/apple2/exehdr.s b/libsrc/apple2/exehdr.s index eb05e66be..778eee903 100644 --- a/libsrc/apple2/exehdr.s +++ b/libsrc/apple2/exehdr.s @@ -6,11 +6,11 @@ ; .export __EXEHDR__ : absolute = 1 ; Linker referenced - .import __LOADADDR__, __LOADSIZE__ ; Linker generated + .import __MAIN_START__, __MAIN_LAST__ ; Linker generated ; ------------------------------------------------------------------------ .segment "EXEHDR" - .addr __LOADADDR__ ; Load address - .word __LOADSIZE__ ; Load length + .addr __MAIN_START__ ; Load address + .word __MAIN_LAST__ - __MAIN_START__ ; Load length From d5092d2d3f37dc3522daa9306b61b6224bc57998 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 17 Mar 2016 21:31:43 +0100 Subject: [PATCH 030/407] Consider the segment attributes 'define' and 'optional' mutually exclusive. In normal situations it isn't too useful to define symbols for optional segments as those symbols can't be presumed to be always present. I in fact suspect that most currently present combinations of 'define' and 'optional' aren't useful - apart form the overlay configurations of course. --- cfg/bbc.cfg | 8 ++++---- cfg/c128.cfg | 6 +++--- cfg/c16.cfg | 6 +++--- cfg/c64.cfg | 6 +++--- cfg/cbm510.cfg | 10 +++++----- cfg/cbm610.cfg | 10 +++++----- cfg/geos-apple.cfg | 4 ++-- cfg/geos-cbm.cfg | 4 ++-- cfg/lunix.cfg | 16 ++++++++-------- cfg/nes.cfg | 14 +++++++------- cfg/none.cfg | 6 +++--- cfg/osic1p-asm.cfg | 4 ++-- cfg/pet.cfg | 6 +++--- cfg/plus4.cfg | 6 +++--- cfg/sim6502.cfg | 6 +++--- cfg/sim65c02.cfg | 6 +++--- cfg/supervision-128k.cfg | 12 ++++++------ cfg/supervision-16k.cfg | 18 +++++++++--------- cfg/supervision-64k.cfg | 12 ++++++------ cfg/supervision.cfg | 18 +++++++++--------- cfg/vic20-32k.cfg | 6 +++--- cfg/vic20.cfg | 6 +++--- 22 files changed, 95 insertions(+), 95 deletions(-) diff --git a/cfg/bbc.cfg b/cfg/bbc.cfg index f1aa4a877..60bf372f0 100644 --- a/cfg/bbc.cfg +++ b/cfg/bbc.cfg @@ -7,13 +7,13 @@ MEMORY { } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - STARTUP: load = MAIN, type = ro, define = yes; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + STARTUP: load = MAIN, type = ro, define = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/c128.cfg b/cfg/c128.cfg index 7546e7921..0ed22266c 100644 --- a/cfg/c128.cfg +++ b/cfg/c128.cfg @@ -14,13 +14,13 @@ SEGMENTS { LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; INIT: load = MAIN, type = bss; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/c16.cfg b/cfg/c16.cfg index 1aae78824..b67c66b96 100644 --- a/cfg/c16.cfg +++ b/cfg/c16.cfg @@ -14,13 +14,13 @@ SEGMENTS { LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; INIT: load = MAIN, type = bss; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/c64.cfg b/cfg/c64.cfg index 43ccce2ca..5bd8d8240 100644 --- a/cfg/c64.cfg +++ b/cfg/c64.cfg @@ -19,13 +19,13 @@ SEGMENTS { LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; INIT: load = MAIN, type = rw; - ONCE: load = MAIN, type = ro, define = yes; - BSS: load = BSS, type = bss, define = yes; + ONCE: load = MAIN, type = ro, define = yes; + BSS: load = BSS, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/cbm510.cfg b/cfg/cbm510.cfg index b4e228fdd..f4db154ab 100644 --- a/cfg/cbm510.cfg +++ b/cfg/cbm510.cfg @@ -14,18 +14,18 @@ MEMORY { } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = rw, define = yes; + EXTZP: load = ZP, type = rw, define = yes; EXEHDR: load = HEADER, type = rw; STARTUP: load = STARTUP, type = rw; PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, optional = yes; - BSS: load = MAIN, type = bss, define = yes; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/cbm610.cfg b/cfg/cbm610.cfg index 431734cd2..da829c9b4 100644 --- a/cfg/cbm610.cfg +++ b/cfg/cbm610.cfg @@ -11,18 +11,18 @@ MEMORY { } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - EXTZP: load = ZP, type = rw, define = yes; + EXTZP: load = ZP, type = rw, define = yes; EXEHDR: load = HEADER, type = rw; STARTUP: load = STARTUP, type = rw; PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = bss, optional = yes; - BSS: load = MAIN, type = bss, define = yes; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/geos-apple.cfg b/cfg/geos-apple.cfg index b39cf1ebe..2c9f6c589 100644 --- a/cfg/geos-apple.cfg +++ b/cfg/geos-apple.cfg @@ -32,7 +32,7 @@ MEMORY { } SEGMENTS { ZEROPAGE: type = zp, load = ZP; - EXTZP: type = zp, load = ZP, optional = yes; + EXTZP: type = zp, load = ZP, optional = yes; EXTBSS: type = bss, load = EXT, define = yes, optional = yes; FILEINFO: type = ro, load = CVT, offset = $002; RECORDS: type = ro, load = CVT, offset = $100, optional = yes; @@ -45,7 +45,7 @@ SEGMENTS { RODATA: type = ro, run = VLIR0, load = CVT; DATA: type = rw, run = VLIR0, load = CVT; INIT: type = bss, load = VLIR0, optional = yes; - BSS: type = bss, load = VLIR0, define = yes; + BSS: type = bss, load = VLIR0, define = yes; VLIRIDX1: type = ro, load = CVT, align = $200, optional = yes; OVERLAY1: type = ro, run = VLIR1, load = CVT, align_load = $200, optional = yes; VLIRIDX2: type = ro, load = CVT, align = $200, optional = yes; diff --git a/cfg/geos-cbm.cfg b/cfg/geos-cbm.cfg index 0269dbacb..d2e896fa5 100644 --- a/cfg/geos-cbm.cfg +++ b/cfg/geos-cbm.cfg @@ -31,7 +31,7 @@ MEMORY { } SEGMENTS { ZEROPAGE: type = zp, load = ZP; - EXTZP: type = zp, load = ZP, optional = yes; + EXTZP: type = zp, load = ZP, optional = yes; DIRENTRY: type = ro, load = CVT, align = $FE; FILEINFO: type = ro, load = CVT, align = $FE; RECORDS: type = ro, load = CVT, align = $FE, optional = yes; @@ -42,7 +42,7 @@ SEGMENTS { RODATA: type = ro, run = VLIR0, load = CVT; DATA: type = rw, run = VLIR0, load = CVT; INIT: type = bss, load = VLIR0, optional = yes; - BSS: type = bss, load = VLIR0, define = yes; + BSS: type = bss, load = VLIR0, define = yes; OVERLAY1: type = ro, run = VLIR1, load = CVT, align_load = $FE, optional = yes; OVERLAY2: type = ro, run = VLIR2, load = CVT, align_load = $FE, optional = yes; OVERLAY3: type = ro, run = VLIR3, load = CVT, align_load = $FE, optional = yes; diff --git a/cfg/lunix.cfg b/cfg/lunix.cfg index 0b7b9c8ff..560b501d5 100644 --- a/cfg/lunix.cfg +++ b/cfg/lunix.cfg @@ -9,14 +9,14 @@ MEMORY { MAIN: start = %S, size = $7600 - __STACKSIZE__; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; # Pseudo-registers - STARTUP: load = MAIN, type = ro; # First initialization code - LOWCODE: load = MAIN, type = ro, optional = yes; # Legacy from other platforms - ONCE: load = MAIN, type = ro, optional = yes; # Library initialization code - CODE: load = MAIN, type = ro; # Program - RODATA: load = MAIN, type = ro; # Literals, constants - DATA: load = MAIN, type = rw; # Initialized variables - BSS: load = MAIN, type = bss, define = yes; # Uninitialized variables + ZEROPAGE: load = ZP, type = zp, define = yes; # Pseudo-registers + STARTUP: load = MAIN, type = ro; # First initialization code + LOWCODE: load = MAIN, type = ro, optional = yes; # Legacy from other platforms + ONCE: load = MAIN, type = ro, optional = yes; # Library initialization code + CODE: load = MAIN, type = ro; # Program + RODATA: load = MAIN, type = ro; # Literals, constants + DATA: load = MAIN, type = rw; # Initialized variables + BSS: load = MAIN, type = bss, define = yes; # Uninitialized variables } FEATURES { CONDES: type = constructor, diff --git a/cfg/nes.cfg b/cfg/nes.cfg index 0cc2ce334..fdd992fe0 100644 --- a/cfg/nes.cfg +++ b/cfg/nes.cfg @@ -35,15 +35,15 @@ MEMORY { SEGMENTS { ZEROPAGE: load = ZP, type = zp; HEADER: load = HEADER, type = ro; - STARTUP: load = ROM0, type = ro, define = yes; - LOWCODE: load = ROM0, type = ro, optional = yes; - ONCE: load = ROM0, type = ro, optional = yes; - CODE: load = ROM0, type = ro, define = yes; - RODATA: load = ROM0, type = ro, define = yes; - DATA: load = ROM0, run = RAM, type = rw, define = yes; + STARTUP: load = ROM0, type = ro, define = yes; + LOWCODE: load = ROM0, type = ro, optional = yes; + ONCE: load = ROM0, type = ro, optional = yes; + CODE: load = ROM0, type = ro, define = yes; + RODATA: load = ROM0, type = ro, define = yes; + DATA: load = ROM0, run = RAM, type = rw, define = yes; VECTORS: load = ROMV, type = rw; CHARS: load = ROM2, type = rw; - BSS: load = RAM, type = bss, define = yes; + BSS: load = RAM, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/none.cfg b/cfg/none.cfg index 8cd9c4f95..6742da7c8 100644 --- a/cfg/none.cfg +++ b/cfg/none.cfg @@ -7,12 +7,12 @@ MEMORY { } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = rw; RODATA: load = MAIN, type = rw; DATA: load = MAIN, type = rw; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/osic1p-asm.cfg b/cfg/osic1p-asm.cfg index 88ab69062..1cebe4449 100644 --- a/cfg/osic1p-asm.cfg +++ b/cfg/osic1p-asm.cfg @@ -16,9 +16,9 @@ MEMORY { } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - BOOT: load = HEAD, type = ro, optional = yes; + BOOT: load = HEAD, type = ro, optional = yes; CODE: load = MAIN, type = rw; RODATA: load = MAIN, type = rw; DATA: load = MAIN, type = rw; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } diff --git a/cfg/pet.cfg b/cfg/pet.cfg index efde48efe..6eb2465b0 100644 --- a/cfg/pet.cfg +++ b/cfg/pet.cfg @@ -14,13 +14,13 @@ SEGMENTS { LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - ONCE: load = RAM, type = ro, optional = yes; + LOWCODE: load = RAM, type = ro, optional = yes; + ONCE: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; INIT: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; + BSS: load = RAM, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/plus4.cfg b/cfg/plus4.cfg index 610a7c23c..802f1076e 100644 --- a/cfg/plus4.cfg +++ b/cfg/plus4.cfg @@ -14,13 +14,13 @@ SEGMENTS { LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; INIT: load = MAIN, type = bss; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/sim6502.cfg b/cfg/sim6502.cfg index 5e7402262..b4f7738f5 100644 --- a/cfg/sim6502.cfg +++ b/cfg/sim6502.cfg @@ -11,12 +11,12 @@ SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/sim65c02.cfg b/cfg/sim65c02.cfg index 5e7402262..b4f7738f5 100644 --- a/cfg/sim65c02.cfg +++ b/cfg/sim65c02.cfg @@ -11,12 +11,12 @@ SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/supervision-128k.cfg b/cfg/supervision-128k.cfg index 6cfde6551..0304e2c02 100644 --- a/cfg/supervision-128k.cfg +++ b/cfg/supervision-128k.cfg @@ -20,8 +20,8 @@ MEMORY { ROM: file = %O, start = $c000, size = $4000, fill = yes, fillval = $FF; } SEGMENTS { - LOWCODE: load = ROM, type = ro, optional = yes; - ONCE: load = ROM, type = ro, optional = yes; + LOWCODE: load = ROM, type = ro, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro; BANK1: load = BANKROM1, type = ro; BANK2: load = BANKROM2, type = ro; @@ -30,8 +30,8 @@ SEGMENTS { BANK5: load = BANKROM5, type = ro; BANK6: load = BANKROM6, type = ro; BANK7: load = BANKROM7, type = ro; - ZEROPAGE: load = RAM, type = bss, define = yes; - DATA: load = RAM, type = bss, define = yes, offset = $0200; - BSS: load = RAM, type = bss, define = yes; - VECTOR: load = ROM, type = ro, offset = $3FFA; + ZEROPAGE: load = RAM, type = bss, define = yes; + DATA: load = RAM, type = bss, define = yes, offset = $0200; + BSS: load = RAM, type = bss, define = yes; + VECTOR: load = ROM, type = ro, offset = $3FFA; } diff --git a/cfg/supervision-16k.cfg b/cfg/supervision-16k.cfg index e42677304..86c8fface 100644 --- a/cfg/supervision-16k.cfg +++ b/cfg/supervision-16k.cfg @@ -14,15 +14,15 @@ MEMORY { ROM: file = %O, start = $C000, size = $4000, fill = yes, fillval = $ff, define=yes; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; - LOWCODE: load = ROM, type = ro, optional = yes; - ONCE: load = ROM, type = ro, optional = yes; - CODE: load = ROM, type = ro, define = yes; - RODATA: load = ROM, type = ro, define = yes; - DATA: load = ROM, run = RAM, type = rw, define = yes; - FFF0: load = ROM, type = ro, offset = $3FF0; - VECTOR: load = ROM, type = ro, offset = $3FFA; - BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp, define = yes; + LOWCODE: load = ROM, type = ro, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; + CODE: load = ROM, type = ro, define = yes; + RODATA: load = ROM, type = ro, define = yes; + DATA: load = ROM, run = RAM, type = rw, define = yes; + FFF0: load = ROM, type = ro, offset = $3FF0; + VECTOR: load = ROM, type = ro, offset = $3FFA; + BSS: load = RAM, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/supervision-64k.cfg b/cfg/supervision-64k.cfg index 18c7b4a45..8a7665c30 100644 --- a/cfg/supervision-64k.cfg +++ b/cfg/supervision-64k.cfg @@ -16,15 +16,15 @@ MEMORY { ROM: file = %O, start = $C000, size = $4000, fill = yes, fillval = $FF; } SEGMENTS { - LOWCODE: load = ROM, type = ro, optional = yes; - ONCE: load = ROM, type = ro, optional = yes; + LOWCODE: load = ROM, type = ro, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro; RODATA: load = ROM, type = ro; BANK1: load = BANKROM1, type = ro; BANK2: load = BANKROM2, type = ro; BANK3: load = BANKROM3, type = ro; - ZEROPAGE: load = RAM, type = bss, define = yes; - DATA: load = RAM, type = bss, define = yes, offset = $0200; - BSS: load = RAM, type = bss, define = yes; - VECTOR: load = ROM, type = ro, offset = $3FFA; + ZEROPAGE: load = RAM, type = bss, define = yes; + DATA: load = RAM, type = bss, define = yes, offset = $0200; + BSS: load = RAM, type = bss, define = yes; + VECTOR: load = ROM, type = ro, offset = $3FFA; } diff --git a/cfg/supervision.cfg b/cfg/supervision.cfg index c96351e5f..2d20e3461 100644 --- a/cfg/supervision.cfg +++ b/cfg/supervision.cfg @@ -13,15 +13,15 @@ MEMORY { ROM: file = %O, start = $8000, size = $8000, fill = yes, fillval = $FF, define = yes; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; - LOWCODE: load = ROM, type = ro, optional = yes; - ONCE: load = ROM, type = ro, optional = yes; - CODE: load = ROM, type = ro, define = yes; - RODATA: load = ROM, type = ro, define = yes; - DATA: load = ROM, run = RAM, type = rw, define = yes; - FFF0: load = ROM, type = ro, offset = $7FF0; - VECTOR: load = ROM, type = ro, offset = $7FFA; - BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp, define = yes; + LOWCODE: load = ROM, type = ro, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; + CODE: load = ROM, type = ro, define = yes; + RODATA: load = ROM, type = ro, define = yes; + DATA: load = ROM, run = RAM, type = rw, define = yes; + FFF0: load = ROM, type = ro, offset = $7FF0; + VECTOR: load = ROM, type = ro, offset = $7FFA; + BSS: load = RAM, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/vic20-32k.cfg b/cfg/vic20-32k.cfg index f592d7bd0..28dd661ad 100644 --- a/cfg/vic20-32k.cfg +++ b/cfg/vic20-32k.cfg @@ -16,13 +16,13 @@ SEGMENTS { LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; INIT: load = MAIN, type = bss; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/cfg/vic20.cfg b/cfg/vic20.cfg index 98f6f82b3..ceaee3a87 100644 --- a/cfg/vic20.cfg +++ b/cfg/vic20.cfg @@ -14,13 +14,13 @@ SEGMENTS { LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = HEADER, type = ro; STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - ONCE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; DATA: load = MAIN, type = rw; INIT: load = MAIN, type = bss; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes; } FEATURES { CONDES: type = constructor, From 78dcb61cb8d59efa93ac8d5cb4fa08598553121a Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 17 Mar 2016 21:51:20 +0100 Subject: [PATCH 031/407] Harmonized asm linker configs. - All segments but CODE are optional and CODE is R/W. Both together allow to "just" write code/data without ever explicitly using a segment. - Symbols are defined for the BSS. This allows to use/implement zerobss. - The ZP memory area isn't artificially limited. --- cfg/apple2-asm.cfg | 2 +- cfg/apple2enh-asm.cfg | 2 +- cfg/atari-asm.cfg | 20 ++++++++++---------- cfg/c64-asm.cfg | 6 +++--- cfg/osic1p-asm.cfg | 12 ++++++------ 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cfg/apple2-asm.cfg b/cfg/apple2-asm.cfg index 151ba84c4..8e5abefc5 100644 --- a/cfg/apple2-asm.cfg +++ b/cfg/apple2-asm.cfg @@ -12,7 +12,7 @@ MEMORY { SEGMENTS { ZEROPAGE: load = ZP, type = zp, optional = yes; EXEHDR: load = HEADER, type = ro, optional = yes; - CODE: load = MAIN, type = rw, optional = yes; + CODE: load = MAIN, type = rw; RODATA: load = MAIN, type = ro, optional = yes; DATA: load = MAIN, type = rw, optional = yes; BSS: load = BSS, type = bss, optional = yes, define = yes; diff --git a/cfg/apple2enh-asm.cfg b/cfg/apple2enh-asm.cfg index 151ba84c4..8e5abefc5 100644 --- a/cfg/apple2enh-asm.cfg +++ b/cfg/apple2enh-asm.cfg @@ -12,7 +12,7 @@ MEMORY { SEGMENTS { ZEROPAGE: load = ZP, type = zp, optional = yes; EXEHDR: load = HEADER, type = ro, optional = yes; - CODE: load = MAIN, type = rw, optional = yes; + CODE: load = MAIN, type = rw; RODATA: load = MAIN, type = ro, optional = yes; DATA: load = MAIN, type = rw, optional = yes; BSS: load = BSS, type = bss, optional = yes, define = yes; diff --git a/cfg/atari-asm.cfg b/cfg/atari-asm.cfg index bea547765..6fc1c2caa 100644 --- a/cfg/atari-asm.cfg +++ b/cfg/atari-asm.cfg @@ -3,7 +3,7 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; - __AUTOSTART__: type = import; # force inclusion of autostart "trailer" + __AUTOSTART__: type = import; # force inclusion of autostart "trailer" __STARTADDRESS__: type = export, value = %S; } MEMORY { @@ -18,13 +18,13 @@ MEMORY { TRAILER: file = %O, start = $0000, size = $0006; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, optional = yes; - EXTZP: load = ZP, type = zp, optional = yes; # to enable modules to be able to link to C and assembler programs - EXEHDR: load = HEADER, type = ro, optional = yes; - MAINHDR: load = MAINHDR, type = ro, optional = yes; - CODE: load = MAIN, type = ro, define = yes, optional = yes; - RODATA: load = MAIN, type = ro optional = yes; - DATA: load = MAIN, type = rw optional = yes; - BSS: load = MAIN, type = bss, define = yes, optional = yes; - AUTOSTRT: load = TRAILER, type = ro, optional = yes; + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXTZP: load = ZP, type = zp, optional = yes; # to enable modules to be able to link to C and assembler programs + EXEHDR: load = HEADER, type = ro, optional = yes; + MAINHDR: load = MAINHDR, type = ro, optional = yes; + CODE: load = MAIN, type = rw, define = yes; + RODATA: load = MAIN, type = ro optional = yes; + DATA: load = MAIN, type = rw optional = yes; + BSS: load = MAIN, type = bss, optional = yes, define = yes; + AUTOSTRT: load = TRAILER, type = ro, optional = yes; } diff --git a/cfg/c64-asm.cfg b/cfg/c64-asm.cfg index 25d12ee71..e2dda5362 100644 --- a/cfg/c64-asm.cfg +++ b/cfg/c64-asm.cfg @@ -5,7 +5,7 @@ SYMBOLS { __LOADADDR__: type = import; } MEMORY { - ZP: file = "", start = $0002, size = $001A, define = yes; + ZP: file = "", start = $0002, size = $00FE, define = yes; LOADADDR: file = %O, start = %S - 2, size = $0002; MAIN: file = %O, start = %S, size = $D000 - %S; } @@ -13,8 +13,8 @@ SEGMENTS { ZEROPAGE: load = ZP, type = zp, optional = yes; LOADADDR: load = LOADADDR, type = ro; EXEHDR: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = rw, optional = yes; + CODE: load = MAIN, type = rw; RODATA: load = MAIN, type = ro, optional = yes; DATA: load = MAIN, type = rw, optional = yes; - BSS: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, optional = yes, define = yes; } diff --git a/cfg/osic1p-asm.cfg b/cfg/osic1p-asm.cfg index 1cebe4449..a16f248ab 100644 --- a/cfg/osic1p-asm.cfg +++ b/cfg/osic1p-asm.cfg @@ -10,15 +10,15 @@ SYMBOLS { } MEMORY { # for size of ZP, see runtime/zeropage.s and c1p/extzp.s - ZP: file = "", define = yes, start = $0002, size = $001A + $0006; + ZP: file = "", define = yes, start = $0002, size = $00FE; HEAD: file = %O, start = $0000, size = $00B6; - MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; + MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp; + ZEROPAGE: load = ZP, type = zp, optional = yes; BOOT: load = HEAD, type = ro, optional = yes; CODE: load = MAIN, type = rw; - RODATA: load = MAIN, type = rw; - DATA: load = MAIN, type = rw; - BSS: load = MAIN, type = bss, define = yes; + RODATA: load = MAIN, type = ro, optional = yes; + DATA: load = MAIN, type = rw, optional = yes; + BSS: load = MAIN, type = bss, optional = yes, define = yes; } From 7773fcb1e124805eec492ebe77af6b6d69475605 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Fri, 18 Mar 2016 11:28:56 -0400 Subject: [PATCH 032/407] Converted the Atmos configuration to the new constructor segment model. --- cfg/atmos.cfg | 16 ++++----- libsrc/atmos/bashdr.s | 12 ++++++- libsrc/atmos/capslock.s | 3 +- libsrc/atmos/cgetc.s | 4 +-- libsrc/atmos/crt0.s | 79 +++++++++++++++++++---------------------- libsrc/atmos/mainargs.s | 5 ++- libsrc/atmos/tapehdr.s | 23 ++++++------ 7 files changed, 73 insertions(+), 69 deletions(-) diff --git a/cfg/atmos.cfg b/cfg/atmos.cfg index bb79a1e8a..35f184f4f 100644 --- a/cfg/atmos.cfg +++ b/cfg/atmos.cfg @@ -11,22 +11,22 @@ MEMORY { ZP: file = "", define = yes, start = $00E2, size = $001A; TAPEHDR: file = %O, type = ro, start = $0000, size = $001F; BASHEAD: file = %O, define = yes, start = $0501, size = $000D; - MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__ - __STACKSIZE__; + MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__; + BSS: file = "", start = __ONCE_RUN__, size = __RAMEND__ - __STACKSIZE__ - __ONCE_RUN__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; TAPEHDR: load = TAPEHDR, type = ro; - BASHDR: load = BASHEAD, type = ro, define = yes, optional = yes; + BASHDR: load = BASHEAD, type = ro, optional = yes; STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; + LOWCODE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; RODATA: load = MAIN, type = ro; - ONCE: load = MAIN, type = ro, optional = yes; DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = rw, optional = yes; - ZPSAVE1: load = MAIN, type = rw, define = yes; # ZPSAVE1, ZPSAVE2 must be together - ZPSAVE2: load = MAIN, type = bss; # see "libsrc/atmos/crt0.s" - BSS: load = MAIN, type = bss, define = yes; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + BASTAIL: load = MAIN, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; } FEATURES { CONDES: type = constructor, diff --git a/libsrc/atmos/bashdr.s b/libsrc/atmos/bashdr.s index e09bc9fec..79cf9acb1 100644 --- a/libsrc/atmos/bashdr.s +++ b/libsrc/atmos/bashdr.s @@ -1,6 +1,6 @@ ; ; 2010-11-14, Ullrich von Bassewitz -; 2014-09-06, Greg King +; 2016-03-17, Greg King ; ; This module supplies a small BASIC stub program that uses CALL ; to jump to the machine-language code that follows it. @@ -22,3 +22,13 @@ .byte $00 ; End of BASIC line Next: .addr $0000 ; BASIC program end marker Start: + +; ------------------------------------------------------------------------ + +; This padding is needed by a bug in the ROM. +; (The CLOAD command starts BASIC's variables table on top of the last byte +; that was loaded [instead of at the next address].) + +.segment "BASTAIL" + + .byte 0 diff --git a/libsrc/atmos/capslock.s b/libsrc/atmos/capslock.s index 0260b3f9f..1451513b4 100644 --- a/libsrc/atmos/capslock.s +++ b/libsrc/atmos/capslock.s @@ -15,7 +15,8 @@ ;-------------------------------------------------------------------------- -; Put this constructor into a segment that can be re-used by programs. +; Put this constructor into a segment whose space +; will be re-used by BSS, the heap, and the C stack. ; .segment "ONCE" diff --git a/libsrc/atmos/cgetc.s b/libsrc/atmos/cgetc.s index 64d597bc6..f1d727a50 100644 --- a/libsrc/atmos/cgetc.s +++ b/libsrc/atmos/cgetc.s @@ -55,8 +55,8 @@ .endproc ; ------------------------------------------------------------------------ -; Switch the cursor off. Code goes into the ONCE segment -; which may be reused after it is run. +; Switch the cursor off. Code goes into the ONCE segment, +; which will be reused after it is run. .segment "ONCE" diff --git a/libsrc/atmos/crt0.s b/libsrc/atmos/crt0.s index 6ad7a3ff3..8c2be656c 100644 --- a/libsrc/atmos/crt0.s +++ b/libsrc/atmos/crt0.s @@ -2,14 +2,15 @@ ; Startup code for cc65 (Oric version) ; ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org> -; 2015-01-09, Greg King +; 2016-03-18, Greg King ; .export _exit .export __STARTUP__ : absolute = 1 ; Mark as startup + .import initlib, donelib .import callmain, zerobss - .import __MAIN_START__, __MAIN_SIZE__, __STACKSIZE__ + .import __MAIN_START__, __MAIN_SIZE__ .include "zeropage.inc" .include "atmos.inc" @@ -19,39 +20,17 @@ .segment "STARTUP" -; Save the zero-page area that we're about to use. - - ldx #zpspace-1 -L1: lda sp,x - sta zpsave,x - dex - bpl L1 - -; Clear the BSS data. - - jsr zerobss - -; Currently, color isn't supported on the text screen. -; Unprotect screen columns 0 and 1 (where each line's color codes would sit). - - lda STATUS - sta stsave - and #%11011111 - sta STATUS - -; Save some system stuff; and, set up the stack. - tsx stx spsave ; Save system stk ptr - lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - sta sp - stx sp+1 ; Set argument stack ptr +; Save space by putting some of the start-up code in a segment +; that will be re-used. -; Call the module constructors. + jsr init - jsr initlib +; Clear the BSS variables (after the constructors have been run). + + jsr zerobss ; Push the command-line arguments; and, call main(). @@ -70,7 +49,7 @@ _exit: jsr donelib ; Copy back the zero-page stuff. - ldx #zpspace-1 + ldx #zpspace - 1 L2: lda zpsave,x sta sp,x dex @@ -81,28 +60,42 @@ L2: lda zpsave,x rts ; ------------------------------------------------------------------------ +; Put this code in a place that will be re-used by BSS, the heap, +; and the C stack. -.segment "ZPSAVE1" +.segment "ONCE" -zpsave: +; Save the zero-page area that we're about to use. -; This padding is needed by a bug in the ROM. -; (The CLOAD command starts BASIC's variables table on top of the last byte -; that was loaded [instead of at the next address].) -; This is overlaid on a buffer, so that it doesn't use extra space in RAM. +init: ldx #zpspace - 1 +L1: lda sp,x + sta zpsave,x + dex + bpl L1 - .byte 0 +; Currently, color isn't supported on the text screen. +; Unprotect screen columns 0 and 1 (where each line's color codes would sit). -; The segments "ZPSAVE1" and "ZPSAVE2" always must be together. -; They create a single object (the zpsave buffer). + lda STATUS + sta stsave + and #%11011111 + sta STATUS -.segment "ZPSAVE2" +; Set up the C stack. - .res zpspace - 1 + lda #<(__MAIN_START__ + __MAIN_SIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__) + sta sp + stx sp+1 ; Set argument stack ptr + +; Call the module constructors. + + jmp initlib ; ------------------------------------------------------------------------ -.bss +.segment "INIT" spsave: .res 1 stsave: .res 1 +zpsave: .res zpspace diff --git a/libsrc/atmos/mainargs.s b/libsrc/atmos/mainargs.s index 3ab353c15..b8d19dccc 100644 --- a/libsrc/atmos/mainargs.s +++ b/libsrc/atmos/mainargs.s @@ -18,7 +18,7 @@ REM = $9D ; BASIC token-code ;--------------------------------------------------------------------------- ; Get possible command-line arguments. Goes into the special ONCE segment, -; which may be reused after the startup code is run +; which will be reused after the startup code is run. .segment "ONCE" @@ -119,8 +119,6 @@ done: lda #<argv .endproc -; These arrays are zeroed before initmainargs is called. - .segment "INIT" term: .res 1 @@ -129,6 +127,7 @@ args: .res SCREEN_XSIZE * 2 - 1 .data +; This array has zeroes when initmainargs starts. ; char* argv[MAXARGS+1]={name}; argv: .addr name diff --git a/libsrc/atmos/tapehdr.s b/libsrc/atmos/tapehdr.s index d90c908eb..1848c48cb 100644 --- a/libsrc/atmos/tapehdr.s +++ b/libsrc/atmos/tapehdr.s @@ -1,6 +1,6 @@ ; ; Based on code by Debrune Jérôme <jede@oric.org> -; 2015-01-08, Greg King +; 2016-03-17, Greg King ; ; The following symbol is used by the linker config. file @@ -8,7 +8,8 @@ .export __TAPEHDR__:abs = 1 ; These symbols, also, come from the configuration file. - .import __BASHDR_LOAD__, __ZPSAVE1_LOAD__, __AUTORUN__, __PROGFLAG__ + .import __AUTORUN__, __PROGFLAG__ + .import __BASHEAD_START__, __MAIN_LAST__ ; ------------------------------------------------------------------------ @@ -16,16 +17,16 @@ .segment "TAPEHDR" - .byte $16, $16, $16 ; Sync bytes - .byte $24 ; Beginning-of-header marker + .byte $16, $16, $16 ; Sync bytes + .byte $24 ; Beginning-of-header marker - .byte $00 ; $2B0 - .byte $00 ; $2AF - .byte <__PROGFLAG__ ; $2AE Language flag ($00=BASIC, $80=machine code) - .byte <__AUTORUN__ ; $2AD Auto-run flag ($C7=run, $00=only load) - .dbyt __ZPSAVE1_LOAD__ ;$2AB Address of end of file - .dbyt __BASHDR_LOAD__ ; $2A9 Address of start of file - .byte $00 ; $2A8 + .byte $00 ; $2B0 + .byte $00 ; $2AF + .byte <__PROGFLAG__ ; $2AE Language flag ($00=BASIC, $80=machine code) + .byte <__AUTORUN__ ; $2AD Auto-run flag ($C7=run, $00=only load) + .dbyt __MAIN_LAST__ - 1 ; $2AB Address of end of file + .dbyt __BASHEAD_START__ ; $2A9 Address of start of file + .byte $00 ; $2A8 ; File name (a maximum of 17 characters), zero-terminated .asciiz .sprintf("%u", .time) From 9aac382afbd7ba689659ea53bbdc1b7eada3318c Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 25 Mar 2016 18:48:23 +0100 Subject: [PATCH 033/407] Updated documentation to reflect the current linker configs. --- doc/apple2.sgml | 185 +++++++++++++++++++++++--------------------- doc/apple2enh.sgml | 189 +++++++++++++++++++++++---------------------- 2 files changed, 192 insertions(+), 182 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index e58565359..7443e50b7 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -75,13 +75,30 @@ However while running module constructors/destructors the Language Card is disab Enabling the Language Card allows to use it as additional memory for cc65 generated code. However code is never automatically placed there. Rather code needs to be explicitly placed in the Language Card either per file by compiling -with <tt/--code-name HIGHCODE/ or per function by enclosing in <tt/#pragma -code-name (push, "HIGHCODE")/ and <tt/#pragma code-name (pop)/. In either case the -cc65 runtime system takes care of actually moving the code into the Language -Card. +with <tt/--code-name LC/ or per function by enclosing in <tt/#pragma code-name +(push, "LC")/ and <tt/#pragma code-name (pop)/. In either case the cc65 runtime +system takes care of actually moving the code into the Language Card. The amount of memory available in the Language Card for generated code depends -on the chosen <ref id="link-configs" name="linker configuration">. +on the <ref id="link-configs" name="linker configuration"> parameters. There are +several usefull settings: + +<descrip> + + <tag>LCADDR: $D400, LCSIZE: $C00</tag> + For plain vanilla ProDOS 8 which doesn't actually use the Language Card bank 2 + memory from $D400 to $DFFF. This is the default setting. + + <tag>LCADDR: $D000, LCSIZE: $1000</tag> + For ProDOS 8 together with the function <tt/rebootafterexit()/. If a program + doesn't quit to the ProDOS 8 dispatcher but rather reboots the machine after + exit then a plain vanilla ProDOS 8 doesn't make use of the Language Card bank + 2 at all. + + <tag>LCADDR: $D000, LCSIZE: $3000</tag> + For plain vanilla DOS 3.3 which doesn't make use of the Language Card at all. + +</descrip><p> @@ -93,126 +110,114 @@ The apple2 package comes with additional secondary linker config files, which are used via <tt/-t apple2 -C <configfile>/. -<sect1>default config file (<tt/apple2.cfg/)<p> +<sect1>default config file (<tt/apple2.cfg/)<label id="apple-def-cfg"><p> -Default configuration optimized for a binary program running on ProDOS 8 with -BASIC.SYSTEM. A plain vanilla ProDOS 8 doesn't actually use the Language Card -bank 2 memory from $D400 to $DFFF. +Default configuration for a binary program. + +Parameters: <descrip> - <tag><tt/RAM:/ Main memory area</tag> - From $803 to $95FF (35.5 KB) - - <tag><tt/LC:/ Language Card memory area</tag> - From $D400 to $DFFF (3 KB) - <tag><tt/STARTADDRESS:/ Program start address</tag> - Variable (default: $803) + Default: $803. Use <tt/-S <addr>/ to set a different start address. - <tag><tt/HEADER:/ Binary file header</tag> - DOS 3.3 header (address and length) + <tag><tt/__EXEHDR__:/ Executable file header</tag> + Default: DOS 3.3 header (address and length). Use <tt/-D __EXEHDR__=0/ to omit + the header. -</descrip><p> + <tag><tt/__STACKSIZE__:/ C runtime stack size</tag> + Default: $800. Use <tt/-D __STACKSIZE__=<size>/ to set a different + stack size. + <tag><tt/__HIMEM__:/ Highest usable memory address presumed at link time</tag> + Default: $9600. Use <tt/-D __HIMEM__=<addr>/ to set a different + highest usable address. -<sect1><tt/apple2-dos33.cfg/<p> + <tag><tt/__LCADDR__:/ Address of code in the Language Card</tag> + Default: $D400. Use <tt/-D __LCADDR__=<addr>/ to set a different + code address. -Configuration optimized for a binary program running on DOS 3.3. A plain -vanilla DOS 3.3 doesn't make use of the Language Card at all. - -<descrip> - - <tag><tt/RAM:/ Main memory area</tag> - From $803 to $95FF (35.5 KB) - - <tag><tt/LC:/ Language Card memory area</tag> - From $D000 to $FFFF (12 KB) - - <tag><tt/STARTADDRESS:/ Program start address</tag> - Variable (default: $803) - - <tag><tt/HEADER:/ Binary file header</tag> - DOS 3.3 header (address and length) + <tag><tt/__LCSIZE__:/ Size of code in the Language Card</tag> + Default: $C00. Use <tt/-D __LCSIZE__=<size>/ to set a different + code size. </descrip><p> <sect1><tt/apple2-system.cfg/<label id="apple-sys-cfg"><p> -Configuration for a system program running on ProDOS 8. +Configuration for a system program running on ProDOS 8 and using the memory from +$2000 to $BEFF. <descrip> - <tag><tt/RAM:/ Main memory area</tag> - From $2000 to $BEFF (39.75 KB) + <tag><tt/__STACKSIZE__:/ C runtime stack size</tag> + Default: $800. Use <tt/-D __STACKSIZE__=<size>/ to set a different + stack size. - <tag><tt/LC:/ Language Card memory area</tag> - From $D400 to $DFFF (3 KB) + <tag><tt/__LCADDR__:/ Address of code in the Language Card</tag> + Default: $D400. Use <tt/-D __LCADDR__=<addr>/ to set a different + code address. - <tag><tt/STARTADDRESS:/ Program start address</tag> - Fixed ($2000) - - <tag><tt/HEADER:/ Binary file header</tag> - None + <tag><tt/__LCSIZE__:/ Size of code in the Language Card</tag> + Default: $C00. Use <tt/-D __LCSIZE__=<size>/ to set a different + code size. </descrip><p> -<sect1><tt/apple2-loader.cfg/<label id="apple-load-cfg"><p> +<sect1><tt/apple2-overlay.cfg/<p> -Configuration optimized for a binary program running on ProDOS 8 without -BASIC.SYSTEM. Intended to be used with <bf/LOADER.SYSTEM - an -Apple ][ ProDOS 8 loader for cc65 programs/, which is available -in the cc65 User Contributions section. - -A program loaded by LOADER.SYSTEM works like a ProDOS 8 system program but -isn't tied to the start address $2000. Thus with the default start -address $800 the main memory area is increased by 6 KB. +Configuration for overlay programs with the up to nine overlays. The overlay files +don't include the DOS 3.3 header. See <tt>samples/overlaydemo.c</tt> for more +information on overlays. <descrip> - <tag><tt/RAM:/ Main memory area</tag> - From $800 to $BEFF (45.75 KB) - - <tag><tt/LC:/ Language Card memory area</tag> - From $D400 to $DFFF (3 KB) - <tag><tt/STARTADDRESS:/ Program start address</tag> - Variable (default: $800) + Default: $803. Use <tt/-S <addr>/ to set a different start address. - <tag><tt/HEADER:/ Binary file header</tag> - DOS 3.3 header (address and length) + <tag><tt/__EXEHDR__:/ Executable file header</tag> + Default: DOS 3.3 header (address and length). Use <tt/-D __EXEHDR__=0/ to omit + the header. + + <tag><tt/__STACKSIZE__:/ C runtime stack size</tag> + Default: $800. Use <tt/-D __STACKSIZE__=<size>/ to set a different + stack size. + + <tag><tt/__HIMEM__:/ Highest usable memory address presumed at link time</tag> + Default: $9600. Use <tt/-D __HIMEM__=<addr>/ to set a different + highest usable address. + + <tag><tt/__LCADDR__:/ Address of code in the Language Card</tag> + Default: $D400. Use <tt/-D __LCADDR__=<addr>/ to set a different + code address. + + <tag><tt/__LCSIZE__:/ Size of code in the Language Card</tag> + Default: $C00. Use <tt/-D __LCSIZE__=<size>/ to set a different + code size. + + <tag><tt/__OVERLAYSIZE__:/ Size of code in the overlays</tag> + Default: $1000. Use <tt/-D __OVERLAYSIZE__=<size>/ to set a different + code size. </descrip><p> -<sect1><tt/apple2-reboot.cfg/<p> +<sect1><tt/apple2-asm.cfg/<p> -Configuration optimized for a binary program running on ProDOS 8 without -BASIC.SYSTEM. Intended to be used with <bf/LOADER.SYSTEM - an -Apple ][ ProDOS 8 loader for cc65 programs/ (see above) together -with the function <tt/rebootafterexit()/. +Configuration for a assembler programs which don't need a special setup. -If a ProDOS 8 system program doesn't quit to the ProDOS 8 dispatcher but rather -reboots the machine after exit then a plain vanilla ProDOS 8 doesn't make use of -the Language Card bank 2 at all. - -This setup makes nearly 50 KB available to a cc65 program - on a 64 KB machine! +Parameters: <descrip> - <tag><tt/RAM:/ Main memory area</tag> - From $800 to $BEFF (45.75 KB) - - <tag><tt/LC:/ Language Card memory area</tag> - From $D000 to $DFFF (4 KB) - <tag><tt/STARTADDRESS:/ Program start address</tag> - Variable (default: $800) + Default: $803. Use <tt/-S <addr>/ to set a different start address. - <tag><tt/HEADER:/ Binary file header</tag> - DOS 3.3 header (address and length) + <tag><tt/__EXEHDR__:/ Executable file header</tag> + Default: No header. Use <tt/-u __EXEHDR__ apple2.lib/ to add a DOS 3.3 header + (address and length). </descrip><p> @@ -230,10 +235,10 @@ range. The easiest (and for really large programs in fact the only) way to have a cc65 program use the memory from $800 to $2000 is to link it as binary -(as opposed to system) program using the linker configuration -<ref id="apple-load-cfg" name="apple2-loader.cfg"> with start address -$803 and load it with the targetutil LOADER.SYSTEM. The program then works -like a system program (i.e. quits to the ProDOS dispatcher). +(as opposed to system) program using the default linker configuration +<ref id="apple-def-cfg" name="apple2.cfg"> with __HIMEM__ set to $BF00 +and load it with the targetutil LOADER.SYSTEM. The program then works like a system +program (i.e. quits to the ProDOS dispatcher). Using LOADER.SYSTEM is as simple as copying it to the ProDOS 8 directory of the program to load under name <program>.SYSTEM as a system program. For @@ -325,8 +330,8 @@ The names in the parentheses denote the symbols to be used for static linking of <tag><tt/a2.hi.tgi (a2_hi_tgi)/</tag> This driver features a resolution of 280×192 with 8 colors and two hires pages. Note that programs using this driver will have to be linked - with <tt/--start-addr $4000/ to reserve the first hires page or with - <tt/--start-addr $6000/ to reserve both hires pages. + with <tt/-S $4000/ to reserve the first hires page or with <tt/-S $6000/ + to reserve both hires pages. The function <tt/tgi_apple2_mix()/ allows to activate 4 lines of text. The function doesn't clear the corresponding area at the bottom of the screen. @@ -374,7 +379,7 @@ The names in the parentheses denote the symbols to be used for static linking of for an AppleMouse II Card compatible firmware. The default bounding box is [0..279,0..191]. - Programs using this driver will have to be linked with <tt/--start-addr $4000/ + Programs using this driver will have to be linked with <tt/-S $4000/ to reserve the first hires page if they are intended to run on an Apple ][ (in contrast to an Apple //e) because the AppleMouse II Card firmware writes to the hires page when initializing diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 215c6d384..5a9da7704 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -75,13 +75,30 @@ However while running module constructors/destructors the Language Card is disab Enabling the Language Card allows to use it as additional memory for cc65 generated code. However code is never automatically placed there. Rather code needs to be explicitly placed in the Language Card either per file by compiling -with <tt/--code-name HIGHCODE/ or per function by enclosing in <tt/#pragma -code-name (push, "HIGHCODE")/ and <tt/#pragma code-name (pop)/. In either case the -cc65 runtime system takes care of actually moving the code into the Language -Card. +with <tt/--code-name LC/ or per function by enclosing in <tt/#pragma code-name +(push, "LC")/ and <tt/#pragma code-name (pop)/. In either case the cc65 runtime +system takes care of actually moving the code into the Language Card. The amount of memory available in the Language Card for generated code depends -on the chosen <ref id="link-configs" name="linker configuration">. +on the <ref id="link-configs" name="linker configuration"> parameters. There are +several usefull settings: + +<descrip> + + <tag>LCADDR: $D400, LCSIZE: $C00</tag> + For plain vanilla ProDOS 8 which doesn't actually use the Language Card bank 2 + memory from $D400 to $DFFF. This is the default setting. + + <tag>LCADDR: $D000, LCSIZE: $1000</tag> + For ProDOS 8 together with the function <tt/rebootafterexit()/. If a program + doesn't quit to the ProDOS 8 dispatcher but rather reboots the machine after + exit then a plain vanilla ProDOS 8 doesn't make use of the Language Card bank + 2 at all. + + <tag>LCADDR: $D000, LCSIZE: $3000</tag> + For plain vanilla DOS 3.3 which doesn't make use of the Language Card at all. + +</descrip><p> @@ -93,126 +110,114 @@ The apple2enh package comes with additional secondary linker config files, which are used via <tt/-t apple2enh -C <configfile>/. -<sect1>default config file (<tt/apple2enh.cfg/)<p> +<sect1>default config file (<tt/apple2enh.cfg/)<label id="apple-def-cfg"><p> -Default configuration optimized for a binary program running on ProDOS 8 with -BASIC.SYSTEM. A plain vanilla ProDOS 8 doesn't actually use the Language Card -bank 2 memory from $D400 to $DFFF. +Default configuration for a binary program. + +Parameters: <descrip> - <tag><tt/RAM:/ Main memory area</tag> - From $803 to $95FF (35.5 KB) - - <tag><tt/LC:/ Language Card memory area</tag> - From $D400 to $DFFF (3 KB) - <tag><tt/STARTADDRESS:/ Program start address</tag> - Variable (default: $803) + Default: $803. Use <tt/-S <addr>/ to set a different start address. - <tag><tt/HEADER:/ Binary file header</tag> - DOS 3.3 header (address and length) + <tag><tt/__EXEHDR__:/ Executable file header</tag> + Default: DOS 3.3 header (address and length). Use <tt/-D __EXEHDR__=0/ to omit + the header. -</descrip><p> + <tag><tt/__STACKSIZE__:/ C runtime stack size</tag> + Default: $800. Use <tt/-D __STACKSIZE__=<size>/ to set a different + stack size. + <tag><tt/__HIMEM__:/ Highest usable memory address presumed at link time</tag> + Default: $9600. Use <tt/-D __HIMEM__=<addr>/ to set a different + highest usable address. -<sect1><tt/apple2enh-dos33.cfg/<p> + <tag><tt/__LCADDR__:/ Address of code in the Language Card</tag> + Default: $D400. Use <tt/-D __LCADDR__=<addr>/ to set a different + code address. -Configuration optimized for a binary program running on DOS 3.3. A plain -vanilla DOS 3.3 doesn't make use of the Language Card at all. - -<descrip> - - <tag><tt/RAM:/ Main memory area</tag> - From $803 to $95FF (35.5 KB) - - <tag><tt/LC:/ Language Card memory area</tag> - From $D000 to $FFFF (12 KB) - - <tag><tt/STARTADDRESS:/ Program start address</tag> - Variable (default: $803) - - <tag><tt/HEADER:/ Binary file header</tag> - DOS 3.3 header (address and length) + <tag><tt/__LCSIZE__:/ Size of code in the Language Card</tag> + Default: $C00. Use <tt/-D __LCSIZE__=<size>/ to set a different + code size. </descrip><p> <sect1><tt/apple2enh-system.cfg/<label id="apple-sys-cfg"><p> -Configuration for a system program running on ProDOS 8. +Configuration for a system program running on ProDOS 8 and using the memory from +$2000 to $BEFF. <descrip> - <tag><tt/RAM:/ Main memory area</tag> - From $2000 to $BEFF (39.75 KB) + <tag><tt/__STACKSIZE__:/ C runtime stack size</tag> + Default: $800. Use <tt/-D __STACKSIZE__=<size>/ to set a different + stack size. - <tag><tt/LC:/ Language Card memory area</tag> - From $D400 to $DFFF (3 KB) + <tag><tt/__LCADDR__:/ Address of code in the Language Card</tag> + Default: $D400. Use <tt/-D __LCADDR__=<addr>/ to set a different + code address. - <tag><tt/STARTADDRESS:/ Program start address</tag> - Fixed ($2000) - - <tag><tt/HEADER:/ Binary file header</tag> - None + <tag><tt/__LCSIZE__:/ Size of code in the Language Card</tag> + Default: $C00. Use <tt/-D __LCSIZE__=<size>/ to set a different + code size. </descrip><p> -<sect1><tt/apple2enh-loader.cfg/<label id="apple-load-cfg"><p> +<sect1><tt/apple2enh-overlay.cfg/<p> -Configuration optimized for a binary program running on ProDOS 8 without -BASIC.SYSTEM. Intended to be used with <bf/LOADER.SYSTEM - an -Apple ][ ProDOS 8 loader for cc65 programs/, which is available -in the cc65 User Contributions section. - -A program loaded by LOADER.SYSTEM works like a ProDOS 8 system program but -isn't tied to the start address $2000. Thus with the default start -address $800 the main memory area is increased by 6 KB. +Configuration for overlay programs with the up to nine overlays. The overlay files +don't include the DOS 3.3 header. See <tt>samples/overlaydemo.c</tt> for more +information on overlays. <descrip> - <tag><tt/RAM:/ Main memory area</tag> - From $800 to $BEFF (45.75 KB) - - <tag><tt/LC:/ Language Card memory area</tag> - From $D400 to $DFFF (3 KB) - <tag><tt/STARTADDRESS:/ Program start address</tag> - Variable (default: $800) + Default: $803. Use <tt/-S <addr>/ to set a different start address. - <tag><tt/HEADER:/ Binary file header</tag> - DOS 3.3 header (address and length) + <tag><tt/__EXEHDR__:/ Executable file header</tag> + Default: DOS 3.3 header (address and length). Use <tt/-D __EXEHDR__=0/ to omit + the header. + + <tag><tt/__STACKSIZE__:/ C runtime stack size</tag> + Default: $800. Use <tt/-D __STACKSIZE__=<size>/ to set a different + stack size. + + <tag><tt/__HIMEM__:/ Highest usable memory address presumed at link time</tag> + Default: $9600. Use <tt/-D __HIMEM__=<addr>/ to set a different + highest usable address. + + <tag><tt/__LCADDR__:/ Address of code in the Language Card</tag> + Default: $D400. Use <tt/-D __LCADDR__=<addr>/ to set a different + code address. + + <tag><tt/__LCSIZE__:/ Size of code in the Language Card</tag> + Default: $C00. Use <tt/-D __LCSIZE__=<size>/ to set a different + code size. + + <tag><tt/__OVERLAYSIZE__:/ Size of code in the overlays</tag> + Default: $1000. Use <tt/-D __OVERLAYSIZE__=<size>/ to set a different + code size. </descrip><p> -<sect1><tt/apple2enh-reboot.cfg/<p> +<sect1><tt/apple2enh-asm.cfg/<p> -Configuration optimized for a binary program running on ProDOS 8 without -BASIC.SYSTEM. Intended to be used with <bf/LOADER.SYSTEM - an -Apple ][ ProDOS 8 loader for cc65 programs/ (see above) together -with the function <tt/rebootafterexit()/. +Configuration for a assembler programs which don't need a special setup. -If a ProDOS 8 system program doesn't quit to the ProDOS 8 dispatcher but rather -reboots the machine after exit then a plain vanilla ProDOS 8 doesn't make use of -the Language Card bank 2 at all. - -This setup makes nearly 50 KB available to a cc65 program - on a 64 KB machine! +Parameters: <descrip> - <tag><tt/RAM:/ Main memory area</tag> - From $800 to $BEFF (45.75 KB) - - <tag><tt/LC:/ Language Card memory area</tag> - From $D000 to $DFFF (4 KB) - <tag><tt/STARTADDRESS:/ Program start address</tag> - Variable (default: $800) + Default: $803. Use <tt/-S <addr>/ to set a different start address. - <tag><tt/HEADER:/ Binary file header</tag> - DOS 3.3 header (address and length) + <tag><tt/__EXEHDR__:/ Executable file header</tag> + Default: No header. Use <tt/-u __EXEHDR__ apple2enh.lib/ to add a DOS 3.3 header + (address and length). </descrip><p> @@ -230,10 +235,10 @@ range. The easiest (and for really large programs in fact the only) way to have a cc65 program use the memory from $800 to $2000 is to link it as binary -(as opposed to system) program using the linker configuration -<ref id="apple-load-cfg" name="apple2enh-loader.cfg"> with start address -$803 and load it with the targetutil LOADER.SYSTEM. The program then works -like a system program (i.e. quits to the ProDOS dispatcher). +(as opposed to system) program using the default linker configuration +<ref id="apple-def-cfg" name="apple2enh.cfg"> with __HIMEM__ set to $BF00 +and load it with the targetutil LOADER.SYSTEM. The program then works like a system +program (i.e. quits to the ProDOS dispatcher). Using LOADER.SYSTEM is as simple as copying it to the ProDOS 8 directory of the program to load under name <program>.SYSTEM as a system program. For @@ -328,8 +333,8 @@ The names in the parentheses denote the symbols to be used for static linking of <tag><tt/a2e.hi.tgi (a2e_hi_tgi)/</tag> This driver features a resolution of 280×192 with 8 colors and two hires pages. Note that programs using this driver will have to be linked - with <tt/--start-addr $4000/ to reserve the first hires page or with - <tt/--start-addr $6000/ to reserve both hires pages. + with <tt/-S $4000/ to reserve the first hires page or with <tt/-S $6000/ + to reserve both hires pages. Note that the second hires page is only available if the text display is not in 80 column mode. This can be asserted by calling <tt/videomode (VIDEOMODE_40COL);/ @@ -354,7 +359,7 @@ The names in the parentheses denote the symbols to be used for static linking of <tag><tt/a2e.auxmem.emd (a2e_auxmem_emd)/</tag> Gives access to 47.5 KB RAM (190 pages of 256 bytes each) on an Extended 80-Column Text Card. - + Note that this driver doesn't check for the actual existence of the memory and that it doesn't check for ProDOS 8 RAM disk content! @@ -429,7 +434,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3: 'Failed to alloc interrupt' on program startup. This implicitly means that <tt/a2e.stdmou.mou/ and <tt/a2e.ssc.ser/ are not functional as they depend on interrupts. - + </descrip><p> @@ -494,7 +499,7 @@ url="ca65.html" name="assembler manual">. <tag/Drive ID/ The function <url url="dio.html#s1" name="dio_open()"> has the single parameter <tt/device/ to identify the device to be opened. Therefore an - Apple II slot and drive pair is mapped to that <tt/drive_id/ according + Apple II slot and drive pair is mapped to that <tt/device/ according to the formula <tscreen> From c9734004eed9741ec90786e3d8fedb2ecbab3b2a Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 25 Mar 2016 19:03:12 +0100 Subject: [PATCH 034/407] Minor fixes for recent doc change. --- doc/apple2.sgml | 12 ++++++++---- doc/apple2enh.sgml | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 7443e50b7..b576ae6c1 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -85,17 +85,17 @@ several usefull settings: <descrip> - <tag>LCADDR: $D400, LCSIZE: $C00</tag> + <tag>LC address: $D400, LC size: $C00</tag> For plain vanilla ProDOS 8 which doesn't actually use the Language Card bank 2 memory from $D400 to $DFFF. This is the default setting. - <tag>LCADDR: $D000, LCSIZE: $1000</tag> + <tag>LC address: $D000, LC size: $1000</tag> For ProDOS 8 together with the function <tt/rebootafterexit()/. If a program doesn't quit to the ProDOS 8 dispatcher but rather reboots the machine after exit then a plain vanilla ProDOS 8 doesn't make use of the Language Card bank 2 at all. - <tag>LCADDR: $D000, LCSIZE: $3000</tag> + <tag>LC address: $D000, LC size: $3000</tag> For plain vanilla DOS 3.3 which doesn't make use of the Language Card at all. </descrip><p> @@ -149,6 +149,8 @@ Parameters: Configuration for a system program running on ProDOS 8 and using the memory from $2000 to $BEFF. +Parameters: + <descrip> <tag><tt/__STACKSIZE__:/ C runtime stack size</tag> @@ -172,6 +174,8 @@ Configuration for overlay programs with the up to nine overlays. The overlay fil don't include the DOS 3.3 header. See <tt>samples/overlaydemo.c</tt> for more information on overlays. +Parameters: + <descrip> <tag><tt/STARTADDRESS:/ Program start address</tag> @@ -236,7 +240,7 @@ range. The easiest (and for really large programs in fact the only) way to have a cc65 program use the memory from $800 to $2000 is to link it as binary (as opposed to system) program using the default linker configuration -<ref id="apple-def-cfg" name="apple2.cfg"> with __HIMEM__ set to $BF00 +<ref id="apple-def-cfg" name="apple2.cfg"> with <tt/__HIMEM__/ set to $BF00 and load it with the targetutil LOADER.SYSTEM. The program then works like a system program (i.e. quits to the ProDOS dispatcher). diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 5a9da7704..6ee525114 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -85,17 +85,17 @@ several usefull settings: <descrip> - <tag>LCADDR: $D400, LCSIZE: $C00</tag> + <tag>LC address: $D400, LC size: $C00</tag> For plain vanilla ProDOS 8 which doesn't actually use the Language Card bank 2 memory from $D400 to $DFFF. This is the default setting. - <tag>LCADDR: $D000, LCSIZE: $1000</tag> + <tag>LC address: $D000, LC size: $1000</tag> For ProDOS 8 together with the function <tt/rebootafterexit()/. If a program doesn't quit to the ProDOS 8 dispatcher but rather reboots the machine after exit then a plain vanilla ProDOS 8 doesn't make use of the Language Card bank 2 at all. - <tag>LCADDR: $D000, LCSIZE: $3000</tag> + <tag>LC address: $D000, LC size: $3000</tag> For plain vanilla DOS 3.3 which doesn't make use of the Language Card at all. </descrip><p> @@ -149,6 +149,8 @@ Parameters: Configuration for a system program running on ProDOS 8 and using the memory from $2000 to $BEFF. +Parameters: + <descrip> <tag><tt/__STACKSIZE__:/ C runtime stack size</tag> @@ -172,6 +174,8 @@ Configuration for overlay programs with the up to nine overlays. The overlay fil don't include the DOS 3.3 header. See <tt>samples/overlaydemo.c</tt> for more information on overlays. +Parameters: + <descrip> <tag><tt/STARTADDRESS:/ Program start address</tag> @@ -236,7 +240,7 @@ range. The easiest (and for really large programs in fact the only) way to have a cc65 program use the memory from $800 to $2000 is to link it as binary (as opposed to system) program using the default linker configuration -<ref id="apple-def-cfg" name="apple2enh.cfg"> with __HIMEM__ set to $BF00 +<ref id="apple-def-cfg" name="apple2enh.cfg"> with <tt/__HIMEM__/set to $BF00 and load it with the targetutil LOADER.SYSTEM. The program then works like a system program (i.e. quits to the ProDOS dispatcher). From 29d1400340f803d0df1ca2b6b2f85a3e3baca9a3 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 25 Mar 2016 21:57:06 +0100 Subject: [PATCH 035/407] Allow _sys() to call ROM routines. _sys() is supposed to be (primarily) intended to call ROM routines. Leveraging the "file overlay" mechanism of the cc65 build system allows to provide a Apple II specific _sys() implementation that temporarily switches in the ROM. --- libsrc/apple2/_sys.s | 81 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 libsrc/apple2/_sys.s diff --git a/libsrc/apple2/_sys.s b/libsrc/apple2/_sys.s new file mode 100644 index 000000000..ae4ea81d2 --- /dev/null +++ b/libsrc/apple2/_sys.s @@ -0,0 +1,81 @@ +; +; void __fastcall__ _sys (struct regs* r); +; + + .export __sys + .import jmpvec + + .include "zeropage.inc" + + .segment "LOWCODE" + +__sys: sta ptr1 + stx ptr1+1 ; Save the pointer to r + + ; Fetch the PC and store it into the jump vector + ldy #5 + lda (ptr1),y + sta jmpvec+2 + dey + lda (ptr1),y + sta jmpvec+1 + + ; Remember the flags so we can restore them to a known state after calling the + ; routine + php + + ; Get the flags, keep the state of bit 4 and 5 using the other flags from + ; the flags value passed by the caller. Push the new flags and push A. + dey + php + pla ; Current flags -> A + eor (ptr1),y + and #%00110000 + eor (ptr1),y + pha ; Push new flags value + ldy #0 + lda (ptr1),y + pha + + ; Get and assign X and Y + iny + lda (ptr1),y + tax + iny + lda (ptr1),y + tay + + ; Switch in ROM + bit $C082 + + ; Set A and the flags, call the machine code routine + pla + plp + jsr jmpvec + + ; Back from the routine. Save the flags and A. + php + pha + + ; Switch in LC bank 2 for R/O + bit $C080 + + ; Put the register values into the regs structure + tya + ldy #2 + sta (ptr1),y + dey + txa + sta (ptr1),y + dey + pla + sta (ptr1),y + ldy #3 + pla + sta (ptr1),y + + ; Restore the old flags value + plp + + ; Done + rts From e2419ece0b596d137b6a9b98f4eb2844c8c29578 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 27 Mar 2016 18:26:46 +0200 Subject: [PATCH 036/407] Added scrcode macro for the Apple II. Although the Apple II generally works with plain ASCII (i.e. in the ProDOS 8 MLI) the actual screen codes differ. This fixes #260. --- asminc/apple2.mac | 48 +++++++++++++++++++++++++++++++++++++++++++++++ doc/ca65.sgml | 6 ++++++ 2 files changed, 54 insertions(+) create mode 100644 asminc/apple2.mac diff --git a/asminc/apple2.mac b/asminc/apple2.mac new file mode 100644 index 000000000..b9860c092 --- /dev/null +++ b/asminc/apple2.mac @@ -0,0 +1,48 @@ +; Convert characters to screen codes + +; Helper macro that converts and outputs one character +.macro _scrcode char + .if (char < 256) + .byte (char + 128) + .else + .error "scrcode: Character constant out of range" + .endif +.endmacro + +.macro scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 + + ; Bail out if next argument is empty + .if .blank (arg1) + .exitmacro + .endif + + ; Check for a string + .if .match ({arg1}, "") + + ; Walk over all string chars + .repeat .strlen (arg1), i + _scrcode {.strat (arg1, i)} + .endrepeat + + ; Check for a number + .elseif .match (.left (1, {arg1}), 0) + + ; Just output the number + _scrcode arg1 + + ; Check for a character + .elseif .match (.left (1, {arg1}), 'a') + + ; Just output the character + _scrcode arg1 + + ; Anything else is an error + .else + + .error "scrcode: invalid argument type" + + .endif + + ; Call the macro recursively with the remaining args + scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 +.endmacro diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 14fe8714f..6ea17d335 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4450,6 +4450,12 @@ The package defines the following macros: +<sect1><tt>.MACPACK apple2</tt><p> + +This macro package defines a macro named <tt/scrcode/. It takes a string +as argument and places this string into memory translated into screen codes. + + <sect1><tt>.MACPACK atari</tt><p> This macro package defines a macro named <tt/scrcode/. It takes a string From e92f3547408978f6f289e9549ad6e32f19e9fd15 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 27 Mar 2016 18:27:53 +0200 Subject: [PATCH 037/407] Made use of recently added Apple scrcode macro. --- libsrc/apple2/irq.s | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libsrc/apple2/irq.s b/libsrc/apple2/irq.s index 97a1633b4..a356e1660 100644 --- a/libsrc/apple2/irq.s +++ b/libsrc/apple2/irq.s @@ -9,6 +9,8 @@ .include "apple2.inc" + .macpack apple2 + .segment "ONCE" initirq: @@ -36,17 +38,9 @@ prterr: ldx #msglen-1 jmp _exit errmsg: .ifdef __APPLE2ENH__ - .byte $8D, 't'|$80, 'p'|$80, 'u'|$80, 'r'|$80, 'r'|$80 - .byte 'e'|$80, 't'|$80, 'n'|$80, 'i'|$80, ' '|$80, 'c'|$80 - .byte 'o'|$80, 'l'|$80, 'l'|$80, 'a'|$80, ' '|$80, 'o'|$80 - .byte 't'|$80, ' '|$80, 'd'|$80, 'e'|$80, 'l'|$80, 'i'|$80 - .byte 'a'|$80, 'F'|$80, $8D + scrcode $0D, "tpurretni colla ot deliaF", $0D .else - .byte $8D, 'T'|$80, 'P'|$80, 'U'|$80, 'R'|$80, 'R'|$80 - .byte 'E'|$80, 'T'|$80, 'N'|$80, 'I'|$80, ' '|$80, 'C'|$80 - .byte 'O'|$80, 'L'|$80, 'L'|$80, 'A'|$80, ' '|$80, 'O'|$80 - .byte 'T'|$80, ' '|$80, 'D'|$80, 'E'|$80, 'L'|$80, 'I'|$80 - .byte 'A'|$80, 'F'|$80, $8D + scrcode $0D, "TPURRETNI COLLA OT DELIAF", $0D .endif msglen = * - errmsg From f10361751275b96afb1348c92e6059ca2cb787fb Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 27 Mar 2016 18:29:45 +0200 Subject: [PATCH 038/407] Use .macpack to include macro package. --- libsrc/atari5200/cartname.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/atari5200/cartname.s b/libsrc/atari5200/cartname.s index c6a701884..11cbaaa67 100644 --- a/libsrc/atari5200/cartname.s +++ b/libsrc/atari5200/cartname.s @@ -2,10 +2,10 @@ ; ; Christian Groessler, 01-Mar-2014 -.include "atari.mac" - .export __CART_NAME__: absolute = 1 +.macpack atari + .segment "CARTNAME" scrcode " cc" From d2f012e4143de46e4f8892b90dc0dd2adeeaa45a Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 27 Mar 2016 18:50:54 +0200 Subject: [PATCH 039/407] Updated Protovision Shop URL. --- doc/c128.sgml | 5 +++-- doc/c64.sgml | 5 +++-- doc/pet.sgml | 5 +++-- doc/vic20.sgml | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/c128.sgml b/doc/c128.sgml index a98b04f49..460621be0 100644 --- a/doc/c128.sgml +++ b/doc/c128.sgml @@ -244,8 +244,9 @@ The default drivers, <tt/joy_stddrv (joy_static_stddrv)/, point to <tt/c128-stdj <tag><tt/c128-ptvjoy.joy (c128_ptvjoy_joy)/</tag> Driver for the Protovision 4-player adapter originally written by Groepaz for the C64, and converted for the C128 by Uz. See <url - url="http://www.protovision-online.de/hardw/hardwstart.htm"> for prices and - building instructions. Up to four joysticks are supported. + url="http://www.protovision-online.de/hardw/4_player.php?language=en" + name="Protovision shop"> for prices and building instructions. Up to four + joysticks are supported. <tag><tt/c128-stdjoy.joy (c128_stdjoy_joy)/</tag> Supports up to two joysticks connected to the standard joysticks ports of diff --git a/doc/c64.sgml b/doc/c64.sgml index 4bf43453d..40bcb37ac 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -319,8 +319,9 @@ The default drivers, <tt/joy_stddrv (joy_static_stddrv)/, point to <tt/c64-stdjo <tag><tt/c64-ptvjoy.joy (c64_ptvjoy_joy)/</tag> Driver for the Protovision 4-player adapter contributed by Groepaz. See - <url url="http://www.protovision-online.de/hardw/hardwstart.htm"> for prices and - building instructions. Up to four joysticks are supported. + <url url="http://www.protovision-online.de/hardw/4_player.php?language=en" + name="Protovision shop"> for prices and building instructions. Up to four + joysticks are supported. <tag><tt/c64-stdjoy.joy (c64_stdjoy_joy)/</tag> Supports up to two standard joysticks connected to the joysticks port of diff --git a/doc/pet.sgml b/doc/pet.sgml index 7c5bd71ea..fd61716dd 100644 --- a/doc/pet.sgml +++ b/doc/pet.sgml @@ -155,8 +155,9 @@ The default drivers, <tt/joy_stddrv (joy_static_stddrv)/, point to <tt/pet-stdjo <tag><tt/pet-ptvjoy.joy (pet_ptvjoy_joy)/</tag> Driver for the Protovision 4-player adapter contributed by Groepaz. See - <url url="http://www.protovision-online.de/hardw/hardwstart.htm"> for prices and - building instructions. Up to two joysticks are supported. + <url url="http://www.protovision-online.de/hardw/4_player.php?language=en" + name="Protovision shop"> for prices and building instructions. Up to two + joysticks are supported. <tag><tt/pet-stdjoy.joy (pet_stdjoy_joy)/</tag> Driver for the standard PET userport joystick. diff --git a/doc/vic20.sgml b/doc/vic20.sgml index 5fba59a13..b1a08ac83 100644 --- a/doc/vic20.sgml +++ b/doc/vic20.sgml @@ -161,8 +161,9 @@ The default drivers, <tt/joy_stddrv (joy_static_stddrv)/, point to <tt/vic20-std <tag><tt/vic20-ptvjoy.joy (vic20_ptvjoy_joy)/</tag> Driver for the Protovision 4-player adapter contributed by Groepaz. See - <url url="http://www.protovision-online.de/hardw/hardwstart.htm"> for prices and - building instructions. Up to three joysticks are supported. + <url url="http://www.protovision-online.de/hardw/4_player.php?language=en" + name="Protovision shop"> for prices and building instructions. Up to three + joysticks are supported. </descrip><p> From 8b685763d4c0845b6f877aa79ec6c6db890f7ffc Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 27 Mar 2016 19:09:00 +0200 Subject: [PATCH 040/407] Renamed chrcvt to chrcvt65 and added it to the build. The /Makefile presumes that all binaries are are named *65 so chrcvt had to be renamed in order to be added to the build. --- doc/{chrcvt.sgml => chrcvt65.sgml} | 14 +++++++------- doc/index.sgml | 4 ++-- src/Makefile | 21 +++++++++++---------- src/{chrcvt => chrcvt65}/error.c | 2 +- src/{chrcvt => chrcvt65}/error.h | 2 +- src/{chrcvt => chrcvt65}/main.c | 9 ++++----- 6 files changed, 26 insertions(+), 26 deletions(-) rename doc/{chrcvt.sgml => chrcvt65.sgml} (86%) rename src/{chrcvt => chrcvt65}/error.c (97%) rename src/{chrcvt => chrcvt65}/error.h (97%) rename src/{chrcvt => chrcvt65}/main.c (98%) diff --git a/doc/chrcvt.sgml b/doc/chrcvt65.sgml similarity index 86% rename from doc/chrcvt.sgml rename to doc/chrcvt65.sgml index 848fb529d..0c5538426 100644 --- a/doc/chrcvt.sgml +++ b/doc/chrcvt65.sgml @@ -1,12 +1,12 @@ <!doctype linuxdoc system> <!-- -*- text-mode -*- --> <article> -<title>chrcvt Users Guide +<title>chrcvt65 Users Guide <author><url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal"> <date>2013-02-10 <abstract> -chrcvt is the vector font converter. It is able to convert a foreign font into +chrcvt65 is the vector font converter. It is able to convert a foreign font into the native format. </abstract> @@ -18,7 +18,7 @@ the native format. <sect>Overview<p> -chrcvt is a vector font converter. It is able to convert a "BGI Stroked +chrcvt65 is a vector font converter. It is able to convert a "BGI Stroked Font" to a compact TGI native vector font. See the function <url url="funcref.html#tgi_load_vectorfont" name="tgi_load_vectorfont"> for usage. @@ -26,7 +26,7 @@ url="funcref.html#tgi_load_vectorfont" name="tgi_load_vectorfont"> for usage. <sect>Usage<p> -The chrcvt utility converts the font of one Borland file to its cc65 equivalent. +The chrcvt65 utility converts the font of one Borland file to its cc65 equivalent. <sect1>Command line option overview<p> @@ -35,7 +35,7 @@ The program may be called as follows: <tscreen><verb> --------------------------------------------------------------------------- -Usage: chrcvt [options] file [options] [file] +Usage: chrcvt65 [options] file [options] [file] Short options: -h Help (this text) -v Be more verbose @@ -80,7 +80,7 @@ in TCH format to a new file. Example output for the command <tscreen><verb> -chrcvt --verbose LITT.CHR +chrcvt65 --verbose LITT.CHR </verb></tscreen> <tscreen><verb> BGI Stroked Font V1.1 - Aug 12, 1991 @@ -91,7 +91,7 @@ Copyright (c) 1987,1988 Borland International <sect>Copyright<p> -chrcvt is (C) Copyright 2009, Ullrich von Bassewitz. For usage of the +chrcvt65 is (C) Copyright 2009, Ullrich von Bassewitz. For usage of the binaries and/or sources the following conditions apply: This software is provided 'as-is', without any expressed or implied diff --git a/doc/index.sgml b/doc/index.sgml index 68f755a29..44b58ef5e 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -18,7 +18,7 @@ <tag><htmlurl url="cc65.html" name="cc65.html"></tag> Describes the cc65 C compiler. - <tag><htmlurl url="chrcvt.html" name="chrcvt.html"></tag> + <tag><htmlurl url="chrcvt65.html" name="chrcvt65.html"></tag> Describes the vector font converter. <tag><htmlurl url="cl65.html" name="cl65.html"></tag> @@ -31,7 +31,7 @@ Describes the da65 6502/65C02 disassembler. <tag><htmlurl url="grc65.html" name="grc65.html"></tag> - Describes the GEOS resource compiler (grc65). + Describes the GEOS resource compiler. <tag><htmlurl url="ld65.html" name="ld65.html"></tag> Describes the ld65 linker. diff --git a/src/Makefile b/src/Makefile index 5aafc4bb8..f10c189b3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,16 +2,17 @@ ifneq ($(shell echo),) CMD_EXE = 1 endif -PROGS = ar65 \ - ca65 \ - cc65 \ - cl65 \ - co65 \ - da65 \ - grc65 \ - ld65 \ - od65 \ - sim65 \ +PROGS = ar65 \ + ca65 \ + cc65 \ + chrcvt65 \ + cl65 \ + co65 \ + da65 \ + grc65 \ + ld65 \ + od65 \ + sim65 \ sp65 .PHONY: all mostlyclean clean install zip avail unavail bin $(PROGS) diff --git a/src/chrcvt/error.c b/src/chrcvt65/error.c similarity index 97% rename from src/chrcvt/error.c rename to src/chrcvt65/error.c index 424080d83..d6bc57fdf 100644 --- a/src/chrcvt/error.c +++ b/src/chrcvt65/error.c @@ -2,7 +2,7 @@ /* */ /* error.c */ /* */ -/* Error handling for the chrcvt vector font converter */ +/* Error handling for the chrcvt65 vector font converter */ /* */ /* */ /* */ diff --git a/src/chrcvt/error.h b/src/chrcvt65/error.h similarity index 97% rename from src/chrcvt/error.h rename to src/chrcvt65/error.h index 93f59ccfd..c5d1474e9 100644 --- a/src/chrcvt/error.h +++ b/src/chrcvt65/error.h @@ -2,7 +2,7 @@ /* */ /* error.h */ /* */ -/* Error handling for the chrcvt vector font converter */ +/* Error handling for the chrcvt65 vector font converter */ /* */ /* */ /* */ diff --git a/src/chrcvt/main.c b/src/chrcvt65/main.c similarity index 98% rename from src/chrcvt/main.c rename to src/chrcvt65/main.c index 7b1c3219e..8685e06b9 100644 --- a/src/chrcvt/main.c +++ b/src/chrcvt65/main.c @@ -2,7 +2,7 @@ /* */ /* main.c */ /* */ -/* Main program of the chrcvt vector font converter */ +/* Main program of the chrcvt65 vector font converter */ /* */ /* */ /* */ @@ -46,7 +46,7 @@ #include "xmalloc.h" #include "version.h" -/* chrcvt */ +/* chrcvt65 */ #include "error.h" @@ -219,8 +219,7 @@ static void OptVersion (const char* Opt attribute ((unused)), /* Print the assembler version */ { fprintf (stderr, - "%s V%s - (C) Copyright 2009, Ullrich von Bassewitz\n", - ProgName, GetVersionAsString ()); + "%s V%s\n", ProgName, GetVersionAsString ()); } @@ -482,7 +481,7 @@ int main (int argc, char* argv []) unsigned I; /* Initialize the cmdline module */ - InitCmdLine (&argc, &argv, "chrcvt"); + InitCmdLine (&argc, &argv, "chrcvt65"); /* Check the parameters */ I = 1; From fac246c799aee0bc0efebc8656cfeb1122177902 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 29 Mar 2016 05:40:12 -0400 Subject: [PATCH 041/407] Moved a warning message, about misaligned segments, to a configuration function. It used to be shown only if the segment was written into a binary file. Now, it's shown for all badly-aligned segments. --- src/ld65/bin.c | 12 ------------ src/ld65/config.c | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/ld65/bin.c b/src/ld65/bin.c index ada4f1e3c..c3efd9cd1 100644 --- a/src/ld65/bin.c +++ b/src/ld65/bin.c @@ -169,18 +169,6 @@ static void BinWriteMem (BinDesc* D, MemoryArea* M) PrintNumVal ("Address", Addr); PrintNumVal ("FileOffs", (unsigned long) ftell (D->F)); - /* Check if the alignment for the segment from the linker config is - ** a multiple for that of the segment. - */ - if ((S->RunAlignment % S->Seg->Alignment) != 0) { - /* Segment requires another alignment than configured - ** in the linker. - */ - Warning ("Segment `%s' is not aligned properly. Resulting " - "executable may not be functional.", - GetString (S->Name)); - } - /* If this is the run memory area, we must apply run alignment. If ** this is not the run memory area but the load memory area (which ** means that both are different), we must apply load alignment. diff --git a/src/ld65/config.c b/src/ld65/config.c index 8e7a049c7..5959067b2 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -1855,6 +1855,20 @@ unsigned CfgProcess (void) /* This is the run (and maybe load) memory area. Handle ** alignment and explict start address and offset. */ + + /* Check if the alignment for the segment from the linker + ** config. is a multiple for that of the segment. + */ + if ((S->RunAlignment % S->Seg->Alignment) != 0) { + /* Segment requires another alignment than configured + ** in the linker. + */ + CfgWarning (GetSourcePos (S->LI), + "Segment `%s' isn't aligned properly; the" + " resulting executable might not be functional.", + GetString (S->Name)); + } + if (S->Flags & SF_ALIGN) { /* Align the address */ unsigned long NewAddr = AlignAddr (Addr, S->RunAlignment); @@ -1865,8 +1879,8 @@ unsigned CfgProcess (void) */ if (M->FillLevel == 0 && NewAddr > Addr) { CfgWarning (GetSourcePos (S->LI), - "First segment in memory area `%s' does " - "already need fill bytes for alignment", + "The first segment in memory area `%s' " + "needs fill bytes for alignment.", GetString (M->Name)); } From 7f06405bdb739e84da46b96c14ae7d59776a6bfa Mon Sep 17 00:00:00 2001 From: KORISNIK <korisnik@Powerbook-3.fritz.box> Date: Sun, 10 Apr 2016 02:21:36 +0200 Subject: [PATCH 042/407] A forgotten option. Empty arguments are not silent anymore. --- doc/sp65.sgml | 7 +++++++ src/sp65/main.c | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/sp65.sgml b/doc/sp65.sgml index 909ac6d25..ccad930c3 100644 --- a/doc/sp65.sgml +++ b/doc/sp65.sgml @@ -49,6 +49,7 @@ Short options: Long options: --convert-to fmt[,attrlist] Convert into target format + --dump-palette Dump palette as table --help Help (this text) --list-conversions List all possible conversions --pop Restore the original loaded image @@ -76,6 +77,12 @@ attribute lists see <ref id="attr-lists" name="below">. see section <ref id="conversions" name="Conversions">. + <label id="option--dump-palette"> + <tag><tt>--dump-palette</tt></tag> + + Dump palette as table. + + <label id="option--help"> <tag><tt>-h, --help</tt></tag> diff --git a/src/sp65/main.c b/src/sp65/main.c index ef2188c82..32cc1b936 100644 --- a/src/sp65/main.c +++ b/src/sp65/main.c @@ -92,6 +92,7 @@ static void Usage (void) "\n" "Long options:\n" " --convert-to fmt[,attrlist]\tConvert into target format\n" + " --dump-palette\t\tDump palette as table\n" " --help\t\t\tHelp (this text)\n" " --list-conversions\t\tList all possible conversions\n" " --pop\t\t\t\tRestore the original loaded image\n" @@ -273,7 +274,7 @@ static void OptSlice (const char* Opt attribute ((unused)), const char* Arg) static void OptVerbose (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) -/* Increase versbosity */ +/* Increase verbosity */ { ++Verbosity; } @@ -397,6 +398,11 @@ int main (int argc, char* argv []) ++I; } + /* Do we have an input file? */ + if (I == 1) { + Error ("No input file"); + } + /* Cleanup data */ SetWorkBitmap (C); FreeBitmap (B); From b14021e9ac4d7677d08903f7150fd8408b35ca30 Mon Sep 17 00:00:00 2001 From: Polluks <korisnik@Powerbook-3.fritz.box> Date: Tue, 12 Apr 2016 23:58:30 +0200 Subject: [PATCH 043/407] Fixed CPU definition of Lynx. Removed nonsense target vc20. --- asminc/lynx.inc | 2 +- asminc/supervision.inc | 5 ++--- src/common/target.c | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/asminc/lynx.inc b/asminc/lynx.inc index 2225bf3c8..81a60bf2e 100644 --- a/asminc/lynx.inc +++ b/asminc/lynx.inc @@ -4,7 +4,7 @@ ; ; Reference: ; Bastian Schick's Lynx Documentation -; http://www.geocities.com/SiliconValley/Byte/4242/lynx/ +; http://www.geocities.ws/SiliconValley/Byte/4242/lynx/ ; ; *** diff --git a/asminc/supervision.inc b/asminc/supervision.inc index a75fb02f6..a1cc212f6 100644 --- a/asminc/supervision.inc +++ b/asminc/supervision.inc @@ -1,8 +1,7 @@ ; supervision symbols -; supervision 65c02s -; in cc65 up to 2.9.1 65c02 means 65c02s -.pc02 +; supervision 65c02s +; in cc65 up to 2.9.1 65c02 means 65sc02 lcd_addr = $4000 LCD_LINESIZE = $30 diff --git a/src/common/target.c b/src/common/target.c index 7e152fe94..f76d03ffb 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -139,7 +139,7 @@ struct TargetEntry { }; /* Table that maps target names to ids. Sorted alphabetically for bsearch. -** Allows mupltiple entries for one target id (target name aliases). +** Allows multiple entries for one target id (target name aliases). */ static const TargetEntry TargetMap[] = { { "apple2", TGT_APPLE2 }, @@ -168,7 +168,6 @@ static const TargetEntry TargetMap[] = { { "sim6502", TGT_SIM6502 }, { "sim65c02", TGT_SIM65C02 }, { "supervision", TGT_SUPERVISION }, - { "vc20", TGT_VIC20 }, { "vic20", TGT_VIC20 }, }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) @@ -199,7 +198,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, { "nes", CPU_6502, BINFMT_BINARY, CTNone }, { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, - { "lynx", CPU_65C02, BINFMT_BINARY, CTNone }, + { "lynx", CPU_65SC02, BINFMT_BINARY, CTNone }, { "sim6502", CPU_6502, BINFMT_BINARY, CTNone }, { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, }; From 2c7ccca2103c159b27b696dbf263b86eacf4f69c Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Fri, 22 Apr 2016 11:33:52 -0400 Subject: [PATCH 044/407] Added the optional C keyword "volatile" to the __asm__ statement grammar. It prevents the statement's Assembly code from being optimized (e.g., moved or removed). Optimization is disabled for that statement's entire function (other functions aren't affected). --- doc/cc65.sgml | 107 ++++++++++++++++++++++++--------------------- src/cc65/asmstmt.c | 11 +++++ 2 files changed, 68 insertions(+), 50 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 9198d6982..8346bac6b 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -2,8 +2,9 @@ <article> <title>cc65 Users Guide -<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>2015-05-26 +<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> +<url url="mailto:gregdk@users.sf.net" name="Greg King"> +<date>2016-04-22 <abstract> cc65 is a C compiler for 6502 targets. It supports several 6502 based home @@ -15,7 +16,6 @@ computers like the Commodore and Atari machines, but it is easily retargetable. <!-- Begin the document --> - <sect>Overview<p> cc65 was originally a C compiler for the Atari 8-bit machines written by @@ -564,7 +564,7 @@ and the one defined by the ISO standard: that you must not mix pointers to those functions with pointers to user-written, cdecl functions (the calling conventions are incompatible). <p> -<item> The <tt/volatile/ keyword doesn't have an effect. This is not as bad +<item> The <tt/volatile/ keyword has almost no effect. That is not as bad as it sounds, since the 6502 has so few registers that it isn't possible to keep values in registers anyway. <p> @@ -586,14 +586,14 @@ This cc65 version has some extensions to the ISO C standard. file. The syntax is <tscreen><verb> - asm (<string literal>[, optional parameters]) ; + asm [optional volatile] (<string literal>[, optional parameters]) ; </verb></tscreen> or <tscreen><verb> - __asm__ (<string literal>[, optional parameters]) ; + __asm__ [optional volatile] (<string literal>[, optional parameters]) ; </verb></tscreen> - The first form is in the user namespace and is disabled if the <tt/-A/ + The first form is in the user namespace; and, is disabled if the <tt/-A/ switch is given. There is a whole section covering inline assembler statements, @@ -735,6 +735,7 @@ This cc65 version has some extensions to the ISO C standard. <p> + <sect>Predefined macros<p> The compiler defines several macros at startup: @@ -1224,39 +1225,44 @@ The compiler allows to insert assembler statements into the output file. The syntax is <tscreen><verb> - asm (<string literal>[, optional parameters]) ; + asm [optional volatile] (<string literal>[, optional parameters]) ; </verb></tscreen> or <tscreen><verb> - __asm__ (<string literal>[, optional parameters]) ; + __asm__ [optional volatile] (<string literal>[, optional parameters]) ; </verb></tscreen> <p> -The first form is in the user namespace and is disabled by <tt><ref +The first form is in the user namespace; and, is disabled by <tt><ref id="option--standard" name="--standard"></tt> if the argument is not <tt/cc65/. -The asm statement may be used inside a function and on global file level. An -inline assembler statement is a primary expression, so it may also be used as -part of an expression. Please note however that the result of an expression -containing just an inline assembler statement is always of type <tt/void/. +The <tt/asm/ statement can be used only inside a function. Please note that +the result of an inline assembler expression is always of type <tt/void/. -The contents of the string literal are preparsed by the compiler and inserted -into the generated assembly output, so that the can be further processed by -the backend and especially the optimizer. For this reason, the compiler does -only allow regular 6502 opcodes to be used with the inline assembler. Pseudo -instructions (like <tt/.import/, <tt/.byte/ and so on) are <em/not/ allowed, +The contents of the string literal are preparsed by the compiler; and, inserted +into the generated assembly output, so that it can be processed further by +the backend -- and, especially the optimizer. For that reason, the compiler does +allow only regular 6502 opcodes to be used with the inline assembler. Pseudo +instructions (like <tt/.import/, <tt/.byte/, and so on) are <em/not/ allowed, even if the ca65 assembler (which is used to translate the generated assembler -code) would accept them. The builtin inline assembler is not a replacement for -the full blown macro assembler which comes with the compiler. +code) would accept them. The built-in inline assembler is not a replacement for +the full-blown macro assembler which comes with the compiler. Note: Inline assembler statements are subject to all optimizations done by the -compiler. There is currently no way to protect an inline assembler statement -from being moved or removed completely by the optimizer. If in doubt, check -the generated assembler output, or disable optimizations. +compiler. There currently is no way to protect an inline assembler statement +-- alone -- from being moved or removed completely by the optimizer. If in +doubt, check the generated assembler output; or, disable optimizations (for +that function). + +As a shortcut, you can put the <tt/volatile/ qualifier in your <tt/asm/ +statements. It will disable optimization for the functions in which those +<tt/asm volatile/ statements sit. The effect is the same as though you put +</#pragma optimize(push, off)/ above those functions, and </#pragma +optimize(pop)/ below those functions. The string literal may contain format specifiers from the following list. For each format specifier, an argument is expected which is inserted instead of -the format specifier before passing the assembly code line to the backend. +the format specifier, before passing the assembly code line to the backend. <itemize> <item><tt/%b/ - Numerical 8-bit value @@ -1269,33 +1275,33 @@ the format specifier before passing the assembly code line to the backend. <item><tt/%%/ - The % sign itself </itemize><p> -Using these format specifiers, you can access C <tt/#defines/, variables or +Using those format specifiers, you can access C <tt/#defines/, variables, or similar stuff from the inline assembler. For example, to load the value of -a C <tt/#define/ into the Y register, one would use +a C <tt/#define/ into the Y index register, one would use <tscreen><verb> - #define OFFS 23 - __asm__ ("ldy #%b", OFFS); + #define OFFS 23 + __asm__ ("ldy #%b", OFFS); </verb></tscreen> Or, to access a struct member of a static variable: <tscreen><verb> - typedef struct { - unsigned char x; - unsigned char y; - unsigned char color; - } pixel_t; - static pixel_t pixel; - __asm__ ("ldy #%b", offsetof(pixel_t, color)); - __asm__ ("lda %v,y", pixel); + typedef struct { + unsigned char x; + unsigned char y; + unsigned char color; + } pixel_t; + static pixel_t pixel; + __asm__ ("ldy #%b", offsetof(pixel_t, color)); + __asm__ ("lda %v,y", pixel); </verb></tscreen> <p> The next example shows how to use global variables to exchange data between C -an assembler and how to handle assembler jumps: +and assembler; and, how to handle assembler jumps: <tscreen><verb> - unsigned char globalSubA, globalSubB, globalSubResult; + static unsigned char globalSubA, globalSubB, globalSubResult; /* return a-b, return 255 if b>a */ unsigned char sub (unsigned char a, unsigned char b) @@ -1314,19 +1320,19 @@ an assembler and how to handle assembler jumps: </verb></tscreen> <p> -Arrays can also be accessed: +Arrays also can be accessed: <tscreen><verb> - unsigned char globalSquareTable[] = { + static const unsigned char globalSquareTable[] = { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225 }; - unsigned char globalSquareA, globalSquareResult; + static unsigned char globalSquareA, globalSquareResult; /* return a*a for a<16, else 255 */ unsigned char square (unsigned char a) { - if (a>15){ + if (a > 15) { return 255; } globalSquareA = a; @@ -1339,28 +1345,30 @@ Arrays can also be accessed: <p> Note: Do not embed the assembler labels that are used as names of global -variables or functions into your asm statements. Code like this +variables or functions into your <tt/asm/ statements. Code such as this: <tscreen><verb> int foo; - int bar () { return 1; } - __asm__ ("lda _foo"); /* DON'T DO THAT! */ + int bar (void) { return 1; } + ... + __asm__ ("lda _foo"); /* DON'T DO THAT! */ ... __asm__ ("jsr _bar"); /* DON'T DO THAT EITHER! */ </verb></tscreen> <p> -may stop working if the way, the compiler generates these names is changed in -a future version. Instead use the format specifiers from the table above: +might stop working if the way that the compiler generates those names is changed in +a future version. Instead, use the format specifiers from the table above: <tscreen><verb> - __asm__ ("lda %v", foo); /* OK */ + __asm__ ("lda %v", foo); /* OK */ ... __asm__ ("jsr %v", bar); /* OK */ </verb></tscreen> <p> + <sect>Implementation-defined behavior<p> This section describes the behavior of cc65 when the standard describes the @@ -1434,4 +1442,3 @@ freely, subject to the following restrictions: </enum> </article> - diff --git a/src/cc65/asmstmt.c b/src/cc65/asmstmt.c index 59c1332ff..4dd6628c4 100644 --- a/src/cc65/asmstmt.c +++ b/src/cc65/asmstmt.c @@ -41,12 +41,14 @@ /* cc65 */ #include "asmlabel.h" #include "codegen.h" +#include "codeseg.h" #include "datatype.h" #include "error.h" #include "expr.h" #include "function.h" #include "litpool.h" #include "scanner.h" +#include "segments.h" #include "stackptr.h" #include "symtab.h" #include "asmstmt.h" @@ -422,6 +424,15 @@ void AsmStatement (void) /* Skip the ASM */ NextToken (); + /* An optional volatile qualifier disables optimization for + ** the entire function [same as #pragma optimize(push, off)]. + */ + if (CurTok.Tok == TOK_VOLATILE) { + /* Don't optimize the Current code Segment */ + CS->Code->Optimize = 0; + NextToken (); + } + /* Need left parenthesis */ if (!ConsumeLParen ()) { return; From 8bd2628d1e1eeabe170304b564bf9ade9c2baf0b Mon Sep 17 00:00:00 2001 From: OzHawk <OzHawk@users.noreply.github.com> Date: Wed, 11 May 2016 19:24:16 +0930 Subject: [PATCH 045/407] Update the missing entries in the kernel jump table for the Vic20 with the actual function addresses. The Vic20 does not have kernal table entries for the following functions. ;----------------------------------------------------------------------------- ; Functions which are not in the kernal jump table for VIC-20 but are for C64 CINT := $E518 IOINIT := $FDF9 RAMTAS := $FD8D All other kernal entries are the same as the C64, however, without this change, the startup code fails. Without this change the vic20.lib builds incorrectly. --- libsrc/vic20/kernal.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsrc/vic20/kernal.s b/libsrc/vic20/kernal.s index 35bedb466..d9e7a9d03 100644 --- a/libsrc/vic20/kernal.s +++ b/libsrc/vic20/kernal.s @@ -47,9 +47,9 @@ ;----------------------------------------------------------------------------- ; All functions are available in the kernal jump table -CINT = $FF81 -IOINIT = $FF84 -RAMTAS = $FF87 +CINT = $E518 ; No entries are in the kernal jump table for these functions. +IOINIT = $FDF9 ; The entries point directly to the function. +RAMTAS = $FD8D ; RESTOR = $FF8A VECTOR = $FF8D SETMSG = $FF90 From 93f55c274b3fc88f26590b0fb104eca2f3da0c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Fri, 13 May 2016 14:28:58 +0200 Subject: [PATCH 046/407] moved output of target utils and drivers to separate directory --- doc/Makefile | 2 ++ libsrc/Makefile | 24 ++++++++++++++--------- libsrc/apple2/targetutil/Makefile.inc | 4 ++-- libsrc/atari/targetutil/Makefile.inc | 4 ++-- libsrc/geos-apple/targetutil/Makefile.inc | 4 ++-- libsrc/nes/Makefile.inc | 16 +++++++-------- 6 files changed, 31 insertions(+), 23 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 967443ef0..8b0b316b0 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -41,7 +41,9 @@ ifeq ($(wildcard ../info),../info) endif zip: +ifneq "$(wildcard ../html)" "" @cd .. && zip cc65 html/*.* +endif doc: html info diff --git a/libsrc/Makefile b/libsrc/Makefile index a4101aecd..ae65dc9b6 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -37,12 +37,15 @@ DRVTYPES = emd \ ser \ tgi -OUTPUTDIRS := lib \ - $(DRVTYPES) \ - targetutil \ - asminc \ - cfg \ - include \ +DRVOUTPUTDIRS := $(foreach drvtype,$(DRVTYPES),goodies/drivers/$(drvtype)) + +OUTPUTDIRS := lib \ + $(DRVOUTPUTDIRS) \ + goodies/targetutil \ + asminc \ + cfg \ + include \ + samples \ $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) .PHONY: all mostlyclean clean install zip lib $(TARGETS) @@ -76,8 +79,11 @@ all lib: $(TARGETS) mostlyclean: $(call RMDIR,../libwrk) +# Transitional line active. Final line commented out below in order to +# allow some time for transition between the directory structures clean: - $(call RMDIR,../libwrk ../lib ../targetutil $(addprefix ../,$(DRVTYPES))) + $(call RMDIR,../libwrk ../lib ../targetutil ../goodies $(addprefix ../,$(DRVTYPES))) +# $(call RMDIR,../libwrk ../lib ../goodies) ifdef CMD_EXE @@ -212,7 +218,7 @@ define DRVTYPE_template $1_SRCDIR = $$(SRCDIR)/$1 $1_STCDIR = ../libwrk/$$(TARGET) $1_DYNDIR = ../libwrk/$$(TARGET)/$1 -$1_DRVDIR = ../$1 +$1_DRVDIR = ../goodies/drivers/$1 $1_SRCPAT = $$($1_SRCDIR)/$$(OBJPFX)%.s $1_STCPAT = $$($1_STCDIR)/$$(OBJPFX)%-$1.o @@ -283,7 +289,7 @@ $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib ../lib/$(TARGET).lib: $(OBJS) | ../lib $(AR65) a $@ $? -../libwrk/$(TARGET) ../lib ../targetutil: +../libwrk/$(TARGET) ../lib ../goodies/targetutil: @$(call MKDIR,$@) $(TARGET): $(EXTRA_OBJS) ../lib/$(TARGET).lib diff --git a/libsrc/apple2/targetutil/Makefile.inc b/libsrc/apple2/targetutil/Makefile.inc index 105a5324f..0b8b39e1f 100644 --- a/libsrc/apple2/targetutil/Makefile.inc +++ b/libsrc/apple2/targetutil/Makefile.inc @@ -3,7 +3,7 @@ DEPS += ../libwrk/$(TARGET)/loader.d ../libwrk/$(TARGET)/loader.o: $(SRCDIR)/targetutil/loader.s | ../libwrk/$(TARGET) $(ASSEMBLE_recipe) -../targetutil/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../targetutil +../goodies/targetutil/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../goodies/targetutil $(LD65) -o $@ -C $(filter %.cfg,$^) $(filter-out %.cfg,$^) -$(TARGET): ../targetutil/loader.system +$(TARGET): ../goodies/targetutil/loader.system diff --git a/libsrc/atari/targetutil/Makefile.inc b/libsrc/atari/targetutil/Makefile.inc index 05405f2e6..42903a3ca 100644 --- a/libsrc/atari/targetutil/Makefile.inc +++ b/libsrc/atari/targetutil/Makefile.inc @@ -3,7 +3,7 @@ DEPS += ../libwrk/$(TARGET)/w2cas.d ../libwrk/$(TARGET)/w2cas.o: $(SRCDIR)/targetutil/w2cas.c | ../libwrk/$(TARGET) $(COMPILE_recipe) -../targetutil/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../targetutil +../goodies/targetutil/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../goodies/targetutil $(LD65) -o $@ -t $(TARGET) $^ -$(TARGET): ../targetutil/w2cas.com +$(TARGET): ../goodies/targetutil/w2cas.com diff --git a/libsrc/geos-apple/targetutil/Makefile.inc b/libsrc/geos-apple/targetutil/Makefile.inc index fbe31981c..d842b4d3f 100644 --- a/libsrc/geos-apple/targetutil/Makefile.inc +++ b/libsrc/geos-apple/targetutil/Makefile.inc @@ -8,7 +8,7 @@ DEPS += ../libwrk/$(TARGET)/convert.d ../lib/apple2enh.lib: @$(MAKE) --no-print-directory apple2enh -../targetutil/convert.system: ../libwrk/$(TARGET)/convert.o ../lib/apple2enh.lib | ../targetutil +../goodies/targetutil/convert.system: ../libwrk/$(TARGET)/convert.o ../lib/apple2enh.lib | ../goodies/targetutil $(LD65) -o $@ -C apple2enh-system.cfg $^ -$(TARGET): ../targetutil/convert.system +$(TARGET): ../goodies/targetutil/convert.system diff --git a/libsrc/nes/Makefile.inc b/libsrc/nes/Makefile.inc index f1dcbf18e..aaebef1db 100644 --- a/libsrc/nes/Makefile.inc +++ b/libsrc/nes/Makefile.inc @@ -1,8 +1,8 @@ -../tgi/nes-64-56-2.tgi: ../libwrk/nes/clrscr.o \ - ../libwrk/nes/cputc.o \ - ../libwrk/nes/get_tv.o \ - ../libwrk/nes/gotoxy.o \ - ../libwrk/nes/popa.o \ - ../libwrk/nes/ppu.o \ - ../libwrk/nes/ppubuf.o \ - ../libwrk/nes/setcursor.o +../goodies/drivers/tgi/nes-64-56-2.tgi: ../libwrk/nes/clrscr.o \ + ../libwrk/nes/cputc.o \ + ../libwrk/nes/get_tv.o \ + ../libwrk/nes/gotoxy.o \ + ../libwrk/nes/popa.o \ + ../libwrk/nes/ppu.o \ + ../libwrk/nes/ppubuf.o \ + ../libwrk/nes/setcursor.o From 1369bed8810e75f7cf87212ae75ec672fbe084ef Mon Sep 17 00:00:00 2001 From: OzHawk <OzHawk@users.noreply.github.com> Date: Mon, 16 May 2016 08:41:13 +0930 Subject: [PATCH 047/407] Update kernal.s --- libsrc/vic20/kernal.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsrc/vic20/kernal.s b/libsrc/vic20/kernal.s index d9e7a9d03..040dbf5e5 100644 --- a/libsrc/vic20/kernal.s +++ b/libsrc/vic20/kernal.s @@ -47,9 +47,9 @@ ;----------------------------------------------------------------------------- ; All functions are available in the kernal jump table -CINT = $E518 ; No entries are in the kernal jump table for these functions. -IOINIT = $FDF9 ; The entries point directly to the function. -RAMTAS = $FD8D ; +CINT = $E518 ; No entries are in the kernal jump table of the Vic20 for these three (3) functions. +IOINIT = $FDF9 ; The entries for these functions have been set to point directly to the functions +RAMTAS = $FD8D ; in the kernal to maintain compatibility with the other Commodore platforms. RESTOR = $FF8A VECTOR = $FF8D SETMSG = $FF90 From ba10c74a7a2783fea88b24c41c5b8a84afe32570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Mon, 16 May 2016 19:49:43 +0200 Subject: [PATCH 048/407] directory structure changed from driver-centric to target-centric --- libsrc/Makefile | 14 ++++++-------- libsrc/apple2/targetutil/Makefile.inc | 4 ++-- libsrc/atari/targetutil/Makefile.inc | 4 ++-- libsrc/geos-apple/targetutil/Makefile.inc | 4 ++-- libsrc/nes/Makefile.inc | 16 ++++++++-------- samples/Makefile | 20 ++++++++++++-------- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index ae65dc9b6..c4c1b78a7 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -1,3 +1,4 @@ + ifneq ($(shell echo),) CMD_EXE = 1 endif @@ -37,11 +38,8 @@ DRVTYPES = emd \ ser \ tgi -DRVOUTPUTDIRS := $(foreach drvtype,$(DRVTYPES),goodies/drivers/$(drvtype)) - OUTPUTDIRS := lib \ - $(DRVOUTPUTDIRS) \ - goodies/targetutil \ + target \ asminc \ cfg \ include \ @@ -82,8 +80,8 @@ mostlyclean: # Transitional line active. Final line commented out below in order to # allow some time for transition between the directory structures clean: - $(call RMDIR,../libwrk ../lib ../targetutil ../goodies $(addprefix ../,$(DRVTYPES))) -# $(call RMDIR,../libwrk ../lib ../goodies) + $(call RMDIR,../libwrk ../lib ../targetutil ../target $(addprefix ../,$(DRVTYPES))) +# $(call RMDIR,../libwrk ../lib ../target) ifdef CMD_EXE @@ -218,7 +216,7 @@ define DRVTYPE_template $1_SRCDIR = $$(SRCDIR)/$1 $1_STCDIR = ../libwrk/$$(TARGET) $1_DYNDIR = ../libwrk/$$(TARGET)/$1 -$1_DRVDIR = ../goodies/drivers/$1 +$1_DRVDIR = ../target/$$(TARGET)/drv/$1 $1_SRCPAT = $$($1_SRCDIR)/$$(OBJPFX)%.s $1_STCPAT = $$($1_STCDIR)/$$(OBJPFX)%-$1.o @@ -289,7 +287,7 @@ $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib ../lib/$(TARGET).lib: $(OBJS) | ../lib $(AR65) a $@ $? -../libwrk/$(TARGET) ../lib ../goodies/targetutil: +../libwrk/$(TARGET) ../lib ../target/$(TARGET)/util: @$(call MKDIR,$@) $(TARGET): $(EXTRA_OBJS) ../lib/$(TARGET).lib diff --git a/libsrc/apple2/targetutil/Makefile.inc b/libsrc/apple2/targetutil/Makefile.inc index 0b8b39e1f..d9d727b0a 100644 --- a/libsrc/apple2/targetutil/Makefile.inc +++ b/libsrc/apple2/targetutil/Makefile.inc @@ -3,7 +3,7 @@ DEPS += ../libwrk/$(TARGET)/loader.d ../libwrk/$(TARGET)/loader.o: $(SRCDIR)/targetutil/loader.s | ../libwrk/$(TARGET) $(ASSEMBLE_recipe) -../goodies/targetutil/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../goodies/targetutil +../target/$(TARGET)/util/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../target/$(TARGET)/util $(LD65) -o $@ -C $(filter %.cfg,$^) $(filter-out %.cfg,$^) -$(TARGET): ../goodies/targetutil/loader.system +$(TARGET): ../target/$(TARGET)/util/loader.system diff --git a/libsrc/atari/targetutil/Makefile.inc b/libsrc/atari/targetutil/Makefile.inc index 42903a3ca..e78585238 100644 --- a/libsrc/atari/targetutil/Makefile.inc +++ b/libsrc/atari/targetutil/Makefile.inc @@ -3,7 +3,7 @@ DEPS += ../libwrk/$(TARGET)/w2cas.d ../libwrk/$(TARGET)/w2cas.o: $(SRCDIR)/targetutil/w2cas.c | ../libwrk/$(TARGET) $(COMPILE_recipe) -../goodies/targetutil/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../goodies/targetutil +../target/$(TARGET)/util/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../target/$(TARGET)/util $(LD65) -o $@ -t $(TARGET) $^ -$(TARGET): ../goodies/targetutil/w2cas.com +$(TARGET): ../target/$(TARGET)/util/w2cas.com diff --git a/libsrc/geos-apple/targetutil/Makefile.inc b/libsrc/geos-apple/targetutil/Makefile.inc index d842b4d3f..3d366f913 100644 --- a/libsrc/geos-apple/targetutil/Makefile.inc +++ b/libsrc/geos-apple/targetutil/Makefile.inc @@ -8,7 +8,7 @@ DEPS += ../libwrk/$(TARGET)/convert.d ../lib/apple2enh.lib: @$(MAKE) --no-print-directory apple2enh -../goodies/targetutil/convert.system: ../libwrk/$(TARGET)/convert.o ../lib/apple2enh.lib | ../goodies/targetutil +../target/$(TARGET)/util/convert.system: ../libwrk/$(TARGET)/convert.o ../lib/apple2enh.lib | ../target/$(TARGET)/util $(LD65) -o $@ -C apple2enh-system.cfg $^ -$(TARGET): ../goodies/targetutil/convert.system +$(TARGET): ../target/$(TARGET)/util/convert.system diff --git a/libsrc/nes/Makefile.inc b/libsrc/nes/Makefile.inc index aaebef1db..6f2e7c7d2 100644 --- a/libsrc/nes/Makefile.inc +++ b/libsrc/nes/Makefile.inc @@ -1,8 +1,8 @@ -../goodies/drivers/tgi/nes-64-56-2.tgi: ../libwrk/nes/clrscr.o \ - ../libwrk/nes/cputc.o \ - ../libwrk/nes/get_tv.o \ - ../libwrk/nes/gotoxy.o \ - ../libwrk/nes/popa.o \ - ../libwrk/nes/ppu.o \ - ../libwrk/nes/ppubuf.o \ - ../libwrk/nes/setcursor.o +../target/nes/drv/tgi/nes-64-56-2.tgi: ../libwrk/nes/clrscr.o \ + ../libwrk/nes/cputc.o \ + ../libwrk/nes/get_tv.o \ + ../libwrk/nes/gotoxy.o \ + ../libwrk/nes/popa.o \ + ../libwrk/nes/ppu.o \ + ../libwrk/nes/ppubuf.o \ + ../libwrk/nes/setcursor.o diff --git a/samples/Makefile b/samples/Makefile index 951706ce6..0cef19798 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -12,15 +12,19 @@ SYS = c64 # source tree; otherwise, use the "install" directories. ifeq "$(wildcard ../src)" "" # No source tree -MOUS = /usr/lib/cc65/mou/$(SYS)*.mou -TGI = /usr/lib/cc65/tgi/$(SYS)*.tgi +MOUS = /usr/lib/cc65/target/$(SYS)/drv/mou/$(SYS)*.mou +TGI = /usr/lib/cc65/target/$(SYS)/drv/tgi/$(SYS)*.tgi ifneq "$(wildcard /usr/local/lib/cc65)" "" -MOUS = /usr/local/lib/cc65/mou/$(SYS)*.mou -TGI = /usr/local/lib/cc65/tgi/$(SYS)*.tgi +MOUS = /usr/local/lib/cc65/target/$(SYS)/drv/mou/$(SYS)*.mou +TGI = /usr/local/lib/cc65/target/$(SYS)/drv/tgi/$(SYS)*.tgi +endif +ifneq "$(wildcard /opt/local/share/cc65)" "" +MOUS = /opt/local/share/cc65/target/$(SYS)/drv/mou/$(SYS)*.mou +TGI = /opt/local/share/cc65/target/$(SYS)/drv/tgi/$(SYS)*.tgi endif ifdef CC65_HOME -MOUS = $(CC65_HOME)/mou/$(SYS)*.mou -TGI = $(CC65_HOME)/tgi/$(SYS)*.tgi +MOUS = $(CC65_HOME)/target/$(SYS)/drv/mou/$(SYS)*.mou +TGI = $(CC65_HOME)/target/$(SYS)/drv/tgi/$(SYS)*.tgi endif CLIB = --lib $(SYS).lib CL = cl65 @@ -31,8 +35,8 @@ LD = ld65 else # "samples/" is a part of a complete source tree. export CC65_HOME := $(abspath ..) -MOUS = ../mou/$(SYS)*.mou -TGI = ../tgi/$(SYS)*.tgi +MOUS = ../target/$(SYS)/drv/mou/$(SYS)*.mou +TGI = ../target/$(SYS)/drv/tgi/$(SYS)*.tgi CLIB = ../lib/$(SYS).lib CL = ../bin/cl65 CC = ../bin/cc65 From a5bff259bc241fc33763ce51f125d887b2221440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Mon, 16 May 2016 19:50:02 +0200 Subject: [PATCH 049/407] Ignores adjusted --- .gitignore | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 196cdc3d7..e1f69d072 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,8 @@ /bin/ -/emd/ /html/ /info/ -/joy/ /lib/ /libwrk/ -/mou/ -/ser/ -/targetutil/ +/target/ /testwrk/ -/tgi/ /wrk/ From 37f992909416defbb34454137ff89705fb4f40ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Mon, 16 May 2016 22:14:05 +0200 Subject: [PATCH 050/407] adapted for zip/install targets --- libsrc/Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index c4c1b78a7..54e0a7540 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -39,12 +39,13 @@ DRVTYPES = emd \ tgi OUTPUTDIRS := lib \ - target \ asminc \ cfg \ include \ samples \ - $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) + $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))\ + $(subst ../,,$(wildcard ../target/*/drv/*))\ + $(subst ../,,$(wildcard ../target/*/util))\ .PHONY: all mostlyclean clean install zip lib $(TARGETS) @@ -80,8 +81,8 @@ mostlyclean: # Transitional line active. Final line commented out below in order to # allow some time for transition between the directory structures clean: - $(call RMDIR,../libwrk ../lib ../targetutil ../target $(addprefix ../,$(DRVTYPES))) -# $(call RMDIR,../libwrk ../lib ../target) + $(call RMDIR,../libwrk ../lib ../targetutil ../$(TARGETDIR) $(addprefix ../,$(DRVTYPES))) +# $(call RMDIR,../libwrk ../lib ../$(TARGETDIR)) ifdef CMD_EXE @@ -95,13 +96,14 @@ define INSTALL_recipe $(if $(prefix),,$(error variable `prefix' must be set)) $(INSTALL) -d $(DESTDIR)$(datadir)/$(dir) -$(INSTALL) -m644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir) +$(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir) endef # INSTALL_recipe install: $(foreach dir,$(OUTPUTDIRS),$(INSTALL_recipe)) + endif # CMD_EXE define ZIP_recipe From 9c3f89fa1fb43336eb588aec7b8c367a788d9a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Mon, 16 May 2016 22:34:43 +0200 Subject: [PATCH 051/407] ignoring zip target output --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e1f69d072..dac38c48b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /target/ /testwrk/ /wrk/ +cc65.zip From cc747946b282b59d9e29ea1f5772172ac6ed7c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Mon, 16 May 2016 22:35:24 +0200 Subject: [PATCH 052/407] removed variable usage --- libsrc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index 54e0a7540..3f6d2746c 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -81,8 +81,8 @@ mostlyclean: # Transitional line active. Final line commented out below in order to # allow some time for transition between the directory structures clean: - $(call RMDIR,../libwrk ../lib ../targetutil ../$(TARGETDIR) $(addprefix ../,$(DRVTYPES))) -# $(call RMDIR,../libwrk ../lib ../$(TARGETDIR)) + $(call RMDIR,../libwrk ../lib ../targetutil ../target $(addprefix ../,$(DRVTYPES))) +# $(call RMDIR,../libwrk ../lib ../target) ifdef CMD_EXE From 759f5f5f486170db50148ffae5b95caffa240c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Wed, 18 May 2016 16:42:51 +0200 Subject: [PATCH 053/407] docs for targets with target utilities adjusted --- doc/apple2.sgml | 2 +- doc/apple2enh.sgml | 4 ++-- doc/atari.sgml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index b576ae6c1..00cd565b4 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -241,7 +241,7 @@ The easiest (and for really large programs in fact the only) way to have a cc65 program use the memory from $800 to $2000 is to link it as binary (as opposed to system) program using the default linker configuration <ref id="apple-def-cfg" name="apple2.cfg"> with <tt/__HIMEM__/ set to $BF00 -and load it with the targetutil LOADER.SYSTEM. The program then works like a system +and load it with the LOADER.SYSTEM utility. The program then works like a system program (i.e. quits to the ProDOS dispatcher). Using LOADER.SYSTEM is as simple as copying it to the ProDOS 8 directory of the diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 6ee525114..7c17c24f2 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -241,7 +241,7 @@ The easiest (and for really large programs in fact the only) way to have a cc65 program use the memory from $800 to $2000 is to link it as binary (as opposed to system) program using the default linker configuration <ref id="apple-def-cfg" name="apple2enh.cfg"> with <tt/__HIMEM__/set to $BF00 -and load it with the targetutil LOADER.SYSTEM. The program then works like a system +and load it with the LOADER.SYSTEM utility. The program then works like a system program (i.e. quits to the ProDOS dispatcher). Using LOADER.SYSTEM is as simple as copying it to the ProDOS 8 directory of the @@ -277,7 +277,7 @@ default I/O buffer allocation basically yields the same placement of I/O buffers in memory the primary benefit of <tt/apple2enh-iobuf-0800.o/ is a reduction in code size - and thus program file size - of more than 1400 bytes. -Using <tt/apple2enh-iobuf-0800.o/ is as simple as placing it on the linker command +Using <tt/apple2enh-iobuf-0800.o/ is as simple as placing it on the linker command line like this: <tscreen><verb> diff --git a/doc/atari.sgml b/doc/atari.sgml index 2087a8541..cfa1937e0 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -229,8 +229,8 @@ for C and assembly language programs. The size of a cassette boot file is restricted to 32K. Larger programs would need to be split in more parts and the parts to be loaded manually. -To write the generated file to a cassette, a utility to run -on an Atari is provided in the <tt/targetutil/ directory (<tt/w2cas.com/). +To write the generated file to a cassette, a utility (<tt/w2cas.com/) to run +on an Atari is provided in the <tt/util/ directory of <tt/atari/ target dir. <sect1><tt/atarixl/ config files<p> From 03cb0bd2fd010fdba9a653dfd4515e5d3570f0a9 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 24 May 2016 00:10:47 +0200 Subject: [PATCH 054/407] atari.inc: add XDOS defines and remove trailing whitespace --- asminc/atari.inc | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/asminc/atari.inc b/asminc/atari.inc index 3cce03046..e6d165524 100644 --- a/asminc/atari.inc +++ b/asminc/atari.inc @@ -106,7 +106,7 @@ SIO_WRPERCOM = $4F ;write PERCOM block (XF551) SIO_WRITE = $50 ;write sector SIO_READ = $52 ;read sector SIO_STAT = $53 ;get status information -SIO_VERIFY = $56 ;verify sector +SIO_VERIFY = $56 ;verify sector SIO_WRITEV = $57 ;write sector with verify SIO_WRITETRK = $60 ;write track (Speedy) SIO_READTRK = $62 ;read track (Speedy) @@ -689,7 +689,7 @@ CASFLG = $030F ;CASSETTE MODE WHEN SET TIMER2 = $0310 ;2-byte final baud rate timer value TEMP1 = $0312 ;TEMPORARY STORAGE REGISTER ;TEMP2 = $0314 ;##old## TEMPORARY STORAGE REGISTER -TEMP2 = $0313 ;##1200xl## 1-byte temporary +TEMP2 = $0313 ;##1200xl## 1-byte temporary PTIMOT = $0314 ;##1200xl## 1-byte printer timeout TEMP3 = $0315 ;TEMPORARY STORAGE REGISTER SAVIO = $0316 ;SAVE SERIAL IN DATA PORT @@ -765,7 +765,7 @@ CART = $BFFC ;##rev2## 1-byte cartridge present indicator ;0=Cart Exists CARTFG = $BFFD ;##rev2## 1-byte cartridge flags ;D7 0=Not a Diagnostic Cart - ; 1=Is a Diagnostic cart and control is + ; 1=Is a Diagnostic cart and control is ; given to cart before any OS is init. ;D2 0=Init but Do not Start Cart ; 1=Init and Start Cart @@ -925,7 +925,7 @@ RADON = 0 ;INDICATES RADIANS DEGON = 6 ;INDICATES DEGREES ASCZER = '0' ;ASCII ZERO -COLON = $3A ;ASCII COLON +COLON = $3A ;ASCII COLON CR = $9B ;SYSTEM EOL (CARRIAGE RETURN) ;------------------------------------------------------------------------- @@ -1004,6 +1004,21 @@ MYDOS = 3 XDOS = 4 NODOS = 255 +;------------------------------------------------------------------------- +; XDOS defines (version 2.4, taken from xdos24.pdf) +;------------------------------------------------------------------------- + +XOPT = $70B ; XDOS options +XCAR = $70C ; XDOS cartridge address (+ $70D) +XPAT = $86F ; XDOS bugfix and patch number +XVER = $870 ; XDOS version number +XFILE = $87D ; XDOS filename buffer +XLINE = $880 ; XDOS DUP input line +XGLIN = $871 ; get line +XSKIP = $874 ; skip parameter +XMOVE = $877 ; move filename +XGNUM = $87A ; get number + ;------------------------------------------------------------------------- ; End of atari.inc ;------------------------------------------------------------------------- From 6d7dfad80b8d17f7342cdcc38d90441b5c0b22ff Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 24 May 2016 02:57:21 +0200 Subject: [PATCH 055/407] add support for XDOS command lines --- asminc/atari.inc | 13 ++++++++----- libsrc/atari/dosdetect.s | 2 +- libsrc/atari/getargs.s | 30 ++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/asminc/atari.inc b/asminc/atari.inc index e6d165524..183564f1f 100644 --- a/asminc/atari.inc +++ b/asminc/atari.inc @@ -997,12 +997,15 @@ diopp_size = 5 ; size of structure ; VALUES for dos_type ;------------------------------------------------------------------------- -ATARIDOS = 0 -SPARTADOS = 1 -OSADOS = 2 ; OS/A+ -MYDOS = 3 -XDOS = 4 +SPARTADOS = 0 +OSADOS = 1 ; OS/A+ +XDOS = 2 +ATARIDOS = 3 +MYDOS = 4 NODOS = 255 +; The DOSes with dos_type below or equal MAX_DOS_WITH_CMDLINE do support +; command line arguments. +MAX_DOS_WITH_CMDLINE = XDOS ;------------------------------------------------------------------------- ; XDOS defines (version 2.4, taken from xdos24.pdf) diff --git a/libsrc/atari/dosdetect.s b/libsrc/atari/dosdetect.s index c2888d888..68f4aefb2 100644 --- a/libsrc/atari/dosdetect.s +++ b/libsrc/atari/dosdetect.s @@ -50,4 +50,4 @@ done: rts .data -__dos_type: .byte 0 ; default to ATARIDOS +__dos_type: .byte ATARIDOS; default to ATARIDOS diff --git a/libsrc/atari/getargs.s b/libsrc/atari/getargs.s index e3b18b2f9..b1b5d258d 100644 --- a/libsrc/atari/getargs.s +++ b/libsrc/atari/getargs.s @@ -7,6 +7,8 @@ ; startup code but is nevertheless included in the compiled program when ; needed. +; XDOS support added 05/2016 by Christian Groessler + MAXARGS = 16 ; max. amount of arguments in arg. table CL_SIZE = 64 ; command line buffer size SPACE = 32 ; SPACE char. @@ -22,22 +24,30 @@ SPACE = 32 ; SPACE char. .segment "ONCE" +nargdos:rts + initmainargs: lda __dos_type ; which DOS? - cmp #ATARIDOS - beq nargdos ; DOS does not support arguments - cmp #MYDOS - bne argdos ; DOS supports arguments -nargdos:rts + cmp #MAX_DOS_WITH_CMDLINE + 1 + bcs nargdos ; Initialize ourcl buffer -argdos: lda #ATEOL - sta ourcl+CL_SIZE +argdos: ldy #ATEOL + sty ourcl+CL_SIZE -; Move SpartaDOS command line to our own buffer +; Move SpartaDOS/XDOS command line to our own buffer - lda DOSVEC + cmp #XDOS + bne sparta + + lda #<XLINE + sta ptr1 + lda #>XLINE + sta ptr1+1 + bne cpcl0 + +sparta: lda DOSVEC clc adc #<LBUF sta ptr1 @@ -45,7 +55,7 @@ argdos: lda #ATEOL adc #>LBUF sta ptr1+1 - ldy #0 +cpcl0: ldy #0 cpcl: lda (ptr1),y sta ourcl,y iny From 2dd8f9f5efdda6824c2eb95e74091be3bf0ff968 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 24 May 2016 04:37:35 +0200 Subject: [PATCH 056/407] atari.h: update _dos_type values --- include/atari.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/atari.h b/include/atari.h index 82cd07330..5e36b1daa 100644 --- a/include/atari.h +++ b/include/atari.h @@ -261,11 +261,11 @@ extern void atrx15p2_tgi[]; #define AT_PAL 1 /* valid _dos_type values */ -#define ATARIDOS 0 -#define SPARTADOS 1 -#define OSADOS 2 -#define MYDOS 3 -#define XDOS 4 +#define SPARTADOS 0 +#define OSADOS 1 +#define XDOS 2 +#define ATARIDOS 3 +#define MYDOS 4 #define NODOS 255 /* Define hardware */ From 2abbd9449262a3b41e450234085fb79f1fad34a9 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 24 May 2016 15:47:34 +0200 Subject: [PATCH 057/407] Fix style issue. --- asminc/atari.inc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/asminc/atari.inc b/asminc/atari.inc index 183564f1f..b8f883cd8 100644 --- a/asminc/atari.inc +++ b/asminc/atari.inc @@ -1011,16 +1011,16 @@ MAX_DOS_WITH_CMDLINE = XDOS ; XDOS defines (version 2.4, taken from xdos24.pdf) ;------------------------------------------------------------------------- -XOPT = $70B ; XDOS options -XCAR = $70C ; XDOS cartridge address (+ $70D) -XPAT = $86F ; XDOS bugfix and patch number -XVER = $870 ; XDOS version number -XFILE = $87D ; XDOS filename buffer -XLINE = $880 ; XDOS DUP input line -XGLIN = $871 ; get line -XSKIP = $874 ; skip parameter -XMOVE = $877 ; move filename -XGNUM = $87A ; get number +XOPT = $070B ; XDOS options +XCAR = $070C ; XDOS cartridge address (+ $70D) +XPAT = $086F ; XDOS bugfix and patch number +XVER = $0870 ; XDOS version number +XFILE = $087D ; XDOS filename buffer +XLINE = $0880 ; XDOS DUP input line +XGLIN = $0871 ; get line +XSKIP = $0874 ; skip parameter +XMOVE = $0877 ; move filename +XGNUM = $087A ; get number ;------------------------------------------------------------------------- ; End of atari.inc From 8d5717b57add7bf67c7d7a18a5c67e87b9faacbc Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 24 May 2016 15:52:12 -0400 Subject: [PATCH 058/407] Small optimization of some cc65-generated loops. "bne" means also branch-on-not-zero. Therefore, this optimization doesn't put a compare-to-zero between an increment and a "bne". --- src/cc65/codegen.c | 7 ++++--- src/cc65/stdfunc.c | 33 ++++++++++++++++++++++----------- src/cc65/stdfunc.h | 7 ++++++- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index f6ec2f51a..bf0251813 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -55,6 +55,7 @@ #include "global.h" #include "segments.h" #include "stackptr.h" +#include "stdfunc.h" #include "textseg.h" #include "util.h" #include "codegen.h" @@ -4241,7 +4242,7 @@ void g_initauto (unsigned Label, unsigned Size) AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, Label, 0)); AddCodeLine ("sta (sp),y"); AddCodeLine ("iny"); - AddCodeLine ("cpy #$%02X", (unsigned char) Size); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size); AddCodeLine ("bne %s", LocalLabelName (CodeLabel)); } } @@ -4266,10 +4267,10 @@ void g_initstatic (unsigned InitLabel, unsigned VarLabel, unsigned Size) AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, InitLabel, 0)); AddCodeLine ("sta %s,y", GetLabelName (CF_STATIC, VarLabel, 0)); AddCodeLine ("iny"); - AddCodeLine ("cpy #$%02X", (unsigned char) Size); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size); AddCodeLine ("bne %s", LocalLabelName (CodeLabel)); } else { - /* Use the easy way here: memcpy */ + /* Use the easy way here: memcpy() */ g_getimmed (CF_STATIC, VarLabel, 0); AddCodeLine ("jsr pushax"); g_getimmed (CF_STATIC, InitLabel, 0); diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 182cad1ef..720e6db15 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -185,6 +185,19 @@ static void ParseArg (ArgDesc* Arg, Type* Type) +void AddCmpCodeIfSizeNot256 (const char* Code, long Size) +/* Add a line of Assembly code that compares an index register +** only if it isn't comparing to #<256. (If the next line +** is "bne", then this will avoid a redundant line.) +*/ +{ + if (Size != 256) { + AddCodeLine (Code, (unsigned int)Size); + } +} + + + /*****************************************************************************/ /* memcpy */ /*****************************************************************************/ @@ -272,7 +285,6 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) if (Arg3.Expr.IVal <= 127) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); g_defcodelabel (Label); if (Reg2) { AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); @@ -290,7 +302,6 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) } else { AddCodeLine ("ldy #$00"); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); g_defcodelabel (Label); if (Reg2) { AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); @@ -303,7 +314,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); } AddCodeLine ("iny"); - AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } @@ -366,7 +377,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); AddCodeLine ("sta (sp),y"); AddCodeLine ("iny"); - AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal)); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } else { AddCodeLine ("ldx #$00"); @@ -376,7 +387,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("sta (sp),y"); AddCodeLine ("iny"); AddCodeLine ("inx"); - AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } @@ -440,7 +451,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("lda (sp),y"); AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); AddCodeLine ("iny"); - AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal)); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } else { AddCodeLine ("ldx #$00"); @@ -450,7 +461,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); AddCodeLine ("iny"); AddCodeLine ("inx"); - AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } @@ -487,7 +498,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("lda (sp),y"); AddCodeLine ("sta (ptr1),y"); AddCodeLine ("iny"); - AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } @@ -631,7 +642,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); } AddCodeLine ("iny"); - AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } @@ -661,7 +672,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) g_defcodelabel (Label); AddCodeLine ("sta (sp),y"); AddCodeLine ("iny"); - AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal)); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); /* memset returns the address, so the result is actually identical @@ -697,7 +708,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) g_defcodelabel (Label); AddCodeLine ("sta (ptr1),y"); AddCodeLine ("iny"); - AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } diff --git a/src/cc65/stdfunc.h b/src/cc65/stdfunc.h index 7fc3abd3e..e944d70b9 100644 --- a/src/cc65/stdfunc.h +++ b/src/cc65/stdfunc.h @@ -50,6 +50,12 @@ +void AddCmpCodeIfSizeNot256 (const char* Code, long Size); +/* Add a line of Assembly code that compares an index register +** only if it isn't comparing to #<256. (If the next line +** is "bne", then this will avoid a redundant line.) +*/ + int FindStdFunc (const char* Name); /* Determine if the given function is a known standard function that may be ** called in a special way. If so, return the index, otherwise return -1. @@ -61,5 +67,4 @@ void HandleStdFunc (int Index, struct FuncDesc* F, ExprDesc* lval); /* End of stdfunc.h */ - #endif From da65866e24efd7698e7b5675ebc926b358bd7122 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 25 May 2016 00:51:40 +0200 Subject: [PATCH 059/407] Atari: add new function '_is_cmdline_dos()' and some other small changes. - use this function instead of directly looking at _dos_type in the included targetutil and test programs - fixes/improvements to the Atari runtime library regarding the recently changed _dos_type values - libsrc/atari/targetutil/w2cas.c: exit if no filename was entered - add documentation for the new function --- doc/atari.sgml | 1 + doc/funcref.sgml | 35 +++++++++++++++++++++++++++++++++ include/atari.h | 11 ++++++----- libsrc/atari/getdefdev.s | 7 +++---- libsrc/atari/sysrmdir.s | 5 +++-- libsrc/atari/targetutil/w2cas.c | 28 +++++++++++++++++--------- testcode/lib/atari/defdev.c | 2 +- testcode/lib/atari/mem.c | 3 +-- 8 files changed, 69 insertions(+), 23 deletions(-) diff --git a/doc/atari.sgml b/doc/atari.sgml index 2087a8541..f911d568e 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -275,6 +275,7 @@ See the <url url="funcref.html" name="function reference"> for declaration and u <item>_getcolor <item>_getdefdev <item>_graphics +<item>_is_cmdline_dos <item>_rest_vecs <item>_save_vecs <item>_scroll diff --git a/doc/funcref.sgml b/doc/funcref.sgml index a2ccf6c73..9bd4a3595 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -98,6 +98,7 @@ function. <!-- <item><ref id="_getcolor" name="_getcolor"> --> <!-- <item><ref id="_getdefdev" name="_getdefdev"> --> <!-- <item><ref id="_graphics" name="_graphics"> --> +<item><ref id="_is_cmdline_dos" name="_is_cmdline_dos"> <!-- <item><ref id="_rest_vecs" name="_rest_vecs"> --> <!-- <item><ref id="_save_vecs" name="_save_vecs"> --> <!-- <item><ref id="_scroll" name="_scroll"> --> @@ -939,6 +940,40 @@ id="malloc" name="malloc"> may still return <tt/NULL/. </quote> +<sect1>_is_cmdline_dos<label id="_is_cmdline_dos"><p> + +<quote> +<descrip> +<tag/Function/Determines whether the underlying DOS supports command line arguments. +<tag/Header/<tt/<ref id="atari.h" name="atari.h">/ +<tag/Declaration/<tt/unsigned char _is_cmdline_dos (void);/ +<tag/Description/The function returns 0 if the DOS doesn't support command line arguments. +It returns 1 if it does. +<tag/Notes/<itemize> +<item>Many Atari DOSes which don't support command line arguments immediately clear the screen +and display their menu after a program exits. Therefore it might be difficult to read +the last messages printed by the program prior to its exit. This function can be used +to decide if a delay or wait for a key press should be executed when then program +exits. +</itemize> +<tag/Availability/cc65 (<tt/atari/ and <tt/atarixl/ platforms) +<tag/Example/<verb> +/* Hello World for Atari */ +#include <stdio.h> +#include <unistd.h> +#include <atari.h> +int main(void) +{ + printf("Hello World\n"); + if (! _is_cmdline_dos()) + sleep(5); + return 0; +} +</verb> +</descrip> +</quote> + + <sect1>_poserror<label id="_poserror"><p> <quote> diff --git a/include/atari.h b/include/atari.h index 5e36b1daa..fa99fca20 100644 --- a/include/atari.h +++ b/include/atari.h @@ -161,11 +161,12 @@ extern void __fastcall__ _scroll (signed char numlines); /* numlines < 0 scrolls down */ /* misc. functions */ -extern unsigned char get_ostype(void); /* get ROM version */ -extern unsigned char get_tv(void); /* get TV system */ -extern void _save_vecs(void); /* save system vectors */ -extern void _rest_vecs(void); /* restore system vectors */ -extern char *_getdefdev(void); /* get default floppy device */ +extern unsigned char get_ostype(void); /* get ROM version */ +extern unsigned char get_tv(void); /* get TV system */ +extern void _save_vecs(void); /* save system vectors */ +extern void _rest_vecs(void); /* restore system vectors */ +extern char *_getdefdev(void); /* get default floppy device */ +extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */ /* global variables */ extern unsigned char _dos_type; /* the DOS flavour */ diff --git a/libsrc/atari/getdefdev.s b/libsrc/atari/getdefdev.s index 47d8714e6..280c042e5 100644 --- a/libsrc/atari/getdefdev.s +++ b/libsrc/atari/getdefdev.s @@ -27,10 +27,9 @@ __getdefdev: lda __dos_type ; which DOS? - cmp #ATARIDOS - beq finish - cmp #MYDOS - beq finish + cmp #OSADOS+1 + bcs finish ; only supported on OS/A+ and SpartaDOS + ; (TODO: add XDOS support) ldy #BUFOFF lda #0 diff --git a/libsrc/atari/sysrmdir.s b/libsrc/atari/sysrmdir.s index 3f5b9e447..f568ded6e 100644 --- a/libsrc/atari/sysrmdir.s +++ b/libsrc/atari/sysrmdir.s @@ -26,11 +26,12 @@ pha lda __dos_type - beq not_impl ; AtariDOS cmp #OSADOS+1 bcc do_sparta ; OS/A and SpartaDOS + cmp #MYDOS + bne not_impl ; neither MyDOS, OS/A, nor SpartaDOS pla - jmp __sysremove ; MyDOS and others (TODO: check XDOS) + jmp __sysremove ; MyDOS not_impl: pla diff --git a/libsrc/atari/targetutil/w2cas.c b/libsrc/atari/targetutil/w2cas.c index 4d574da07..453785140 100644 --- a/libsrc/atari/targetutil/w2cas.c +++ b/libsrc/atari/targetutil/w2cas.c @@ -45,7 +45,7 @@ int main(int argc, char **argv) if (! iocb) { fprintf(stderr, "couldn't find a free iocb\n"); - if (_dos_type != 1) + if (! _is_cmdline_dos()) cgetc(); return 1; } @@ -57,10 +57,20 @@ int main(int argc, char **argv) printf("\nfilename: "); x = fgets(buf, 19, stdin); printf("\n"); - if (! x) + if (! x) { + printf("empty filename, exiting...\n"); + if (! _is_cmdline_dos()) + cgetc(); return 1; + } if (*x && *(x + strlen(x) - 1) == '\n') *(x + strlen(x) - 1) = 0; + if (! strlen(x)) { /* empty filename */ + printf("empty filename, exiting...\n"); + if (! _is_cmdline_dos()) + cgetc(); + return 1; + } filename = x; } else { @@ -74,7 +84,7 @@ int main(int argc, char **argv) buffer = malloc(buflen); if (! buffer) { fprintf(stderr, "cannot alloc %ld bytes -- aborting...\n", (long)buflen); - if (_dos_type != 1) + if (! _is_cmdline_dos()) cgetc(); return 1; } @@ -87,7 +97,7 @@ int main(int argc, char **argv) if (! file) { free(buffer); fprintf(stderr, "cannot open '%s': %s\n", filename, strerror(errno)); - if (_dos_type != 1) + if (! _is_cmdline_dos()) cgetc(); return 1; } @@ -101,7 +111,7 @@ int main(int argc, char **argv) file_err: fclose(file); free(buffer); - if (_dos_type != 1) + if (! _is_cmdline_dos()) cgetc(); return 1; } @@ -133,7 +143,7 @@ int main(int argc, char **argv) if (regs.y != 1) { fprintf(stderr, "CIO call to open cassette returned %d\n", regs.y); free(buffer); - if (_dos_type != 1) + if (! _is_cmdline_dos()) cgetc(); return 1; } @@ -157,7 +167,7 @@ int main(int argc, char **argv) regs.pc = 0xe456; /* CIOV */ _sys(®s); - if (_dos_type != 1) + if (! _is_cmdline_dos()) cgetc(); return 1; } @@ -173,14 +183,14 @@ int main(int argc, char **argv) if (regs.y != 1) { fprintf(stderr, "CIO call to close cassette returned %d\n", regs.y); - if (_dos_type != 1) + if (! _is_cmdline_dos()) cgetc(); return 1; } /* all is fine */ printf("success\n"); - if (_dos_type != 1) + if (! _is_cmdline_dos()) cgetc(); return 0; } diff --git a/testcode/lib/atari/defdev.c b/testcode/lib/atari/defdev.c index f679985ec..06ddb6365 100644 --- a/testcode/lib/atari/defdev.c +++ b/testcode/lib/atari/defdev.c @@ -13,6 +13,6 @@ extern char _defdev[]; int main(void) { printf("default device: %s\n", _defdev); - if (_dos_type != SPARTADOS && _dos_type != OSADOS) cgetc(); + if (! _is_cmdline_dos()) cgetc(); return 0; } diff --git a/testcode/lib/atari/mem.c b/testcode/lib/atari/mem.c index 36222e08b..a8d50cf30 100644 --- a/testcode/lib/atari/mem.c +++ b/testcode/lib/atari/mem.c @@ -11,7 +11,6 @@ extern int getsp(void); /* comes from ../getsp.s */ -extern char _dos_type; /* bss variable */ unsigned char data = 0x12; /* data variable */ unsigned int *APPMHI = (unsigned int *)14; /* 14,15 */ @@ -42,6 +41,6 @@ int main(void) printf(" sp: $%04X (stack ptr)\n", getsp()); if (allocmem) free(allocmem); - if (_dos_type != 1) cgetc(); + if (! _is_cmdline_dos()) cgetc(); return(0); } From b3d7c09ba186326c5d539a65c531a06dea566c81 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 25 May 2016 01:06:53 +0200 Subject: [PATCH 060/407] forgot to add the new file atari/is_cmdline_dos.s in my last commit... --- libsrc/atari/is_cmdline_dos.s | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libsrc/atari/is_cmdline_dos.s diff --git a/libsrc/atari/is_cmdline_dos.s b/libsrc/atari/is_cmdline_dos.s new file mode 100644 index 000000000..71b35fbad --- /dev/null +++ b/libsrc/atari/is_cmdline_dos.s @@ -0,0 +1,20 @@ +; +; Christian Groessler, May-2016 +; +; unsigned char _is_cmdline_dos(void); +; +; returns 0 for non-commandline DOS, 1 for commandline DOS +; + + .export __is_cmdline_dos + .import __dos_type + .include "atari.inc" + +__is_cmdline_dos: + ldx #0 + lda __dos_type + cmp #MAX_DOS_WITH_CMDLINE + 1 + txa + rol a + eor #$01 + rts From e2d14291b74e3cbbbc584c9d24f95860bf65313d Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 25 May 2016 01:29:00 +0200 Subject: [PATCH 061/407] make BSS segment optional in atari-cassette.cfg --- cfg/atari-cassette.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfg/atari-cassette.cfg b/cfg/atari-cassette.cfg index 84bb5ad02..5e99c303e 100644 --- a/cfg/atari-cassette.cfg +++ b/cfg/atari-cassette.cfg @@ -21,7 +21,7 @@ SEGMENTS { CODE: load = MAIN, type = ro, define = yes; RODATA: load = MAIN, type = ro, optional = yes; DATA: load = MAIN, type = rw, optional = yes; - BSS: load = MAIN, type = bss, define = yes; + BSS: load = MAIN, type = bss, define = yes, optional = yes; INIT: load = MAIN, type = bss, optional = yes; } FEATURES { From 8951e74ba7563589bf19102881ba8428ddaf55e0 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <curaga@operamail.com> Date: Fri, 27 May 2016 20:03:58 +0300 Subject: [PATCH 062/407] ld65: Be more verbose in token errors --- src/ld65/scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ld65/scanner.c b/src/ld65/scanner.c index 0f6ea58de..3c2346aac 100644 --- a/src/ld65/scanner.c +++ b/src/ld65/scanner.c @@ -505,7 +505,7 @@ void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name) } /* Not found or no identifier */ - CfgError (&CfgErrorPos, "%s expected", Name); + CfgError (&CfgErrorPos, "%s expected, got '%s'", Name, SB_GetConstBuf(&CfgSVal)); } From ac5bb6707d9ccfd2f586a0de7c2bb108e5811dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Sun, 29 May 2016 16:19:03 +0200 Subject: [PATCH 063/407] Post-review changes --- doc/Makefile | 4 ++-- libsrc/Makefile | 6 +----- libsrc/nes/Makefile.inc | 14 +++++++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 8b0b316b0..862164e1b 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -33,11 +33,11 @@ install: $(if $(prefix),,$(error variable `prefix' must be set)) ifeq ($(wildcard ../html),../html) $(INSTALL) -d $(DESTDIR)$(htmldir) - $(INSTALL) -m644 ../html/*.* $(DESTDIR)$(htmldir) + $(INSTALL) -m0644 ../html/*.* $(DESTDIR)$(htmldir) endif ifeq ($(wildcard ../info),../info) $(INSTALL) -d $(DESTDIR)$(infodir) - $(INSTALL) -m644 ../info/*.* $(DESTDIR)$(infodir) + $(INSTALL) -m0644 ../info/*.* $(DESTDIR)$(infodir) endif zip: diff --git a/libsrc/Makefile b/libsrc/Makefile index 3f6d2746c..549a7d4e9 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -78,11 +78,8 @@ all lib: $(TARGETS) mostlyclean: $(call RMDIR,../libwrk) -# Transitional line active. Final line commented out below in order to -# allow some time for transition between the directory structures clean: - $(call RMDIR,../libwrk ../lib ../targetutil ../target $(addprefix ../,$(DRVTYPES))) -# $(call RMDIR,../libwrk ../lib ../target) + $(call RMDIR,../libwrk ../lib ../target) ifdef CMD_EXE @@ -103,7 +100,6 @@ endef # INSTALL_recipe install: $(foreach dir,$(OUTPUTDIRS),$(INSTALL_recipe)) - endif # CMD_EXE define ZIP_recipe diff --git a/libsrc/nes/Makefile.inc b/libsrc/nes/Makefile.inc index 6f2e7c7d2..e23605781 100644 --- a/libsrc/nes/Makefile.inc +++ b/libsrc/nes/Makefile.inc @@ -1,8 +1,8 @@ ../target/nes/drv/tgi/nes-64-56-2.tgi: ../libwrk/nes/clrscr.o \ - ../libwrk/nes/cputc.o \ - ../libwrk/nes/get_tv.o \ - ../libwrk/nes/gotoxy.o \ - ../libwrk/nes/popa.o \ - ../libwrk/nes/ppu.o \ - ../libwrk/nes/ppubuf.o \ - ../libwrk/nes/setcursor.o + ../libwrk/nes/cputc.o \ + ../libwrk/nes/get_tv.o \ + ../libwrk/nes/gotoxy.o \ + ../libwrk/nes/popa.o \ + ../libwrk/nes/ppu.o \ + ../libwrk/nes/ppubuf.o \ + ../libwrk/nes/setcursor.o From e36a636eee796466242874507fa3712b504f08ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Sun, 29 May 2016 16:34:22 +0200 Subject: [PATCH 064/407] Indenting optimised --- libsrc/nes/Makefile.inc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libsrc/nes/Makefile.inc b/libsrc/nes/Makefile.inc index e23605781..ee43b4ff8 100644 --- a/libsrc/nes/Makefile.inc +++ b/libsrc/nes/Makefile.inc @@ -1,8 +1,9 @@ -../target/nes/drv/tgi/nes-64-56-2.tgi: ../libwrk/nes/clrscr.o \ - ../libwrk/nes/cputc.o \ - ../libwrk/nes/get_tv.o \ - ../libwrk/nes/gotoxy.o \ - ../libwrk/nes/popa.o \ - ../libwrk/nes/ppu.o \ - ../libwrk/nes/ppubuf.o \ - ../libwrk/nes/setcursor.o +../target/nes/drv/tgi/nes-64-56-2.tgi: \ + ../libwrk/nes/clrscr.o \ + ../libwrk/nes/cputc.o \ + ../libwrk/nes/get_tv.o \ + ../libwrk/nes/gotoxy.o \ + ../libwrk/nes/popa.o \ + ../libwrk/nes/ppu.o \ + ../libwrk/nes/ppubuf.o \ + ../libwrk/nes/setcursor.o From a6c306500a79120fb8398b6512bcf46065fc1c42 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 30 May 2016 14:16:37 +0200 Subject: [PATCH 065/407] Small optimization in apple2 exec.s. --- libsrc/apple2/exec.s | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libsrc/apple2/exec.s b/libsrc/apple2/exec.s index d24de604c..429afef54 100644 --- a/libsrc/apple2/exec.s +++ b/libsrc/apple2/exec.s @@ -233,11 +233,10 @@ source: jsr $BF00 system: lda $2000 cmp #$4C bne jump - lda $2003 - cmp #$EE + lda #$EE + cmp $2003 bne jump - lda $2004 - cmp #$EE + cmp $2004 bne jump ; Store cmdline in startup filename buffer From b979fb5763d44917b00d35a56bcb335ef58d5100 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 30 May 2016 14:31:53 +0200 Subject: [PATCH 066/407] Minor adjustment to recent change. --- libsrc/apple2/exec.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/apple2/exec.s b/libsrc/apple2/exec.s index 429afef54..c0cd98650 100644 --- a/libsrc/apple2/exec.s +++ b/libsrc/apple2/exec.s @@ -230,8 +230,8 @@ source: jsr $BF00 ; Check for startup filename support ; ProDOS TechRefMan, chapter 5.1.5.1: ; "$2000 is a jump instruction. $2003 and $2004 are $EE." -system: lda $2000 - cmp #$4C +system: lda #$4C + cmp $2000 bne jump lda #$EE cmp $2003 From 4dcfc036c8d29a9c57f3181931448027aeea0ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Mon, 30 May 2016 17:42:01 +0200 Subject: [PATCH 067/407] samples zip and install targets moved into samples/Makefile as agreed --- Makefile | 17 +++++++++-------- libsrc/Makefile | 1 - samples/Makefile | 49 ++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 48 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index e0530e9f0..a10df8db0 100644 --- a/Makefile +++ b/Makefile @@ -3,21 +3,22 @@ .SUFFIXES: all mostlyclean clean install zip: - @$(MAKE) -C src --no-print-directory $@ - @$(MAKE) -C libsrc --no-print-directory $@ - @$(MAKE) -C doc --no-print-directory $@ + @$(MAKE) -C src --no-print-directory $@ + @$(MAKE) -C libsrc --no-print-directory $@ + @$(MAKE) -C doc --no-print-directory $@ + @$(MAKE) -C samples --no-print-directory $@ avail unavail bin: - @$(MAKE) -C src --no-print-directory $@ + @$(MAKE) -C src --no-print-directory $@ lib: - @$(MAKE) -C libsrc --no-print-directory $@ + @$(MAKE) -C libsrc --no-print-directory $@ doc: - @$(MAKE) -C doc --no-print-directory $@ + @$(MAKE) -C doc --no-print-directory $@ %65: - @$(MAKE) -C src --no-print-directory $@ + @$(MAKE) -C src --no-print-directory $@ %: - @$(MAKE) -C libsrc --no-print-directory $@ + @$(MAKE) -C libsrc --no-print-directory $@ diff --git a/libsrc/Makefile b/libsrc/Makefile index 549a7d4e9..99f120f3a 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -42,7 +42,6 @@ OUTPUTDIRS := lib \ asminc \ cfg \ include \ - samples \ $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))\ $(subst ../,,$(wildcard ../target/*/drv/*))\ $(subst ../,,$(wildcard ../target/*/util))\ diff --git a/samples/Makefile b/samples/Makefile index 0cef19798..d9b51e827 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -12,20 +12,19 @@ SYS = c64 # source tree; otherwise, use the "install" directories. ifeq "$(wildcard ../src)" "" # No source tree -MOUS = /usr/lib/cc65/target/$(SYS)/drv/mou/$(SYS)*.mou -TGI = /usr/lib/cc65/target/$(SYS)/drv/tgi/$(SYS)*.tgi +installdir = /usr/lib/cc65 ifneq "$(wildcard /usr/local/lib/cc65)" "" -MOUS = /usr/local/lib/cc65/target/$(SYS)/drv/mou/$(SYS)*.mou -TGI = /usr/local/lib/cc65/target/$(SYS)/drv/tgi/$(SYS)*.tgi +installdir = /usr/local/lib/cc65 endif ifneq "$(wildcard /opt/local/share/cc65)" "" -MOUS = /opt/local/share/cc65/target/$(SYS)/drv/mou/$(SYS)*.mou -TGI = /opt/local/share/cc65/target/$(SYS)/drv/tgi/$(SYS)*.tgi +installdir = /opt/local/share/cc65 endif ifdef CC65_HOME -MOUS = $(CC65_HOME)/target/$(SYS)/drv/mou/$(SYS)*.mou -TGI = $(CC65_HOME)/target/$(SYS)/drv/tgi/$(SYS)*.tgi +installdir = $(CC65_HOME) endif + +MOUS = $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou +TGI = $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi CLIB = --lib $(SYS).lib CL = cl65 CC = cc65 @@ -109,8 +108,11 @@ EXELIST = ascii \ # -------------------------------------------------------------------------- # Rules to make the binaries -.PHONY: all -all: $(EXELIST) +.PHONY: all samples +all: + +samples: + $(EXELIST) # -------------------------------------------------------------------------- # Overlay rules. Overlays need special ld65 configuration files. Also, the @@ -138,9 +140,36 @@ samples.d64: all $(C1541) -attach $@ -write $$mod > /dev/null || exit $$?;\ done +# -------------------------------------------------------------------------- +# Installation rules + +INSTALL = install +samplesdir = $(prefix)/share/cc65 +.PHONY: install +install: + $(if $(prefix),,$(error variable `prefix' must be set)) + $(INSTALL) -d $(DESTDIR)$(samplesdir) + $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos + $(INSTALL) -d $$(DESTDIR)$(samplesdir)/tutorial + $(INSTALL) -m0644 *.* $(DESTDIR)$(samplesdir) + $(INSTALL) -m0644 README $(DESTDIR)$(samplesdir) + $(INSTALL) -m0644 Makefile $(DESTDIR)$(samplesdir) + $(INSTALL) -m0644 geos/*.* $(DESTDIR)$(samplesdir)/geos + $(INSTALL) -m0644 tutorial/*.* $(DESTDIR)$(samplesdir)/tutorial + +# -------------------------------------------------------------------------- +# Packaging rules + +.PHONY: zip +zip: + @cd .. && zip -r cc65 samples/ + # -------------------------------------------------------------------------- # Clean-up rules +.PHONY: mostlyclean +mostlyclean: + .PHONY: clean clean: $(RM) *~ *.map *.o *.s *.lbl From 9523fa2d33f08cc380f28e7499b7d5200ceaa37f Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 31 May 2016 07:37:58 +0200 Subject: [PATCH 068/407] Atari: get current drive on XDOS --- asminc/atari.inc | 1 + libsrc/atari/getdefdev.s | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/asminc/atari.inc b/asminc/atari.inc index b8f883cd8..f7a7ab223 100644 --- a/asminc/atari.inc +++ b/asminc/atari.inc @@ -1021,6 +1021,7 @@ XGLIN = $0871 ; get line XSKIP = $0874 ; skip parameter XMOVE = $0877 ; move filename XGNUM = $087A ; get number +XDEFDEV = $0816 ; current drive * undocumented * ;------------------------------------------------------------------------- ; End of atari.inc diff --git a/libsrc/atari/getdefdev.s b/libsrc/atari/getdefdev.s index 280c042e5..56ad8ff65 100644 --- a/libsrc/atari/getdefdev.s +++ b/libsrc/atari/getdefdev.s @@ -27,9 +27,10 @@ __getdefdev: lda __dos_type ; which DOS? - cmp #OSADOS+1 - bcs finish ; only supported on OS/A+ and SpartaDOS - ; (TODO: add XDOS support) + cmp #XDOS + beq xdos ; only supported on XDOS ... +; cmp #OSADOS+1 ; (redundant: #OSADOS+1 = #XDOS) + bcs finish ; ... and on OS/A+ and SpartaDOS ldy #BUFOFF lda #0 @@ -68,7 +69,7 @@ crvec: jsr $FFFF ; will be set to crunch vector sta __defdev iny lda (DOSVEC),y - sta __defdev+1 +done: sta __defdev+1 ; Return pointer to default device @@ -76,6 +77,11 @@ finish: lda #<__defdev ldx #>__defdev rts +; XDOS version + +xdos: lda XDEFDEV + bne done + .data ; Default device From c1f17e9c18603724c7795709cbcb4b9b5a18f60b Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 31 May 2016 09:28:53 +0200 Subject: [PATCH 069/407] Atari: make __getdefdev function ROM-friendly --- libsrc/atari/getdefdev.s | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libsrc/atari/getdefdev.s b/libsrc/atari/getdefdev.s index 56ad8ff65..ed0d49907 100644 --- a/libsrc/atari/getdefdev.s +++ b/libsrc/atari/getdefdev.s @@ -60,7 +60,7 @@ __getdefdev: lda (DOSVEC),y sta crvec+2 -crvec: jsr $FFFF ; will be set to crunch vector + jsr crvec ; Get default device @@ -84,6 +84,8 @@ xdos: lda XDEFDEV .data +crvec: .byte $4C,$FF,$FF ; will be set to crunch vector + ; Default device __defdev: From 4d02d478325f737b35a18d6efb8147c2edabd990 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 31 May 2016 10:38:02 +0200 Subject: [PATCH 070/407] Use atexit() to wait for key press at program ternination. Idea by polluks. --- libsrc/atari/targetutil/w2cas.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/libsrc/atari/targetutil/w2cas.c b/libsrc/atari/targetutil/w2cas.c index 453785140..c95ff7ba5 100644 --- a/libsrc/atari/targetutil/w2cas.c +++ b/libsrc/atari/targetutil/w2cas.c @@ -32,6 +32,13 @@ static struct __iocb *findfreeiocb(void) return NULL; } +static void exitfn(void) +{ + /* if DOS will automatically clear the screen, after the program exits, wait for a keypress... */ + if (! _is_cmdline_dos()) + cgetc(); +} + int main(int argc, char **argv) { char *filename, *x; @@ -43,10 +50,10 @@ int main(int argc, char **argv) struct __iocb *iocb = findfreeiocb(); int iocb_num; + atexit(exitfn); + if (! iocb) { fprintf(stderr, "couldn't find a free iocb\n"); - if (! _is_cmdline_dos()) - cgetc(); return 1; } iocb_num = (iocb - &IOCB) * 16; @@ -59,16 +66,12 @@ int main(int argc, char **argv) printf("\n"); if (! x) { printf("empty filename, exiting...\n"); - if (! _is_cmdline_dos()) - cgetc(); return 1; } if (*x && *(x + strlen(x) - 1) == '\n') *(x + strlen(x) - 1) = 0; if (! strlen(x)) { /* empty filename */ printf("empty filename, exiting...\n"); - if (! _is_cmdline_dos()) - cgetc(); return 1; } filename = x; @@ -84,8 +87,6 @@ int main(int argc, char **argv) buffer = malloc(buflen); if (! buffer) { fprintf(stderr, "cannot alloc %ld bytes -- aborting...\n", (long)buflen); - if (! _is_cmdline_dos()) - cgetc(); return 1; } } @@ -97,8 +98,6 @@ int main(int argc, char **argv) if (! file) { free(buffer); fprintf(stderr, "cannot open '%s': %s\n", filename, strerror(errno)); - if (! _is_cmdline_dos()) - cgetc(); return 1; } @@ -111,8 +110,6 @@ int main(int argc, char **argv) file_err: fclose(file); free(buffer); - if (! _is_cmdline_dos()) - cgetc(); return 1; } if (filen > 32767l) { @@ -143,8 +140,6 @@ int main(int argc, char **argv) if (regs.y != 1) { fprintf(stderr, "CIO call to open cassette returned %d\n", regs.y); free(buffer); - if (! _is_cmdline_dos()) - cgetc(); return 1; } @@ -167,8 +162,6 @@ int main(int argc, char **argv) regs.pc = 0xe456; /* CIOV */ _sys(®s); - if (! _is_cmdline_dos()) - cgetc(); return 1; } @@ -183,14 +176,10 @@ int main(int argc, char **argv) if (regs.y != 1) { fprintf(stderr, "CIO call to close cassette returned %d\n", regs.y); - if (! _is_cmdline_dos()) - cgetc(); return 1; } /* all is fine */ printf("success\n"); - if (! _is_cmdline_dos()) - cgetc(); return 0; } From 0114a850d9387d02ce51a592dd523f506ec92146 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 31 May 2016 12:24:21 +0200 Subject: [PATCH 071/407] Atari, getdefdev.s: use mnemonics for 'crvec'. --- libsrc/atari/getdefdev.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/getdefdev.s b/libsrc/atari/getdefdev.s index ed0d49907..a1c950dc5 100644 --- a/libsrc/atari/getdefdev.s +++ b/libsrc/atari/getdefdev.s @@ -84,7 +84,7 @@ xdos: lda XDEFDEV .data -crvec: .byte $4C,$FF,$FF ; will be set to crunch vector +crvec: jmp $FFFF ; target address will be set to crunch vector ; Default device From b7e7d1496bc3ebf90a62b75fa5ddce8ba204e1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycjusz=20R=2E=20=C5=81ogiewa?= <patrycjusz.logiewa@srebrnysen.com> Date: Wed, 1 Jun 2016 16:37:05 +0200 Subject: [PATCH 072/407] corrected all samples and samples.d64 targets --- samples/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index d9b51e827..2542275fb 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -111,8 +111,7 @@ EXELIST = ascii \ .PHONY: all samples all: -samples: - $(EXELIST) +samples: $(EXELIST) # -------------------------------------------------------------------------- # Overlay rules. Overlays need special ld65 configuration files. Also, the @@ -131,7 +130,7 @@ ovrldemo: overlaydemo.o .PHONY: disk disk: samples.d64 -samples.d64: all +samples.d64: samples @$(C1541) -format samples,AA d64 $@ > /dev/null @for exe in $(EXELIST); do\ $(C1541) -attach $@ -write $$exe > /dev/null || exit $$?;\ From 3c8fd588f6b9d348685c0fc64c5e3b3914846277 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 19:41:51 +0200 Subject: [PATCH 073/407] Don't fiddle with foreign files. No cc65 tool creates *~ files so we don't cleanup *~ files. If some other tool (like an editor) creates *~ files it's up to the user - and only him - to decide when those files are to be deleted ! --- samples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index 2542275fb..4560b35d0 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -171,7 +171,7 @@ mostlyclean: .PHONY: clean clean: - $(RM) *~ *.map *.o *.s *.lbl + $(RM) *.map *.o *.s *.lbl .PHONY: zap zap: clean From d455263e6661cfc0130a36978431a5c3f0aea006 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 19:46:02 +0200 Subject: [PATCH 074/407] Don'r presume that the C64 is the only target. Other targets have disks too and if at some point some one is interested enough to add support for disk creation for other targets too then 'disk' is no good goal name for a C64 disk. --- samples/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index 4560b35d0..aa869b088 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -127,8 +127,8 @@ ovrldemo: overlaydemo.o # Rule to make a CBM disk with all samples. Needs the c1541 program that comes # with the VICE emulator. -.PHONY: disk -disk: samples.d64 +.PHONY: d64 +d64: samples.d64 samples.d64: samples @$(C1541) -format samples,AA d64 $@ > /dev/null From 6fca6897cd600641214c54b6aab6a31bb217322f Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 20:59:33 +0200 Subject: [PATCH 075/407] Removed tab characters. The cc65 code base uses tab character only for make recipes. --- samples/Makefile | 54 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index aa869b088..dcae2f575 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -5,7 +5,7 @@ # # Enter the target system here -SYS = c64 +SYS = c64 # Determine the path to the executables and libraries. If the samples # directory is part of a complete source tree, use the stuff from that @@ -44,7 +44,7 @@ LD = ../bin/ld65 endif # This one comes with VICE -C1541 = c1541 +C1541 = c1541 # -------------------------------------------------------------------------- # System-dependent settings @@ -90,20 +90,20 @@ LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000 # List of executables. This list could be made target-dependent by checking # $(SYS). -EXELIST = ascii \ - diodemo \ - enumdevdir \ - fire \ - gunzip65 \ - hello \ - mandelbrot \ - mousetest \ - multdemo \ - nachtm \ - ovrldemo \ - plasma \ - sieve \ - tgidemo +EXELIST = ascii \ + diodemo \ + enumdevdir \ + fire \ + gunzip65 \ + hello \ + mandelbrot \ + mousetest \ + multdemo \ + nachtm \ + ovrldemo \ + plasma \ + sieve \ + tgidemo # -------------------------------------------------------------------------- # Rules to make the binaries @@ -111,26 +111,26 @@ EXELIST = ascii \ .PHONY: all samples all: -samples: $(EXELIST) +samples: $(EXELIST) # -------------------------------------------------------------------------- # Overlay rules. Overlays need special ld65 configuration files. Also, the # overlay file-names are shortenned to fit the Atari's 8.3-character limit. -multdemo: multidemo.o +multdemo: multidemo.o @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB) -ovrldemo: overlaydemo.o +ovrldemo: overlaydemo.o @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB) # -------------------------------------------------------------------------- # Rule to make a CBM disk with all samples. Needs the c1541 program that comes # with the VICE emulator. -.PHONY: d64 -d64: samples.d64 +.PHONY: d64 +d64: samples.d64 -samples.d64: samples +samples.d64: samples @$(C1541) -format samples,AA d64 $@ > /dev/null @for exe in $(EXELIST); do\ $(C1541) -attach $@ -write $$exe > /dev/null || exit $$?;\ @@ -144,7 +144,7 @@ samples.d64: samples INSTALL = install samplesdir = $(prefix)/share/cc65 -.PHONY: install +.PHONY: install install: $(if $(prefix),,$(error variable `prefix' must be set)) $(INSTALL) -d $(DESTDIR)$(samplesdir) @@ -159,7 +159,7 @@ install: # -------------------------------------------------------------------------- # Packaging rules -.PHONY: zip +.PHONY: zip zip: @cd .. && zip -r cc65 samples/ @@ -169,11 +169,11 @@ zip: .PHONY: mostlyclean mostlyclean: -.PHONY: clean +.PHONY: clean clean: $(RM) *.map *.o *.s *.lbl -.PHONY: zap -zap: clean +.PHONY: zap +zap: clean $(RM) $(EXELIST) samples.d64 $(RM) multdemo.? ovrldemo.? From d78b44f8c601c942274bc88ed038c2364c8f47be Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 21:08:47 +0200 Subject: [PATCH 076/407] Adjusted to the cc65 Makefile style. The cc65 Makefiles have a single .PHONY target. It serves as an overview of the "interesting" goals supported by the Makfile. --- samples/Makefile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index dcae2f575..7ab9a13e6 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -69,6 +69,8 @@ LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000 # -------------------------------------------------------------------------- # Generic rules +.PHONY: all mostlyclean clean install zip samples d64 zap + %: %.c %: %.s @@ -108,7 +110,6 @@ EXELIST = ascii \ # -------------------------------------------------------------------------- # Rules to make the binaries -.PHONY: all samples all: samples: $(EXELIST) @@ -127,7 +128,6 @@ ovrldemo: overlaydemo.o # Rule to make a CBM disk with all samples. Needs the c1541 program that comes # with the VICE emulator. -.PHONY: d64 d64: samples.d64 samples.d64: samples @@ -144,7 +144,7 @@ samples.d64: samples INSTALL = install samplesdir = $(prefix)/share/cc65 -.PHONY: install + install: $(if $(prefix),,$(error variable `prefix' must be set)) $(INSTALL) -d $(DESTDIR)$(samplesdir) @@ -159,21 +159,17 @@ install: # -------------------------------------------------------------------------- # Packaging rules -.PHONY: zip zip: @cd .. && zip -r cc65 samples/ # -------------------------------------------------------------------------- # Clean-up rules -.PHONY: mostlyclean mostlyclean: -.PHONY: clean clean: $(RM) *.map *.o *.s *.lbl -.PHONY: zap zap: clean $(RM) $(EXELIST) samples.d64 $(RM) multdemo.? ovrldemo.? From ec06d162bd82038de2312a7a07d6a160ab169f35 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 22:14:30 +0200 Subject: [PATCH 077/407] Fixed clean goal on Windows. Now that the clean goal of the samples Makefile is part of the global clean goal it should work on Windows! BTW: Ideally the whole samples Makefile should work on Windows ;-)) --- samples/Makefile | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index 7ab9a13e6..f90cafa5a 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -7,6 +7,18 @@ # Enter the target system here SYS = c64 +ifneq ($(shell echo),) + CMD_EXE = 1 +endif + +ifdef CMD_EXE + NULLDEV = nul: + DEL = -del /f +else + NULLDEV = /dev/null + DEL = $(RM) +endif + # Determine the path to the executables and libraries. If the samples # directory is part of a complete source tree, use the stuff from that # source tree; otherwise, use the "install" directories. @@ -131,12 +143,12 @@ ovrldemo: overlaydemo.o d64: samples.d64 samples.d64: samples - @$(C1541) -format samples,AA d64 $@ > /dev/null + @$(C1541) -format samples,AA d64 $@ >$(NULLDEV) @for exe in $(EXELIST); do\ - $(C1541) -attach $@ -write $$exe > /dev/null || exit $$?;\ + $(C1541) -attach $@ -write $$exe >$(NULLDEV) || exit $$?;\ done @for mod in $(TGI) $(MOUS); do\ - $(C1541) -attach $@ -write $$mod > /dev/null || exit $$?;\ + $(C1541) -attach $@ -write $$mod >$(NULLDEV) || exit $$?;\ done # -------------------------------------------------------------------------- @@ -168,8 +180,8 @@ zip: mostlyclean: clean: - $(RM) *.map *.o *.s *.lbl + @$(DEL) *.map *.o *.s *.lbl 2>$(NULLDEV) zap: clean - $(RM) $(EXELIST) samples.d64 - $(RM) multdemo.? ovrldemo.? + @$(DEL) $(EXELIST) samples.d64 2>$(NULLDEV) + @$(DEL) multdemo.? ovrldemo.? 2>$(NULLDEV) From b75e36bba18e9a86ed45c1d9be833cfc59510526 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 22:36:38 +0200 Subject: [PATCH 078/407] Don't ignore more than necessary. We know that the one and only cc65.zip we want to ignore lives in the root directory. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index dac38c48b..ad4d26c3f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ /target/ /testwrk/ /wrk/ -cc65.zip +/cc65.zip From 506e44fb5dbfff0aed898823256dbe79346ac8a6 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 22:50:42 +0200 Subject: [PATCH 079/407] Corrected cleanup semantics. There's no zap goal in cc65 Makefiles. --- samples/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index f90cafa5a..26b0e42f4 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -81,7 +81,7 @@ LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000 # -------------------------------------------------------------------------- # Generic rules -.PHONY: all mostlyclean clean install zip samples d64 zap +.PHONY: all mostlyclean clean install zip samples d64 %: %.c %: %.s @@ -178,10 +178,8 @@ zip: # Clean-up rules mostlyclean: - -clean: @$(DEL) *.map *.o *.s *.lbl 2>$(NULLDEV) -zap: clean +clean: mostlyclean @$(DEL) $(EXELIST) samples.d64 2>$(NULLDEV) @$(DEL) multdemo.? ovrldemo.? 2>$(NULLDEV) From 1ab725e526d542c2ccf816f10133ff508c399c9b Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 23:00:37 +0200 Subject: [PATCH 080/407] Don't hide build commands. The samples Makefile serves educational purposes. From that perspective it's counterproductive to hide the actual build commands. Apart fom that it becomes visible if an installed cc65 is used to build the samples. --- samples/Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index 26b0e42f4..2b356b384 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -87,18 +87,16 @@ LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000 %: %.s .c.o: - @echo $< - @$(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $< - @$(AS) $(<:.c=.s) + $(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $< + $(AS) $(<:.c=.s) .s.o: - @echo $< - @$(AS) $(AFLAGS) -t $(SYS) $< + $(AS) $(AFLAGS) -t $(SYS) $< .PRECIOUS: %.o .o: - @$(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB) + $(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB) # -------------------------------------------------------------------------- # List of executables. This list could be made target-dependent by checking @@ -131,10 +129,10 @@ samples: $(EXELIST) # overlay file-names are shortenned to fit the Atari's 8.3-character limit. multdemo: multidemo.o - @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB) + $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB) ovrldemo: overlaydemo.o - @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB) + $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB) # -------------------------------------------------------------------------- # Rule to make a CBM disk with all samples. Needs the c1541 program that comes From 38778cdeb6fc6b8f83b3631e423d63e648d86d53 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 23:04:46 +0200 Subject: [PATCH 081/407] Don't cleanup files "just in case". The build doesn't create *.lbl files so we're not deleting *.lbl files. --- samples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index 2b356b384..fa3777000 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -176,7 +176,7 @@ zip: # Clean-up rules mostlyclean: - @$(DEL) *.map *.o *.s *.lbl 2>$(NULLDEV) + @$(DEL) *.map *.o *.s 2>$(NULLDEV) clean: mostlyclean @$(DEL) $(EXELIST) samples.d64 2>$(NULLDEV) From 24256256fb772ed34c5197bcfba109278c471052 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 23:45:27 +0200 Subject: [PATCH 082/407] Removed shell for-loop. Just a few of the many reasons why shell for-loops have no place in (GNUmake) Makefiles: * They don't conform to https://www.gnu.org/software/make/manual/html_node/Utilities-in-Makefiles.html * They break Windows builds for sure * They don't fit to make's approach of working with sets * They break make parallelism --- samples/Makefile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index fa3777000..5a75c7f4b 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -35,8 +35,8 @@ ifdef CC65_HOME installdir = $(CC65_HOME) endif -MOUS = $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou -TGI = $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi +MOUS := $(wildcard $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou) +TGI := $(wildcard $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi) CLIB = --lib $(SYS).lib CL = cl65 CC = cc65 @@ -46,8 +46,8 @@ LD = ld65 else # "samples/" is a part of a complete source tree. export CC65_HOME := $(abspath ..) -MOUS = ../target/$(SYS)/drv/mou/$(SYS)*.mou -TGI = ../target/$(SYS)/drv/tgi/$(SYS)*.tgi +MOUS := $(wildcard ../target/$(SYS)/drv/mou/$(SYS)*.mou) +TGI := $(wildcard ../target/$(SYS)/drv/tgi/$(SYS)*.tgi) CLIB = ../lib/$(SYS).lib CL = ../bin/cl65 CC = ../bin/cc65 @@ -140,14 +140,16 @@ ovrldemo: overlaydemo.o d64: samples.d64 +define D64_WRITE_recipe + +$(C1541) -attach $@ -write $(file) $(notdir $(file)) >$(NULLDEV) + +endef # D64_WRITE_recipe + samples.d64: samples @$(C1541) -format samples,AA d64 $@ >$(NULLDEV) - @for exe in $(EXELIST); do\ - $(C1541) -attach $@ -write $$exe >$(NULLDEV) || exit $$?;\ - done - @for mod in $(TGI) $(MOUS); do\ - $(C1541) -attach $@ -write $$mod >$(NULLDEV) || exit $$?;\ - done + $(foreach file,$(EXELIST),$(D64_WRITE_recipe)) + $(foreach file,$(TGI) $(MOUS),$(D64_WRITE_recipe)) # -------------------------------------------------------------------------- # Installation rules From d653054d980db55fb12f3413b20509324778de84 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 23:48:09 +0200 Subject: [PATCH 083/407] Allow usage of C1541 environment variable. --- samples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index 5a75c7f4b..df8aab38e 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -56,7 +56,7 @@ LD = ../bin/ld65 endif # This one comes with VICE -C1541 = c1541 +C1541 ?= c1541 # -------------------------------------------------------------------------- # System-dependent settings From ce45f759873e20a839dc2997f2376856f80fd9d3 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 1 Jun 2016 23:51:43 +0200 Subject: [PATCH 084/407] Harmonized goal name. --- test/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Makefile b/test/Makefile index 1ad86ca98..ffdf72aa0 100644 --- a/test/Makefile +++ b/test/Makefile @@ -25,7 +25,7 @@ WORKDIR := ../testwrk CC := gcc -.PHONY: all dotests continue mostly-clean clean +.PHONY: all dotests continue mostlyclean clean all: dotests @@ -37,7 +37,7 @@ $(WORKDIR)/bdiff$(EXE): bdiff.c | $(WORKDIR) .NOTPARALLEL: -dotests: mostly-clean continue +dotests: mostlyclean continue continue: $(WORKDIR)/bdiff$(EXE) @$(MAKE) -C val all @@ -45,12 +45,12 @@ continue: $(WORKDIR)/bdiff$(EXE) @$(MAKE) -C err all @$(MAKE) -C misc all -mostly-clean: +mostlyclean: @$(MAKE) -C val clean @$(MAKE) -C ref clean @$(MAKE) -C err clean @$(MAKE) -C misc clean -clean: mostly-clean +clean: mostlyclean @$(call DEL,$(WORKDIR)/bdiff$(EXE)) @$(call RMDIR,$(WORKDIR)) From 9f01392922d47fe5062b0446df740c0165396e57 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 2 Jun 2016 20:49:10 +0200 Subject: [PATCH 085/407] Write overlays to d64 image. --- samples/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/Makefile b/samples/Makefile index df8aab38e..c138c1c2e 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -134,6 +134,8 @@ multdemo: multidemo.o ovrldemo: overlaydemo.o $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB) +OVERLAYLIST := $(foreach I,1 2 3,multdemo.$I ovrldemo.$I) + # -------------------------------------------------------------------------- # Rule to make a CBM disk with all samples. Needs the c1541 program that comes # with the VICE emulator. @@ -149,6 +151,7 @@ endef # D64_WRITE_recipe samples.d64: samples @$(C1541) -format samples,AA d64 $@ >$(NULLDEV) $(foreach file,$(EXELIST),$(D64_WRITE_recipe)) + $(foreach file,$(OVERLAYLIST),$(D64_WRITE_recipe)) $(foreach file,$(TGI) $(MOUS),$(D64_WRITE_recipe)) # -------------------------------------------------------------------------- From 8dd003d2b3e462ca982016d64d17a01dddc8a771 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 3 Jun 2016 11:08:53 +0200 Subject: [PATCH 086/407] Added --print-target-path option. If cc65 is installed and used as designed there's no need whatsoever for CC65_HOME (both on *IX and Windows) from the perspective of the cc65 binaries. If the user however has to access files from the 'target' directory thenhe ends up with some assumption on the cc65 installation path nevertheless :-( In order to avoid this I added the --print-target-path option. It "exports" the logic used by the cc65 binaries to locate their files to the user thus allowing him to leverage the same logic to locate the target files in his build scripts / Makefiles. --- doc/cl65.sgml | 15 ++++- src/Makefile | 4 +- src/cl65/main.c | 120 +++++++++++++++++++++++----------------- src/common/searchpath.c | 12 ++++ src/common/searchpath.h | 5 ++ 5 files changed, 103 insertions(+), 53 deletions(-) diff --git a/doc/cl65.sgml b/doc/cl65.sgml index 6e044b8d5..6f29fa29d 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -103,6 +103,7 @@ Long options: --o65-model model Override the o65 model --obj file Link this object file --obj-path path Specify an object file search path + --print-target-path Print the target file path --register-space b Set space available for register variables --register-vars Enable register variables --rodata-name seg Set the name of the RODATA segment @@ -154,6 +155,14 @@ There are a few remaining options that control the behaviour of cl65: shouldn't use -o when more than one output file is created. + <tag><tt>--print-target-path</tt></tag> + + This option prints the absolute path of the target file directory and exits + then. It is supposed to be used with shell backquotes or the GNU make shell + function This way you can write build scripts or Makefiles accessing target + files without any assumption about the cc65 installation path. + + <tag><tt>-t sys, --target sys</tt></tag> The default for this option is different from the compiler and linker in the @@ -162,6 +171,7 @@ There are a few remaining options that control the behaviour of cl65: the C64 as a target system by default. This was chosen since most people seem to use cc65 to develop for the C64. + <tag><tt>-Wa options, --asm-args options</tt></tag> Pass options directly to the assembler. This may be used to pass options @@ -172,6 +182,7 @@ There are a few remaining options that control the behaviour of cl65: if cl65 supports an option by itself, do not pass this option to the assembler by means of the <tt/-Wa/ switch. + <tag><tt>-Wc options, --cc-args options</tt></tag> Pass options directly to the compiler. This may be used to pass options @@ -182,6 +193,7 @@ There are a few remaining options that control the behaviour of cl65: if cl65 supports an option by itself, do not pass this option to the compiler by means of the <tt/-Wc/ switch. + <tag><tt>-Wl options, --ld-args options</tt></tag> Pass options directly to the linker. This may be used to pass options that @@ -192,7 +204,7 @@ There are a few remaining options that control the behaviour of cl65: supports an option by itself, do not pass this option to the linker by means of the <tt/-Wl/ switch. -</descrip> +</descrip> @@ -304,4 +316,3 @@ freely, subject to the following restrictions: </article> - diff --git a/src/Makefile b/src/Makefile index f10c189b3..edb6f5aa8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,6 +24,7 @@ datadir := $(if $(prefix),$(prefix)/share/cc65,$(abspath ..)) CA65_INC = $(datadir)/asminc CC65_INC = $(datadir)/include +CL65_TGT = $(datadir)/target LD65_LIB = $(datadir)/lib LD65_OBJ = $(datadir)/lib LD65_CFG = $(datadir)/cfg @@ -63,8 +64,9 @@ endif CFLAGS += -MMD -MP -O -I common \ -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \ - -DGIT_SHA=$(GIT_SHA) -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \ + -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) -DCL65_TGT=$(CL65_TGT) \ -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) + -DGIT_SHA=$(GIT_SHA) LDLIBS += -lm diff --git a/src/cl65/main.c b/src/cl65/main.c index 4268a569b..654bd97b2 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -73,6 +73,7 @@ #include "filetype.h" #include "fname.h" #include "mmodel.h" +#include "searchpath.h" #include "strbuf.h" #include "target.h" #include "version.h" @@ -759,6 +760,7 @@ static void Usage (void) " --o65-model model\t\tOverride the o65 model\n" " --obj file\t\t\tLink this object file\n" " --obj-path path\t\tSpecify an object file search path\n" + " --print-target-path\t\tPrint the target file path\n" " --register-space b\t\tSet space available for register variables\n" " --register-vars\t\tEnable register variables\n" " --rodata-name seg\t\tSet the name of the RODATA segment\n" @@ -1126,6 +1128,23 @@ static void OptObjPath (const char* Opt attribute ((unused)), const char* Arg) +static void OptPrintTargetPath (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Print the target file path */ +{ + SearchPaths* TargetPath = NewSearchPath (); + AddSubSearchPathFromEnv (TargetPath, "CC65_HOME", "target"); +#if defined(CL65_TGT) && !defined(_WIN32) + AddSearchPath (TargetPath, STRINGIZE (CL65_TGT)); +#endif + AddSubSearchPathFromWinBin (TargetPath, "target"); + + printf ("%s\n", GetSearchPath (TargetPath, 0)); + exit (EXIT_SUCCESS); +} + + + static void OptRegisterSpace (const char* Opt attribute ((unused)), const char* Arg) /* Handle the --register-space option */ { @@ -1240,56 +1259,57 @@ int main (int argc, char* argv []) { /* Program long options */ static const LongOpt OptTab[] = { - { "--add-source", 0, OptAddSource }, - { "--asm-args", 1, OptAsmArgs }, - { "--asm-define", 1, OptAsmDefine }, - { "--asm-include-dir", 1, OptAsmIncludeDir }, - { "--bin-include-dir", 1, OptBinIncludeDir }, - { "--bss-label", 1, OptBssLabel }, - { "--bss-name", 1, OptBssName }, - { "--cc-args", 1, OptCCArgs }, - { "--cfg-path", 1, OptCfgPath }, - { "--check-stack", 0, OptCheckStack }, - { "--code-label", 1, OptCodeLabel }, - { "--code-name", 1, OptCodeName }, - { "--codesize", 1, OptCodeSize }, - { "--config", 1, OptConfig }, - { "--cpu", 1, OptCPU }, - { "--create-dep", 1, OptCreateDep }, - { "--create-full-dep", 1, OptCreateFullDep }, - { "--data-label", 1, OptDataLabel }, - { "--data-name", 1, OptDataName }, - { "--debug", 0, OptDebug }, - { "--debug-info", 0, OptDebugInfo }, - { "--feature", 1, OptFeature }, - { "--force-import", 1, OptForceImport }, - { "--help", 0, OptHelp }, - { "--include-dir", 1, OptIncludeDir }, - { "--ld-args", 1, OptLdArgs }, - { "--lib", 1, OptLib }, - { "--lib-path", 1, OptLibPath }, - { "--list-targets", 0, OptListTargets }, - { "--listing", 1, OptListing }, - { "--list-bytes", 1, OptListBytes }, - { "--mapfile", 1, OptMapFile }, - { "--memory-model", 1, OptMemoryModel }, - { "--module", 0, OptModule }, - { "--module-id", 1, OptModuleId }, - { "--o65-model", 1, OptO65Model }, - { "--obj", 1, OptObj }, - { "--obj-path", 1, OptObjPath }, - { "--register-space", 1, OptRegisterSpace }, - { "--register-vars", 0, OptRegisterVars }, - { "--rodata-name", 1, OptRodataName }, - { "--signed-chars", 0, OptSignedChars }, - { "--standard", 1, OptStandard }, - { "--start-addr", 1, OptStartAddr }, - { "--static-locals", 0, OptStaticLocals }, - { "--target", 1, OptTarget }, - { "--verbose", 0, OptVerbose }, - { "--version", 0, OptVersion }, - { "--zeropage-label", 1, OptZeropageLabel }, - { "--zeropage-name", 1, OptZeropageName }, + { "--add-source", 0, OptAddSource }, + { "--asm-args", 1, OptAsmArgs }, + { "--asm-define", 1, OptAsmDefine }, + { "--asm-include-dir", 1, OptAsmIncludeDir }, + { "--bin-include-dir", 1, OptBinIncludeDir }, + { "--bss-label", 1, OptBssLabel }, + { "--bss-name", 1, OptBssName }, + { "--cc-args", 1, OptCCArgs }, + { "--cfg-path", 1, OptCfgPath }, + { "--check-stack", 0, OptCheckStack }, + { "--code-label", 1, OptCodeLabel }, + { "--code-name", 1, OptCodeName }, + { "--codesize", 1, OptCodeSize }, + { "--config", 1, OptConfig }, + { "--cpu", 1, OptCPU }, + { "--create-dep", 1, OptCreateDep }, + { "--create-full-dep", 1, OptCreateFullDep }, + { "--data-label", 1, OptDataLabel }, + { "--data-name", 1, OptDataName }, + { "--debug", 0, OptDebug }, + { "--debug-info", 0, OptDebugInfo }, + { "--feature", 1, OptFeature }, + { "--force-import", 1, OptForceImport }, + { "--help", 0, OptHelp }, + { "--include-dir", 1, OptIncludeDir }, + { "--ld-args", 1, OptLdArgs }, + { "--lib", 1, OptLib }, + { "--lib-path", 1, OptLibPath }, + { "--list-targets", 0, OptListTargets }, + { "--listing", 1, OptListing }, + { "--list-bytes", 1, OptListBytes }, + { "--mapfile", 1, OptMapFile }, + { "--memory-model", 1, OptMemoryModel }, + { "--module", 0, OptModule }, + { "--module-id", 1, OptModuleId }, + { "--o65-model", 1, OptO65Model }, + { "--obj", 1, OptObj }, + { "--obj-path", 1, OptObjPath }, + { "--print-target-path", 0, OptPrintTargetPath}, + { "--register-space", 1, OptRegisterSpace }, + { "--register-vars", 0, OptRegisterVars }, + { "--rodata-name", 1, OptRodataName }, + { "--signed-chars", 0, OptSignedChars }, + { "--standard", 1, OptStandard }, + { "--start-addr", 1, OptStartAddr }, + { "--static-locals", 0, OptStaticLocals }, + { "--target", 1, OptTarget }, + { "--verbose", 0, OptVerbose }, + { "--version", 0, OptVersion }, + { "--zeropage-label", 1, OptZeropageLabel }, + { "--zeropage-name", 1, OptZeropageName }, }; char* CmdPath; diff --git a/src/common/searchpath.c b/src/common/searchpath.c index 78443f34c..ca7017e6f 100644 --- a/src/common/searchpath.c +++ b/src/common/searchpath.c @@ -238,6 +238,18 @@ void PopSearchPath (SearchPaths* P) +char* GetSearchPath (SearchPaths* P, unsigned Index) +/* Return the search path at the given index, if the index is valid, return an +** empty string otherwise. +*/ +{ + if (Index < CollCount (P)) + return CollAtUnchecked (P, Index); + return ""; +} + + + char* SearchFile (const SearchPaths* P, const char* File) /* Search for a file in a list of directories. Return a pointer to a malloced ** area that contains the complete path, if found, return 0 otherwise. diff --git a/src/common/searchpath.h b/src/common/searchpath.h index 6f5bafa7a..974886a67 100644 --- a/src/common/searchpath.h +++ b/src/common/searchpath.h @@ -94,6 +94,11 @@ int PushSearchPath (SearchPaths* P, const char* NewPath); void PopSearchPath (SearchPaths* P); /* Remove a search path from the head of an existing search path list */ +char* GetSearchPath (SearchPaths* P, unsigned Index); +/* Return the search path at the given index, if the index is valid, return an +** empty string otherwise. +*/ + char* SearchFile (const SearchPaths* P, const char* File); /* Search for a file in a list of directories. Return a pointer to a malloced ** area that contains the complete path, if found, return 0 otherwise. From 6f0b57fe514c0656c179189f73399a2a52907eee Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 3 Jun 2016 11:37:15 +0200 Subject: [PATCH 087/407] Added chrcvt65 to the Visual Studio project. --- src/cc65.sln | 9 +++++ src/chrcvt65.vcxproj | 87 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 src/chrcvt65.vcxproj diff --git a/src/cc65.sln b/src/cc65.sln index 9d0f2cc2e..4ae2816ad 100644 --- a/src/cc65.sln +++ b/src/cc65.sln @@ -58,6 +58,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sim65", "sim65.vcxproj", "{ {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chrcvt65", "chrcvt65.vcxproj", "{1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -112,6 +117,10 @@ Global {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.Build.0 = Debug|Win32 {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.ActiveCfg = Release|Win32 {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.Build.0 = Release|Win32 + {1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}.Debug|Win32.ActiveCfg = Debug|Win32 + {1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}.Debug|Win32.Build.0 = Debug|Win32 + {1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}.Release|Win32.ActiveCfg = Release|Win32 + {1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/chrcvt65.vcxproj b/src/chrcvt65.vcxproj new file mode 100644 index 000000000..1daf7cae9 --- /dev/null +++ b/src/chrcvt65.vcxproj @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>chrcvt65</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>v120</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>$(SolutionDir)..\bin\</OutDir> + <IntDir>$(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <OutDir>$(SolutionDir)..\bin\</OutDir> + <IntDir>$(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CONSOLE;_DEBUG</PreprocessorDefinitions> + <AdditionalIncludeDirectories>common</AdditionalIncludeDirectories> + <TreatWarningAsError>true</TreatWarningAsError> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalDependencies>$(IntDir)..\..\common\$(Configuration)\common.lib</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CONSOLE;NDEBUG</PreprocessorDefinitions> + <AdditionalIncludeDirectories>common</AdditionalIncludeDirectories> + <TreatWarningAsError>true</TreatWarningAsError> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>false</GenerateDebugInformation> + <AdditionalDependencies>$(IntDir)..\..\common\$(Configuration)\common.lib</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="chrcvt65\error.c" /> + <ClCompile Include="chrcvt65\main.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="chrcvt65\error.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> \ No newline at end of file From 02b84698757753fec2019de18cb75da9d014085d Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 3 Jun 2016 21:21:22 +0200 Subject: [PATCH 088/407] Added full stop. --- doc/cl65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cl65.sgml b/doc/cl65.sgml index 6f29fa29d..b9a6cd1e4 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -159,7 +159,7 @@ There are a few remaining options that control the behaviour of cl65: This option prints the absolute path of the target file directory and exits then. It is supposed to be used with shell backquotes or the GNU make shell - function This way you can write build scripts or Makefiles accessing target + function. This way you can write build scripts or Makefiles accessing target files without any assumption about the cc65 installation path. From d67099881477e82f6539e69df6fc2e9622480466 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 5 Jun 2016 13:00:37 +0200 Subject: [PATCH 089/407] Added Apple II version of doesclrscrafterexit(). The prototype and documentation is supposed to be provided together with the ATARI version. --- libsrc/apple2/doesclrscr.s | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 libsrc/apple2/doesclrscr.s diff --git a/libsrc/apple2/doesclrscr.s b/libsrc/apple2/doesclrscr.s new file mode 100644 index 000000000..2e2e7b96f --- /dev/null +++ b/libsrc/apple2/doesclrscr.s @@ -0,0 +1,21 @@ +; +; Oliver Schmidt, 2016-06-05 +; +; unsigned char doesclrscrafterexit (void); +; + + .export _doesclrscrafterexit + .import done + + .include "apple2.inc" + +_doesclrscrafterexit: + ; If the page we jump to when done equals the page + ; of the warmstart vector we'll return to BASIC so + ; there's no implicit clrscr() after exit(). + lda done+2 + sec + sbc #>DOSWARM + + ldx #>$0000 + rts From 13482984ca38c5a34a51321d0806f3e4a73122ff Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 5 Jun 2016 14:58:38 +0200 Subject: [PATCH 090/407] Introduced internal gotoxy that pops both parameters. About all CONIO functions offering a <...>xy variant call popa _gotoxy By providing an internal gotoxy variant that starts with a popa all those CONIO function can be shortened by 3 bytes. As soon as program calls more than one CONIO function this means an overall code size reduction. --- libsrc/apple2/cclear.s | 5 ++--- libsrc/apple2/chline.s | 5 ++--- libsrc/apple2/cputc.s | 7 +++---- libsrc/apple2/cvline.s | 5 ++--- libsrc/apple2/gotoxy.s | 5 ++++- libsrc/atari/cclear.s | 5 ++--- libsrc/atari/chline.s | 5 ++--- libsrc/atari/cputc.s | 5 ++--- libsrc/atari/cvline.s | 5 ++--- libsrc/atari/gotoxy.s | 7 +++++-- libsrc/atari5200/cputc.s | 5 ++--- libsrc/atari5200/gotoxy.s | 5 ++++- libsrc/c128/cputc.s | 5 ++--- libsrc/c16/cputc.s | 5 ++--- libsrc/c64/cputc.s | 5 ++--- libsrc/c64/soft80_cputc.s | 5 ++--- libsrc/c64/soft80mono_cputc.s | 5 ++--- libsrc/cbm/cclear.s | 9 ++------- libsrc/cbm/chline.s | 9 ++------- libsrc/cbm/cvline.s | 8 ++------ libsrc/cbm/gotoxy.s | 5 ++++- libsrc/cbm510/cputc.s | 5 ++--- libsrc/cbm610/cputc.s | 6 ++---- libsrc/conio/cputs.s | 5 ++--- libsrc/gamate/chline.s | 5 ++--- libsrc/gamate/cputc.s | 5 ++--- libsrc/gamate/cvline.s | 5 ++--- libsrc/gamate/gotoxy.s | 5 ++++- libsrc/geos-common/conio/cclear.s | 5 ++--- libsrc/geos-common/conio/chline.s | 5 ++--- libsrc/geos-common/conio/cputc.s | 6 ++---- libsrc/geos-common/conio/cvline.s | 5 ++--- libsrc/geos-common/conio/gotoxy.s | 5 ++++- libsrc/nes/cclear.s | 5 ++--- libsrc/nes/chline.s | 5 ++--- libsrc/nes/cputc.s | 5 ++--- libsrc/nes/cvline.s | 5 ++--- libsrc/nes/gotoxy.s | 10 ++++------ libsrc/osic1p/cclear.s | 5 ++--- libsrc/osic1p/chline.s | 5 ++--- libsrc/osic1p/cvline.s | 5 ++--- libsrc/osic1p/gotoxy.s | 5 ++++- libsrc/osic1p/osiscreen.inc | 5 ++--- libsrc/pce/chline.s | 5 ++--- libsrc/pce/cputc.s | 5 ++--- libsrc/pce/cvline.s | 5 ++--- libsrc/pce/gotoxy.s | 5 ++++- libsrc/pet/cputc.s | 5 ++--- libsrc/plus4/cputc.s | 5 ++--- libsrc/vic20/cputc.s | 5 ++--- 50 files changed, 120 insertions(+), 152 deletions(-) diff --git a/libsrc/apple2/cclear.s b/libsrc/apple2/cclear.s index c06cb0812..4106752eb 100644 --- a/libsrc/apple2/cclear.s +++ b/libsrc/apple2/cclear.s @@ -6,12 +6,11 @@ ; .export _cclearxy, _cclear - .import popa, _gotoxy, chlinedirect + .import gotoxy, chlinedirect _cclearxy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cclear _cclear: diff --git a/libsrc/apple2/chline.s b/libsrc/apple2/chline.s index dba094365..6cf77de1b 100644 --- a/libsrc/apple2/chline.s +++ b/libsrc/apple2/chline.s @@ -6,15 +6,14 @@ ; .export _chlinexy, _chline, chlinedirect - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .include "zeropage.inc" .include "apple2.inc" _chlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _chline _chline: diff --git a/libsrc/apple2/cputc.s b/libsrc/apple2/cputc.s index 2db2962f9..6607c6178 100644 --- a/libsrc/apple2/cputc.s +++ b/libsrc/apple2/cputc.s @@ -10,7 +10,7 @@ .endif .export _cputcxy, _cputc .export cputdirect, newline, putchar - .import popa, _gotoxy, VTABZ + .import gotoxy, VTABZ .include "apple2.inc" @@ -29,9 +29,8 @@ initconio: _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy - pla ; Restore C + jsr gotoxy ; Call this one, will pop params + pla ; Restore C and run into _cputc _cputc: cmp #$0D ; Test for \r = carrage return diff --git a/libsrc/apple2/cvline.s b/libsrc/apple2/cvline.s index 1ac3fad74..a26cc7063 100644 --- a/libsrc/apple2/cvline.s +++ b/libsrc/apple2/cvline.s @@ -6,14 +6,13 @@ ; .export _cvlinexy, _cvline, cvlinedirect - .import popa, _gotoxy, putchar, newline + .import gotoxy, putchar, newline .include "zeropage.inc" _cvlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cvline _cvline: diff --git a/libsrc/apple2/gotoxy.s b/libsrc/apple2/gotoxy.s index dc96ac75e..6755af8d8 100644 --- a/libsrc/apple2/gotoxy.s +++ b/libsrc/apple2/gotoxy.s @@ -5,11 +5,14 @@ ; void __fastcall__ gotox (unsigned char x); ; - .export _gotoxy, _gotox + .export gotoxy, _gotoxy, _gotox .import popa, VTABZ .include "apple2.inc" +gotoxy: + jsr popa ; Get Y + _gotoxy: clc adc WNDTOP diff --git a/libsrc/atari/cclear.s b/libsrc/atari/cclear.s index ceb17aca5..7fe3f0f1b 100644 --- a/libsrc/atari/cclear.s +++ b/libsrc/atari/cclear.s @@ -6,13 +6,12 @@ ; .export _cclearxy, _cclear - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .importzp tmp1 _cclearxy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cclear _cclear: diff --git a/libsrc/atari/chline.s b/libsrc/atari/chline.s index a096f35a0..194fe0bb3 100644 --- a/libsrc/atari/chline.s +++ b/libsrc/atari/chline.s @@ -6,7 +6,7 @@ ; .export _chlinexy, _chline - .import popa, _gotoxy, cputdirect, setcursor + .import gotoxy, cputdirect, setcursor .importzp tmp1 .ifdef __ATARI5200__ @@ -17,8 +17,7 @@ CHRCODE = $12+64 _chlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length _chline: diff --git a/libsrc/atari/cputc.s b/libsrc/atari/cputc.s index cd2aefe79..a06daa691 100644 --- a/libsrc/atari/cputc.s +++ b/libsrc/atari/cputc.s @@ -7,7 +7,7 @@ .export _cputcxy, _cputc .export plot, cputdirect, putchar - .import popa, _gotoxy, mul40 + .import gotoxy, mul40 .importzp tmp4,ptr4 .import _revflag,setcursor @@ -15,8 +15,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C _cputc: diff --git a/libsrc/atari/cvline.s b/libsrc/atari/cvline.s index da6c8dca4..1b4ba0b1b 100644 --- a/libsrc/atari/cvline.s +++ b/libsrc/atari/cvline.s @@ -7,7 +7,7 @@ .include "atari.inc" .export _cvlinexy, _cvline - .import popa, _gotoxy, putchar, setcursor + .import gotoxy, putchar, setcursor .importzp tmp1 .ifdef __ATARI5200__ @@ -18,8 +18,7 @@ CHRCODE = $7C ; Vertical bar _cvlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cvline _cvline: diff --git a/libsrc/atari/gotoxy.s b/libsrc/atari/gotoxy.s index 1f00c3b23..aeaa732c0 100644 --- a/libsrc/atari/gotoxy.s +++ b/libsrc/atari/gotoxy.s @@ -6,14 +6,17 @@ .include "atari.inc" - .export _gotoxy + .export gotoxy, _gotoxy .import popa .import setcursor +gotoxy: + jsr popa ; Get Y + _gotoxy: ; Set the cursor position sta ROWCRS ; Set Y jsr popa ; Get X sta COLCRS ; Set X lda #0 - sta COLCRS+1 ; + sta COLCRS+1 jmp setcursor diff --git a/libsrc/atari5200/cputc.s b/libsrc/atari5200/cputc.s index 4bee0fba2..860eea88d 100644 --- a/libsrc/atari5200/cputc.s +++ b/libsrc/atari5200/cputc.s @@ -10,7 +10,7 @@ .export _cputcxy, _cputc .export plot, cputdirect, putchar - .import popa, _gotoxy, mul20 + .import gotoxy, mul20 .importzp ptr4 .import setcursor @@ -21,8 +21,7 @@ screen_setup = screen_setup_20x24 _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C _cputc: diff --git a/libsrc/atari5200/gotoxy.s b/libsrc/atari5200/gotoxy.s index a4b7c61d0..24e2c2e35 100644 --- a/libsrc/atari5200/gotoxy.s +++ b/libsrc/atari5200/gotoxy.s @@ -6,10 +6,13 @@ .include "atari5200.inc" - .export _gotoxy + .export gotoxy, _gotoxy .import popa .import setcursor +gotoxy: + jsr popa ; Get Y + _gotoxy: ; Set the cursor position sta ROWCRS_5200 ; Set Y jsr popa ; Get X diff --git a/libsrc/c128/cputc.s b/libsrc/c128/cputc.s index e906c242a..9d269a47e 100644 --- a/libsrc/c128/cputc.s +++ b/libsrc/c128/cputc.s @@ -8,7 +8,7 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot - .import popa, _gotoxy + .import gotoxy .import PLOT .include "c128.inc" @@ -21,8 +21,7 @@ newline = NEWLINE _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/c16/cputc.s b/libsrc/c16/cputc.s index a83a9c60b..49b3a84dd 100644 --- a/libsrc/c16/cputc.s +++ b/libsrc/c16/cputc.s @@ -7,7 +7,7 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot - .import popa, _gotoxy + .import gotoxy .import PLOT .include "plus4.inc" @@ -15,8 +15,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/c64/cputc.s b/libsrc/c64/cputc.s index 606d6f596..d6b49607a 100644 --- a/libsrc/c64/cputc.s +++ b/libsrc/c64/cputc.s @@ -7,7 +7,7 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot - .import popa, _gotoxy + .import gotoxy .import PLOT .include "c64.inc" @@ -15,8 +15,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index acbe5b560..f00f7792f 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -12,7 +12,7 @@ .export soft80_newline, soft80_plot .export soft80_checkchar - .import popa, _gotoxy + .import gotoxy .import soft80_kplot .import soft80_internal_bgcolor, soft80_internal_cellcolor @@ -25,8 +25,7 @@ soft80_cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/c64/soft80mono_cputc.s b/libsrc/c64/soft80mono_cputc.s index c89362cb5..252de0319 100644 --- a/libsrc/c64/soft80mono_cputc.s +++ b/libsrc/c64/soft80mono_cputc.s @@ -11,7 +11,7 @@ .export soft80mono_cputdirect, soft80mono_putchar .export soft80mono_newline, soft80mono_plot - .import popa, _gotoxy + .import gotoxy .import soft80mono_kplot .import soft80mono_internal_bgcolor, soft80mono_internal_cellcolor @@ -24,8 +24,7 @@ soft80mono_cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/cbm/cclear.s b/libsrc/cbm/cclear.s index 233c112c6..14b9d0e8b 100644 --- a/libsrc/cbm/cclear.s +++ b/libsrc/cbm/cclear.s @@ -6,13 +6,12 @@ ; .export _cclearxy, _cclear - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .importzp tmp1 _cclearxy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cclear _cclear: @@ -24,7 +23,3 @@ L1: lda #$20 ; Blank - screen code dec tmp1 bne L1 L9: rts - - - - diff --git a/libsrc/cbm/chline.s b/libsrc/cbm/chline.s index fe7e7255d..73782f344 100644 --- a/libsrc/cbm/chline.s +++ b/libsrc/cbm/chline.s @@ -6,13 +6,12 @@ ; .export _chlinexy, _chline - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .importzp tmp1, chlinechar _chlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length _chline: @@ -24,7 +23,3 @@ L1: lda #chlinechar ; Horizontal line, screen code dec tmp1 bne L1 L9: rts - - - - diff --git a/libsrc/cbm/cvline.s b/libsrc/cbm/cvline.s index 2cf231e98..b6d2d86e6 100644 --- a/libsrc/cbm/cvline.s +++ b/libsrc/cbm/cvline.s @@ -6,13 +6,12 @@ ; .export _cvlinexy, _cvline - .import popa, _gotoxy, putchar, newline + .import gotoxy, putchar, newline .importzp tmp1, cvlinechar _cvlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cvline _cvline: @@ -25,6 +24,3 @@ L1: lda #cvlinechar ; Vertical bar dec tmp1 bne L1 L9: rts - - - diff --git a/libsrc/cbm/gotoxy.s b/libsrc/cbm/gotoxy.s index 64c6bd21d..afc9c4d45 100644 --- a/libsrc/cbm/gotoxy.s +++ b/libsrc/cbm/gotoxy.s @@ -4,10 +4,13 @@ ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy + .export gotoxy, _gotoxy .import popa, plot .importzp CURS_X, CURS_Y +gotoxy: + jsr popa ; Get Y + _gotoxy: sta CURS_Y ; Set Y jsr popa ; Get X diff --git a/libsrc/cbm510/cputc.s b/libsrc/cbm510/cputc.s index bd8c364e8..73d45b422 100644 --- a/libsrc/cbm510/cputc.s +++ b/libsrc/cbm510/cputc.s @@ -8,7 +8,7 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot - .import popa, _gotoxy + .import gotoxy .import __VIDRAM_START__ .import CURS_X: zp, CURS_Y: zp, CHARCOLOR: zp, RVS: zp .import SCREEN_PTR: zp, CRAM_PTR: zp @@ -22,8 +22,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/cbm610/cputc.s b/libsrc/cbm610/cputc.s index 831ead6d6..5888580ac 100644 --- a/libsrc/cbm610/cputc.s +++ b/libsrc/cbm610/cputc.s @@ -9,8 +9,7 @@ .export newline, plot .destructor setsyscursor - .import _gotoxy - .import popa + .import gotoxy .import PLOT .import ktmp: zp, crtc: zp, CURS_X: zp, CURS_Y: zp, RVS: zp @@ -21,8 +20,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/conio/cputs.s b/libsrc/conio/cputs.s index 13cf84789..c9ca5df76 100644 --- a/libsrc/conio/cputs.s +++ b/libsrc/conio/cputs.s @@ -6,14 +6,13 @@ ; .export _cputsxy, _cputs - .import popa, _gotoxy, _cputc + .import gotoxy, _cputc .importzp ptr1, tmp1 _cputsxy: sta ptr1 ; Save s for later stx ptr1+1 - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, pop x + jsr gotoxy ; Set cursor, pop x and y jmp L0 ; Same as cputs... _cputs: sta ptr1 ; Save s diff --git a/libsrc/gamate/chline.s b/libsrc/gamate/chline.s index 2d96c9d2f..4d4ebe2dc 100644 --- a/libsrc/gamate/chline.s +++ b/libsrc/gamate/chline.s @@ -6,15 +6,14 @@ ; .export _chlinexy, _chline - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .importzp tmp1 .include "gamate.inc" _chlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length _chline: diff --git a/libsrc/gamate/cputc.s b/libsrc/gamate/cputc.s index c7b11c8c9..84742cb9d 100644 --- a/libsrc/gamate/cputc.s +++ b/libsrc/gamate/cputc.s @@ -5,7 +5,7 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot - .import popa, _gotoxy + .import gotoxy .import PLOT .import xsize .import fontdata @@ -19,8 +19,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/gamate/cvline.s b/libsrc/gamate/cvline.s index b22890815..89f49219a 100644 --- a/libsrc/gamate/cvline.s +++ b/libsrc/gamate/cvline.s @@ -6,15 +6,14 @@ ; .export _cvlinexy, _cvline - .import popa, _gotoxy, putchar, newline + .import gotoxy, putchar, newline .importzp tmp1 .include "gamate.inc" _cvlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cvline _cvline: diff --git a/libsrc/gamate/gotoxy.s b/libsrc/gamate/gotoxy.s index 407da1f2f..4a4871444 100644 --- a/libsrc/gamate/gotoxy.s +++ b/libsrc/gamate/gotoxy.s @@ -2,12 +2,15 @@ ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy + .export gotoxy, _gotoxy .import popa, plot .include "gamate.inc" .include "extzp.inc" +gotoxy: + jsr popa ; Get X + _gotoxy: sta CURS_Y ; Set Y jsr popa ; Get X diff --git a/libsrc/geos-common/conio/cclear.s b/libsrc/geos-common/conio/cclear.s index 9857f70e8..903b9fe92 100644 --- a/libsrc/geos-common/conio/cclear.s +++ b/libsrc/geos-common/conio/cclear.s @@ -7,7 +7,7 @@ ; void cclear (unsigned char length); .export _cclearxy, _cclear - .import popa, _gotoxy, fixcursor + .import gotoxy, fixcursor .importzp cursor_x, cursor_y, cursor_c .include "jumptab.inc" @@ -15,8 +15,7 @@ _cclearxy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length _cclear: diff --git a/libsrc/geos-common/conio/chline.s b/libsrc/geos-common/conio/chline.s index 328d01a01..1cf7a41f0 100644 --- a/libsrc/geos-common/conio/chline.s +++ b/libsrc/geos-common/conio/chline.s @@ -7,7 +7,7 @@ ; void chline (unsigned char length); .export _chlinexy, _chline - .import popa, _gotoxy, fixcursor + .import gotoxy, fixcursor .importzp cursor_x, cursor_y, cursor_c .include "jumptab.inc" @@ -15,8 +15,7 @@ _chlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length _chline: diff --git a/libsrc/geos-common/conio/cputc.s b/libsrc/geos-common/conio/cputc.s index 55674d583..014c2ed0b 100644 --- a/libsrc/geos-common/conio/cputc.s +++ b/libsrc/geos-common/conio/cputc.s @@ -23,8 +23,7 @@ ; UPLINE = ?, KEY_UPARROW = GOTOY, ... .export _cputcxy, _cputc - .import _gotoxy, fixcursor - .import popa + .import gotoxy, fixcursor .import xsize,ysize .importzp cursor_x, cursor_y, cursor_c, cursor_r @@ -34,8 +33,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/geos-common/conio/cvline.s b/libsrc/geos-common/conio/cvline.s index ade7f34c9..c12b8764b 100644 --- a/libsrc/geos-common/conio/cvline.s +++ b/libsrc/geos-common/conio/cvline.s @@ -7,7 +7,7 @@ ; void cvline (unsigned char length); .export _cvlinexy, _cvline - .import popa, _gotoxy, fixcursor + .import gotoxy, fixcursor .importzp cursor_x, cursor_y, cursor_r .include "jumptab.inc" @@ -15,8 +15,7 @@ _cvlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length _cvline: diff --git a/libsrc/geos-common/conio/gotoxy.s b/libsrc/geos-common/conio/gotoxy.s index 48b413d5f..0519a7d59 100644 --- a/libsrc/geos-common/conio/gotoxy.s +++ b/libsrc/geos-common/conio/gotoxy.s @@ -8,7 +8,7 @@ ; void gotoy (unsigned char y); ; void gotoxy (unsigned char x, unsigned char y); - .export _gotox, _gotoy, _gotoxy, fixcursor + .export _gotox, _gotoy, gotoxy, _gotoxy, fixcursor .import popa .importzp cursor_x, cursor_y, cursor_c, cursor_r @@ -22,6 +22,9 @@ _gotoy: sta cursor_r jmp fixcursor +gotoxy: + jsr popa + _gotoxy: sta cursor_r jsr popa diff --git a/libsrc/nes/cclear.s b/libsrc/nes/cclear.s index 233c112c6..7a2413826 100644 --- a/libsrc/nes/cclear.s +++ b/libsrc/nes/cclear.s @@ -6,13 +6,12 @@ ; .export _cclearxy, _cclear - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .importzp tmp1 _cclearxy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cclear _cclear: diff --git a/libsrc/nes/chline.s b/libsrc/nes/chline.s index 5f6e67c8f..d68a77df9 100644 --- a/libsrc/nes/chline.s +++ b/libsrc/nes/chline.s @@ -6,15 +6,14 @@ ; .export _chlinexy, _chline - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .importzp tmp1 .include "nes.inc" _chlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length _chline: diff --git a/libsrc/nes/cputc.s b/libsrc/nes/cputc.s index 5bcdc7994..209d22db2 100644 --- a/libsrc/nes/cputc.s +++ b/libsrc/nes/cputc.s @@ -9,7 +9,7 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline .constructor initconio - .import popa, _gotoxy + .import gotoxy .import ppuinit, paletteinit, ppubuf_put .import setcursor @@ -23,8 +23,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/nes/cvline.s b/libsrc/nes/cvline.s index 3ab93f34a..d564a25cb 100644 --- a/libsrc/nes/cvline.s +++ b/libsrc/nes/cvline.s @@ -6,15 +6,14 @@ ; .export _cvlinexy, _cvline - .import popa, _gotoxy, putchar, newline + .import gotoxy, putchar, newline .importzp tmp1 .include "nes.inc" _cvlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cvline _cvline: diff --git a/libsrc/nes/gotoxy.s b/libsrc/nes/gotoxy.s index a670962fc..3460aad19 100644 --- a/libsrc/nes/gotoxy.s +++ b/libsrc/nes/gotoxy.s @@ -4,21 +4,19 @@ ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy + .export gotoxy, _gotoxy .import setcursor .import popa .include "nes.inc" -.proc _gotoxy +gotoxy: + jsr popa ; Get Y +_gotoxy: sta CURS_Y ; Set Y jsr popa ; Get X sta CURS_X ; Set X tay ldx CURS_Y jmp setcursor ; Set the cursor position - -.endproc - - diff --git a/libsrc/osic1p/cclear.s b/libsrc/osic1p/cclear.s index 2036c38e0..f7e9b2984 100644 --- a/libsrc/osic1p/cclear.s +++ b/libsrc/osic1p/cclear.s @@ -9,13 +9,12 @@ ; .export _cclearxy, _cclear - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .importzp tmp1 _cclearxy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cclear _cclear: diff --git a/libsrc/osic1p/chline.s b/libsrc/osic1p/chline.s index be40d40af..ae2df5014 100644 --- a/libsrc/osic1p/chline.s +++ b/libsrc/osic1p/chline.s @@ -9,13 +9,12 @@ ; .export _chlinexy, _chline - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .importzp tmp1 _chlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length _chline: diff --git a/libsrc/osic1p/cvline.s b/libsrc/osic1p/cvline.s index 84e5a45bf..7a393bdc8 100644 --- a/libsrc/osic1p/cvline.s +++ b/libsrc/osic1p/cvline.s @@ -8,13 +8,12 @@ ; .export _cvlinexy, _cvline - .import popa, _gotoxy, putchar, newline + .import gotoxy, putchar, newline .importzp tmp1 _cvlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cvline _cvline: diff --git a/libsrc/osic1p/gotoxy.s b/libsrc/osic1p/gotoxy.s index f76537349..b9666a722 100644 --- a/libsrc/osic1p/gotoxy.s +++ b/libsrc/osic1p/gotoxy.s @@ -6,10 +6,13 @@ ; ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy + .export gotoxy, _gotoxy .import popa, plot .include "extzp.inc" +gotoxy: + jsr popa ; Get Y + _gotoxy: sta CURS_Y ; Set Y jsr popa ; Get X diff --git a/libsrc/osic1p/osiscreen.inc b/libsrc/osic1p/osiscreen.inc index 66c5e9fb0..fc8324781 100644 --- a/libsrc/osic1p/osiscreen.inc +++ b/libsrc/osic1p/osiscreen.inc @@ -73,8 +73,7 @@ ScrollLength = (ScrHeight - 1) * ScrollDist _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function @@ -157,7 +156,7 @@ putchar: .macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \ ScrWidth, ScrHeight, ScrollDist - .import popa, _gotoxy + .import gotoxy .import _memmove, _memset, pushax .importzp ptr1 diff --git a/libsrc/pce/chline.s b/libsrc/pce/chline.s index 8bf8f1626..3c6589375 100644 --- a/libsrc/pce/chline.s +++ b/libsrc/pce/chline.s @@ -6,15 +6,14 @@ ; .export _chlinexy, _chline - .import popa, _gotoxy, cputdirect + .import gotoxy, cputdirect .importzp tmp1 .include "pce.inc" _chlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length _chline: diff --git a/libsrc/pce/cputc.s b/libsrc/pce/cputc.s index 8d1cec8eb..cfe6a1a27 100644 --- a/libsrc/pce/cputc.s +++ b/libsrc/pce/cputc.s @@ -5,7 +5,7 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot - .import popa, _gotoxy + .import gotoxy .import PLOT .import xsize @@ -16,8 +16,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/pce/cvline.s b/libsrc/pce/cvline.s index abd74a5c7..279c691a9 100644 --- a/libsrc/pce/cvline.s +++ b/libsrc/pce/cvline.s @@ -6,15 +6,14 @@ ; .export _cvlinexy, _cvline - .import popa, _gotoxy, putchar, newline + .import gotoxy, putchar, newline .importzp tmp1 .include "pce.inc" _cvlinexy: pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params + jsr gotoxy ; Call this one, will pop params pla ; Restore the length and run into _cvline _cvline: diff --git a/libsrc/pce/gotoxy.s b/libsrc/pce/gotoxy.s index fb61646d1..dae9e6e43 100644 --- a/libsrc/pce/gotoxy.s +++ b/libsrc/pce/gotoxy.s @@ -2,12 +2,15 @@ ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy + .export gotoxy, _gotoxy .import popa, plot .include "pce.inc" .include "extzp.inc" +gotoxy: + jsr popa ; Get Y + _gotoxy: sta CURS_Y ; Set Y jsr popa ; Get X diff --git a/libsrc/pet/cputc.s b/libsrc/pet/cputc.s index f38d2759a..9b2c22323 100644 --- a/libsrc/pet/cputc.s +++ b/libsrc/pet/cputc.s @@ -7,14 +7,13 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot - .import popa, _gotoxy + .import gotoxy .include "pet.inc" _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/plus4/cputc.s b/libsrc/plus4/cputc.s index a83a9c60b..49b3a84dd 100644 --- a/libsrc/plus4/cputc.s +++ b/libsrc/plus4/cputc.s @@ -7,7 +7,7 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot - .import popa, _gotoxy + .import gotoxy .import PLOT .include "plus4.inc" @@ -15,8 +15,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function diff --git a/libsrc/vic20/cputc.s b/libsrc/vic20/cputc.s index 7a1014c1c..43aacdae3 100644 --- a/libsrc/vic20/cputc.s +++ b/libsrc/vic20/cputc.s @@ -7,7 +7,7 @@ .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot - .import popa, _gotoxy + .import gotoxy .import PLOT .include "vic20.inc" @@ -15,8 +15,7 @@ _cputcxy: pha ; Save C - jsr popa ; Get Y - jsr _gotoxy ; Set cursor, drop x + jsr gotoxy ; Set cursor, drop x and y pla ; Restore C ; Plot a character - also used as internal function From 27841c7b40269cc3dbbe37f198f1177c97c2a78b Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 6 Jun 2016 22:45:20 +0200 Subject: [PATCH 091/407] Some Atari runtime library fixes. * libsrc/atari/ucase_fn.s: Fix handling if input parameter 'tmp2' is 0. * libsrc/atari/open.s: Set 'tmp2' parameter for 'ucase_fn' if DEFAULT_DEVICE is not defined. --- libsrc/atari/open.s | 4 +++- libsrc/atari/ucase_fn.s | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/libsrc/atari/open.s b/libsrc/atari/open.s index 2188257cb..d5ff4ca52 100644 --- a/libsrc/atari/open.s +++ b/libsrc/atari/open.s @@ -93,8 +93,10 @@ cont: ldy #3 .ifdef UCASE_FILENAME .ifdef DEFAULT_DEVICE ldy #$80 - sty tmp2 ; set flag for ucase_fn +.else + ldy #$00 .endif + sty tmp2 ; set flag for ucase_fn jsr ucase_fn bcc ucok1 invret: lda #<EINVAL ; file name is too long diff --git a/libsrc/atari/ucase_fn.s b/libsrc/atari/ucase_fn.s index e53750e29..f7f03915d 100644 --- a/libsrc/atari/ucase_fn.s +++ b/libsrc/atari/ucase_fn.s @@ -40,7 +40,9 @@ stx ptr4+1 .ifdef DEFAULT_DEVICE - ; bit #0 of tmp2 is used as a flag whether device name is present in passed string (1 = present, 0 = not present) + lda tmp2 + beq hasdev ; don't fiddle with device part + ; bit #0 of tmp2 is used as an additional flag whether device name is present in passed string (1 = present, 0 = not present) ldy #1 inc tmp2 ; initialize flag: device present lda #':' @@ -81,11 +83,11 @@ copy_end: .ifdef DEFAULT_DEVICE lda #1 - bit tmp2 + bit tmp2 ; is a device present in the string? bne hasdev2 ; yes, don't prepend something - bpl hasdev2 + bpl hasdev2 ; check input parameter (tmp2 != $80) - ldy #128+3 ; no, prepend "D:" (or other device) + ldy #128+3 ; no, prepend "Dn:" (__defdev) sty tmp3 ; adjust stack size used ldy #3 jsr subysp ; adjust stack pointer From c7874b9f60cebee3f6ce237cebf2aa8ecfad0f36 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 7 Jun 2016 00:42:51 +0200 Subject: [PATCH 092/407] Add Atari version of of doesclrscrafterexit(). - Update documentation. - Update atari.h and apple2.h header files. - Adapt Atari test/target programs. - Fix a typo in "div" entry in funcref.sgml. --- doc/funcref.sgml | 58 ++++++++++++++++++++------------- include/apple2.h | 3 ++ include/atari.h | 13 ++++---- libsrc/atari/doesclrscr.s | 19 +++++++++++ libsrc/atari/is_cmdline_dos.s | 11 ++----- libsrc/atari/targetutil/w2cas.c | 2 +- testcode/lib/atari/defdev.c | 2 +- testcode/lib/atari/mem.c | 2 +- 8 files changed, 71 insertions(+), 39 deletions(-) create mode 100644 libsrc/atari/doesclrscr.s diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 9bd4a3595..5b529b822 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -949,27 +949,7 @@ id="malloc" name="malloc"> may still return <tt/NULL/. <tag/Declaration/<tt/unsigned char _is_cmdline_dos (void);/ <tag/Description/The function returns 0 if the DOS doesn't support command line arguments. It returns 1 if it does. -<tag/Notes/<itemize> -<item>Many Atari DOSes which don't support command line arguments immediately clear the screen -and display their menu after a program exits. Therefore it might be difficult to read -the last messages printed by the program prior to its exit. This function can be used -to decide if a delay or wait for a key press should be executed when then program -exits. -</itemize> <tag/Availability/cc65 (<tt/atari/ and <tt/atarixl/ platforms) -<tag/Example/<verb> -/* Hello World for Atari */ -#include <stdio.h> -#include <unistd.h> -#include <atari.h> -int main(void) -{ - printf("Hello World\n"); - if (! _is_cmdline_dos()) - sleep(5); - return 0; -} -</verb> </descrip> </quote> @@ -2572,8 +2552,8 @@ used in presence of a prototype. <descrip> <tag/Function/Divide two ints and return quotient and remainder. <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/ -<tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/ -<tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the +<tag/Declaration/<tt/div_t __fastcall__ div (int number, int denom);/ +<tag/Description/<tt/div/ divides <tt/number/ by <tt/denom/ and returns the quotient and remainder in a <tt/div_t/ structure. <tag/Notes/<itemize> <item>The function is only available as fastcall function, so it may only @@ -2587,6 +2567,40 @@ ldiv </quote> +<sect1>doesclrscrafterexit<label id="doesclrscrafterexit"><p> + +<quote> +<descrip> +<tag/Function/Determines whether the screen is going to be cleared after program exit. +<tag/Header/<tt/<ref id="atari.h" name="atari.h">, <ref id="apple2.h" name="apple2.h">/ +<tag/Declaration/<tt/unsigned char doesclrscrafterexit (void);/ +<tag/Description/The function returns 0 if the screen won't be cleared immediately after +program termination. It returns 1 if it will. +<tag/Notes/<itemize> +<item>Some systems, maybe depending on configuration, immediately clear the screen +after a program exits. Therefore it might be difficult to read +the last messages printed by the program prior to its exit. This function can be used +to decide if a delay or wait for a key press should be executed when then program +exits. +</itemize> +<tag/Availability/cc65 (<tt/atari/, <tt/atarixl/, <tt/apple2/, and <tt/apple2enh/ platforms) +<tag/Example/<verb> +/* Hello World */ +#include <stdio.h> +#include <unistd.h> +#include <atari.h> +int main(void) +{ + printf("Hello World\n"); + if (doesclrscrafterexit()) + sleep(5); + return 0; +} +</verb> +</descrip> +</quote> + + <sect1>em_commit<label id="em_commit"><p> <quote> diff --git a/include/apple2.h b/include/apple2.h index a1b094d4d..97a2f124f 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -177,6 +177,9 @@ unsigned char get_ostype (void); void rebootafterexit (void); /* Reboot machine after program termination has completed. */ +unsigned char doesclrscrafterexit (void); +/* Will the screen automatically be cleared after program termination. */ + #define ser_apple2_slot(num) ser_ioctl (0, (void*) (num)) /* Select a slot number from 1 to 7 prior to ser_open. ** The default slot number is 2. diff --git a/include/atari.h b/include/atari.h index fa99fca20..76684c624 100644 --- a/include/atari.h +++ b/include/atari.h @@ -161,12 +161,13 @@ extern void __fastcall__ _scroll (signed char numlines); /* numlines < 0 scrolls down */ /* misc. functions */ -extern unsigned char get_ostype(void); /* get ROM version */ -extern unsigned char get_tv(void); /* get TV system */ -extern void _save_vecs(void); /* save system vectors */ -extern void _rest_vecs(void); /* restore system vectors */ -extern char *_getdefdev(void); /* get default floppy device */ -extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */ +extern unsigned char get_ostype(void); /* get ROM version */ +extern unsigned char get_tv(void); /* get TV system */ +extern void _save_vecs(void); /* save system vectors */ +extern void _rest_vecs(void); /* restore system vectors */ +extern char *_getdefdev(void); /* get default floppy device */ +extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */ +extern unsigned char doesclrscrafterexit (void); /* will DOS clear the screen after program termination */ /* global variables */ extern unsigned char _dos_type; /* the DOS flavour */ diff --git a/libsrc/atari/doesclrscr.s b/libsrc/atari/doesclrscr.s new file mode 100644 index 000000000..c085faebf --- /dev/null +++ b/libsrc/atari/doesclrscr.s @@ -0,0 +1,19 @@ +; +; Christian Groessler, June-2016 +; +; unsigned char doesclrscr(void); +; +; returns 0/1 if after program termination the screen isn't/is cleared +; + + .export _doesclrscrafterexit + .import __dos_type + .include "atari.inc" + +_doesclrscrafterexit: + ldx #0 + lda __dos_type + cmp #MAX_DOS_WITH_CMDLINE + 1 + txa + rol a + rts diff --git a/libsrc/atari/is_cmdline_dos.s b/libsrc/atari/is_cmdline_dos.s index 71b35fbad..b85cb3ca7 100644 --- a/libsrc/atari/is_cmdline_dos.s +++ b/libsrc/atari/is_cmdline_dos.s @@ -7,14 +7,9 @@ ; .export __is_cmdline_dos - .import __dos_type - .include "atari.inc" + .import _doesclrscrafterexit __is_cmdline_dos: - ldx #0 - lda __dos_type - cmp #MAX_DOS_WITH_CMDLINE + 1 - txa - rol a - eor #$01 + jsr _doesclrscrafterexit ; currently (unless a DOS behaving differently is popping up) + eor #$01 ; we can get by with the inverse of _doesclrscrafterexit rts diff --git a/libsrc/atari/targetutil/w2cas.c b/libsrc/atari/targetutil/w2cas.c index c95ff7ba5..c1dd0cfcc 100644 --- a/libsrc/atari/targetutil/w2cas.c +++ b/libsrc/atari/targetutil/w2cas.c @@ -35,7 +35,7 @@ static struct __iocb *findfreeiocb(void) static void exitfn(void) { /* if DOS will automatically clear the screen, after the program exits, wait for a keypress... */ - if (! _is_cmdline_dos()) + if (doesclrscrafterexit()) cgetc(); } diff --git a/testcode/lib/atari/defdev.c b/testcode/lib/atari/defdev.c index 06ddb6365..851d87106 100644 --- a/testcode/lib/atari/defdev.c +++ b/testcode/lib/atari/defdev.c @@ -13,6 +13,6 @@ extern char _defdev[]; int main(void) { printf("default device: %s\n", _defdev); - if (! _is_cmdline_dos()) cgetc(); + if (doesclrscrafterexit()) cgetc(); return 0; } diff --git a/testcode/lib/atari/mem.c b/testcode/lib/atari/mem.c index a8d50cf30..04978c77e 100644 --- a/testcode/lib/atari/mem.c +++ b/testcode/lib/atari/mem.c @@ -41,6 +41,6 @@ int main(void) printf(" sp: $%04X (stack ptr)\n", getsp()); if (allocmem) free(allocmem); - if (! _is_cmdline_dos()) cgetc(); + if (doesclrscrafterexit()) cgetc(); return(0); } From 346d88a6a77fd0fa7bd5972991e101640d97f040 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 7 Jun 2016 12:05:28 +0200 Subject: [PATCH 093/407] Add issues from pull request #307. --- doc/funcref.sgml | 12 ++++++------ include/apple2.h | 3 --- include/atari.h | 1 - include/cc65.h | 5 +++++ libsrc/atari/targetutil/w2cas.c | 12 ++++-------- libsrc/common/doesclrscr.s | 14 ++++++++++++++ testcode/lib/atari/defdev.c | 1 + testcode/lib/atari/mem.c | 1 + 8 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 libsrc/common/doesclrscr.s diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 5b529b822..ff32a2960 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -2552,8 +2552,8 @@ used in presence of a prototype. <descrip> <tag/Function/Divide two ints and return quotient and remainder. <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/ -<tag/Declaration/<tt/div_t __fastcall__ div (int number, int denom);/ -<tag/Description/<tt/div/ divides <tt/number/ by <tt/denom/ and returns the +<tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/ +<tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the quotient and remainder in a <tt/div_t/ structure. <tag/Notes/<itemize> <item>The function is only available as fastcall function, so it may only @@ -2574,8 +2574,8 @@ ldiv <tag/Function/Determines whether the screen is going to be cleared after program exit. <tag/Header/<tt/<ref id="atari.h" name="atari.h">, <ref id="apple2.h" name="apple2.h">/ <tag/Declaration/<tt/unsigned char doesclrscrafterexit (void);/ -<tag/Description/The function returns 0 if the screen won't be cleared immediately after -program termination. It returns 1 if it will. +<tag/Description/The function returns zero if the screen won't be cleared immediately after +program termination. It returns a non-zero value if it will. <tag/Notes/<itemize> <item>Some systems, maybe depending on configuration, immediately clear the screen after a program exits. Therefore it might be difficult to read @@ -2583,12 +2583,12 @@ the last messages printed by the program prior to its exit. This function can be to decide if a delay or wait for a key press should be executed when then program exits. </itemize> -<tag/Availability/cc65 (<tt/atari/, <tt/atarixl/, <tt/apple2/, and <tt/apple2enh/ platforms) +<tag/Availability/cc65 <tag/Example/<verb> /* Hello World */ #include <stdio.h> #include <unistd.h> -#include <atari.h> +#include <cc65.h> int main(void) { printf("Hello World\n"); diff --git a/include/apple2.h b/include/apple2.h index 97a2f124f..a1b094d4d 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -177,9 +177,6 @@ unsigned char get_ostype (void); void rebootafterexit (void); /* Reboot machine after program termination has completed. */ -unsigned char doesclrscrafterexit (void); -/* Will the screen automatically be cleared after program termination. */ - #define ser_apple2_slot(num) ser_ioctl (0, (void*) (num)) /* Select a slot number from 1 to 7 prior to ser_open. ** The default slot number is 2. diff --git a/include/atari.h b/include/atari.h index 76684c624..eedd814e0 100644 --- a/include/atari.h +++ b/include/atari.h @@ -167,7 +167,6 @@ extern void _save_vecs(void); /* save system vectors */ extern void _rest_vecs(void); /* restore system vectors */ extern char *_getdefdev(void); /* get default floppy device */ extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */ -extern unsigned char doesclrscrafterexit (void); /* will DOS clear the screen after program termination */ /* global variables */ extern unsigned char _dos_type; /* the DOS flavour */ diff --git a/include/cc65.h b/include/cc65.h index 4f9f3067f..9b7b69a0e 100644 --- a/include/cc65.h +++ b/include/cc65.h @@ -85,6 +85,11 @@ int __fastcall__ cc65_cos (unsigned x); ** is in 8.8 fixed point format, which means that 1.0 = $100 and -1.0 = $FF00. */ +unsigned char doesclrscrafterexit (void); +/* Indicates whether the screen automatically be cleared after program +** termination. +*/ + /* End of cc65.h */ diff --git a/libsrc/atari/targetutil/w2cas.c b/libsrc/atari/targetutil/w2cas.c index c1dd0cfcc..1381a49a0 100644 --- a/libsrc/atari/targetutil/w2cas.c +++ b/libsrc/atari/targetutil/w2cas.c @@ -14,6 +14,7 @@ #include <errno.h> #include <6502.h> #include <atari.h> +#include <cc65.h> #include <conio.h> static int verbose = 1; @@ -32,13 +33,6 @@ static struct __iocb *findfreeiocb(void) return NULL; } -static void exitfn(void) -{ - /* if DOS will automatically clear the screen, after the program exits, wait for a keypress... */ - if (doesclrscrafterexit()) - cgetc(); -} - int main(int argc, char **argv) { char *filename, *x; @@ -50,7 +44,9 @@ int main(int argc, char **argv) struct __iocb *iocb = findfreeiocb(); int iocb_num; - atexit(exitfn); + /* if DOS will automatically clear the screen after the program exits, wait for a keypress... */ + if (doesclrscrafterexit()) + atexit((void (*)(void))cgetc); if (! iocb) { fprintf(stderr, "couldn't find a free iocb\n"); diff --git a/libsrc/common/doesclrscr.s b/libsrc/common/doesclrscr.s new file mode 100644 index 000000000..71f7ab70e --- /dev/null +++ b/libsrc/common/doesclrscr.s @@ -0,0 +1,14 @@ +; +; Christian Groessler, June-2016 +; +; unsigned char doesclrscr(void); +; +; returns 0/1 if after program termination the screen isn't/is cleared +; + + .export _doesclrscrafterexit + +_doesclrscrafterexit: + ldx #$00 + txa + rts diff --git a/testcode/lib/atari/defdev.c b/testcode/lib/atari/defdev.c index 851d87106..9b14e97fc 100644 --- a/testcode/lib/atari/defdev.c +++ b/testcode/lib/atari/defdev.c @@ -7,6 +7,7 @@ #include <stdio.h> #include <conio.h> #include <atari.h> +#include <cc65.h> extern char _defdev[]; diff --git a/testcode/lib/atari/mem.c b/testcode/lib/atari/mem.c index 04978c77e..bc70aded6 100644 --- a/testcode/lib/atari/mem.c +++ b/testcode/lib/atari/mem.c @@ -8,6 +8,7 @@ #include <stdlib.h> #include <conio.h> #include <atari.h> +#include <cc65.h> extern int getsp(void); /* comes from ../getsp.s */ From 308767cbae129214654c5f6c3294f0b2a0c8af38 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 7 Jun 2016 12:22:25 +0200 Subject: [PATCH 094/407] fix wrong header reference in doesclrscrafterexit() description --- doc/funcref.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index ff32a2960..d665ce0b9 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -2572,7 +2572,7 @@ ldiv <quote> <descrip> <tag/Function/Determines whether the screen is going to be cleared after program exit. -<tag/Header/<tt/<ref id="atari.h" name="atari.h">, <ref id="apple2.h" name="apple2.h">/ +<tag/Header/<tt/<ref id="cc65.h" name="cc65.h">/ <tag/Declaration/<tt/unsigned char doesclrscrafterexit (void);/ <tag/Description/The function returns zero if the screen won't be cleared immediately after program termination. It returns a non-zero value if it will. From 5705d0b55b433f4147b4efaeada23debb1a51e4d Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 7 Jun 2016 15:05:00 +0200 Subject: [PATCH 095/407] Use 'return0' for default 'doesclrscrafterexit()' implementation in libsrc/common. Fix include/atari.h formatting. --- include/atari.h | 12 ++++++------ libsrc/common/doesclrscr.s | 8 +++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/atari.h b/include/atari.h index eedd814e0..fa99fca20 100644 --- a/include/atari.h +++ b/include/atari.h @@ -161,12 +161,12 @@ extern void __fastcall__ _scroll (signed char numlines); /* numlines < 0 scrolls down */ /* misc. functions */ -extern unsigned char get_ostype(void); /* get ROM version */ -extern unsigned char get_tv(void); /* get TV system */ -extern void _save_vecs(void); /* save system vectors */ -extern void _rest_vecs(void); /* restore system vectors */ -extern char *_getdefdev(void); /* get default floppy device */ -extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */ +extern unsigned char get_ostype(void); /* get ROM version */ +extern unsigned char get_tv(void); /* get TV system */ +extern void _save_vecs(void); /* save system vectors */ +extern void _rest_vecs(void); /* restore system vectors */ +extern char *_getdefdev(void); /* get default floppy device */ +extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */ /* global variables */ extern unsigned char _dos_type; /* the DOS flavour */ diff --git a/libsrc/common/doesclrscr.s b/libsrc/common/doesclrscr.s index 71f7ab70e..49ce2fd12 100644 --- a/libsrc/common/doesclrscr.s +++ b/libsrc/common/doesclrscr.s @@ -6,9 +6,7 @@ ; returns 0/1 if after program termination the screen isn't/is cleared ; - .export _doesclrscrafterexit + .export _doesclrscrafterexit + .import return0 -_doesclrscrafterexit: - ldx #$00 - txa - rts +_doesclrscrafterexit = return0 From 083598599956b7f26ea1555ee443cf83f1c7585a Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 8 Jun 2016 21:05:00 -0400 Subject: [PATCH 096/407] Updated the function reference document. * Added doesclrscrafterexit() to cc65.h's list. * Added header-file function lists for some new target platforms. --- doc/funcref.sgml | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index d665ce0b9..64e519238 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -3,7 +3,7 @@ <article> <title>cc65 function reference <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>2015-07-21 +<date>2016-06-08 <abstract> cc65 is a C compiler for 6502 based systems. This function reference describes @@ -207,7 +207,7 @@ function. <sect1><tt/cc65.h/<label id="cc65.h"><p> -<!-- <itemize> --> +<itemize> <!-- <item><ref id="cc65_cos" name="cc65_cos"> --> <!-- <item><ref id="cc65_idiv32by16r16" name="cc65_idiv32by16r16"> --> <!-- <item><ref id="cc65_imul16x16r32" name="cc65_imul16x16r32"> --> @@ -217,7 +217,8 @@ function. <!-- <item><ref id="cc65_umul16x16r32" name="cc65_umul16x16r32"> --> <!-- <item><ref id="cc65_umul16x8r32" name="cc65_umul16x8r32"> --> <!-- <item><ref id="cc65_umul8x8r16" name="cc65_umul8x8r16"> --> -<!-- </itemize> --> +<item><ref id="doesclrscrafterexit" name="doesclrscrafterexit"> +</itemize> (incomplete) @@ -344,6 +345,16 @@ function. </itemize> +<sect1><tt/gamate.h/<label id="gamate.h"><p> + +<!-- <itemize> --> +<!-- <item><ref id="get_tv" name="get_tv"> --> +<!-- <item><ref id="waitvblank" name="waitvblank"> --> +<!-- </itemize> --> + +(incomplete) + + <sect1><tt/geos.h/<label id="geos.h"><p> (incomplete) @@ -430,6 +441,16 @@ url="http://www.6502.org/users/andre/o65/fileformat.html" name="the o65 format"> It does not declare any functions. +<sect1><tt/pce.h/<label id="pce.h"><p> + +<!-- <itemize> --> +<!-- <item><ref id="get_tv" name="get_tv"> --> +<!-- <item><ref id="waitvblank" name="waitvblank"> --> +<!-- </itemize> --> + +(incomplete) + + <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p> <itemize> @@ -440,6 +461,16 @@ It does not declare any functions. </itemize> +<sect1><tt/pen.h/<label id="pen.h"><p> + +<!-- <itemize> --> +<!-- <item><ref id="pen_adjust" name="pen_adjust"> --> +<!-- <item><ref id="pen_calibrate" name="pen_calibrate"> --> +<!-- </itemize> --> + +(incomplete) + + <sect1><tt/pet.h/<label id="pet.h"><p> (incomplete) From 573381a340decd6a533e9f9aefaff908772b123c Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sat, 11 Jun 2016 06:43:19 -0400 Subject: [PATCH 097/407] Allowed character code zero to be remapped with other character codes. --- doc/ca65.sgml | 11 ++++--- doc/cc65.sgml | 68 ++++++++++++++++++++++++------------------- src/ca65/pseudo.c | 8 ++--- src/cc65/error.c | 8 +++-- src/cc65/error.h | 3 +- src/cc65/pragma.c | 22 +++++++------- src/cc65/pragma.h | 8 ++--- src/common/tgttrans.c | 2 +- 8 files changed, 71 insertions(+), 59 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 6ea17d335..050e75628 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4,7 +4,7 @@ <title>ca65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:greg.king5@verizon.net" name="Greg King"> -<date>2015-11-17 +<date>2016-06-11 <abstract> ca65 is a powerful macro assembler for the 6502, 65C02, and 65816 CPUs. It is @@ -2170,16 +2170,15 @@ Here's a list of all control commands and a description, what they do: <sect1><tt>.CHARMAP</tt><label id=".CHARMAP"><p> Apply a custom mapping for characters. The command is followed by two - numbers. The first one is the index of the source character (range 1..255), + numbers. The first one is the index of the source character (range 0..255); the second one is the mapping (range 0..255). The mapping applies to all - character and string constants when they generate output, and overrides a - mapping table specified with the <tt><ref id="option-t" name="-t"></tt> + character and string constants <em/when/ they generate output; and, overrides + a mapping table specified with the <tt><ref id="option-t" name="-t"></tt> command line switch. Example: - <tscreen><verb> - .charmap $41, $61 ; Map 'A' to 'a' + .charmap $41, $61 ; Map 'A' to 'a' </verb></tscreen> diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 8346bac6b..3e59d4cf0 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -4,7 +4,7 @@ <title>cc65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:gregdk@users.sf.net" name="Greg King"> -<date>2016-04-22 +<date>2016-06-11 <abstract> cc65 is a C compiler for 6502 targets. It supports several 6502 based home @@ -478,15 +478,15 @@ Here is a description of all the command line options: <label id="option-W"> - <tag><tt>-W name[,name]</tt></tag> + <tag><tt>-W name[,name,...]</tt></tag> This option allows to control warnings generated by the compiler. It is - followed by a comma separated list of warnings that should be enabled or + followed by a comma-separated list of warnings that should be enabled or disabled. To disable a warning, its name is prefixed by a minus sign. If no such prefix exists, or the name is prefixed by a plus sign, the warning is enabled. - The following warning names are currently recognized: + The following warning names currently are recognized: <descrip> <tag><tt/const-comparison/</tag> Warn if the result of a comparison is constant. @@ -494,10 +494,13 @@ Here is a description of all the command line options: Treat all warnings as errors. <tag><tt/no-effect/</tag> Warn about statements that don't have an effect. + <tag><tt/remap-zero/</tag> + Warn about a <tt/<ref id="pragma-charmap" name="#pragma charmap()">/ + that changes a character's code number from/to 0x00. <tag><tt/struct-param/</tag> Warn when passing structs by value. <tag><tt/unknown-pragma/</tag> - Warn about known #pragmas. + Warn about #pragmas that aren't recognized by cc65. <tag><tt/unused-label/</tag> Warn about unused labels. <tag><tt/unused-param/</tag> @@ -506,11 +509,11 @@ Here is a description of all the command line options: Warn about unused variables. </descrip> - The full list of available warning names may be retrieved by using the + The full list of available warning names can be retrieved by using the option <tt><ref id="option-list-warnings" name="--list-warnings"></tt>. - You may also use <tt><ref id="pragma-warn" name="#pragma warn"></tt> to - control this setting for smaller pieces of code from within your code. + You may use also <tt><ref id="pragma-warn" name="#pragma warn"></tt> to + control this setting, for smaller pieces of code, from within your sources. </descrip><p> @@ -931,34 +934,38 @@ parameter with the <tt/#pragma/. <sect1><tt>#pragma charmap (<index>, <code>)</tt><label id="pragma-charmap"><p> Each literal string and each literal character in the source is translated - by use of a translation table. This translation table is preset when the - compiler is started depending on the target system, for example to map - ISO-8859-1 characters into PETSCII if the target is a commodore machine. + by use of a translation table. That translation table is preset when the + compiler is started, depending on the target system; for example, to map + ISO-8859-1 characters into PETSCII if the target is a Commodore machine. This pragma allows to change entries in the translation table, so the translation for individual characters, or even the complete table may be - adjusted. + adjusted. Both arguments are assumed to be unsigned characters with a valid + range of 0-255. - Both arguments are assumed to be unsigned characters with a valid range of - 1-255. - - Beware of two pitfalls: - - <itemize> - <item>The character index is actually the code of the character in the - C source, so character mappings do always depend on the source - character set. This means that <tt/#pragma charmap/ is not - portable -- it depends on the build environment. - <item>While it is possible to use character literals as indices, the - result may be somewhat unexpected, since character literals are - itself translated. For this reason I would suggest to avoid - character literals and use numeric character codes instead. - </itemize> + Beware of some pitfalls: + <itemize> + <item>The character index is actually the code of the character in the + C source; so, character mappings do always depend on the source + character set. That means that <tt/#pragma charmap()/ is not + portable -- it depends on the build environment. + <item>While it is possible to use character literals as indices, the + result may be somewhat unexpected, since character literals are + themselves translated. For that reason, I would suggest to avoid + character literals, and use numeric character codes instead. + <item>It is risky to change index <tt/0x00/, because string functions depend + on it. If it is changed, then the <tt/'\0'/ at the end of string + literals will become non-zero. Functions that are used on those + literals won't stop at the end of them. cc65 will warn you if you do + change that code number. You can turn off that <tt/remap-zero/ warning + if you are certain that you know what you are doing (see <tt/<ref + id="pragma-warn" name="#pragma warn()">/). + </itemize> Example: <tscreen><verb> - /* Use a space wherever an 'a' occurs in ISO-8859-1 source */ - #pragma charmap (0x61, 0x20); + /* Use a space wherever an 'a' occurs in ISO-8859-1 source */ + #pragma charmap (0x61, 0x20); </verb></tscreen> @@ -1129,7 +1136,7 @@ parameter with the <tt/#pragma/. Switch compiler warnings on or off. "name" is the name of a warning (see the <tt/<ref name="-W" id="option-W">/ compiler option for a list). The name is - either followed by "pop", which restores the last pushed state, or by "on" or + followed either by "pop", which restores the last pushed state, or by "on" or "off", optionally preceeded by "push" to push the current state before changing it. @@ -1144,6 +1151,7 @@ parameter with the <tt/#pragma/. #pragma warn (unused-param, pop) </verb></tscreen> + <sect1><tt>#pragma writable-strings ([push,] on|off)</tt><label id="pragma-writable-strings"><p> Changes the storage location of string literals. For historical reasons, diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index 4db780318..250ceecc9 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -618,16 +618,16 @@ static void DoCase (void) static void DoCharMap (void) -/* Allow custome character mappings */ +/* Allow custom character mappings */ { long Index; long Code; /* Read the index as numerical value */ Index = ConstExpression (); - if (Index <= 0 || Index > 255) { + if (Index < 0 || Index > 255) { /* Value out of range */ - ErrorSkip ("Range error"); + ErrorSkip ("Index range error"); return; } @@ -638,7 +638,7 @@ static void DoCharMap (void) Code = ConstExpression (); if (Code < 0 || Code > 255) { /* Value out of range */ - ErrorSkip ("Range error"); + ErrorSkip ("Code range error"); return; } diff --git a/src/cc65/error.c b/src/cc65/error.c index 5218d195c..858a80826 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -66,11 +66,12 @@ IntStack WarningsAreErrors = INTSTACK(0); /* Treat warnings as errors */ /* Warn about: */ IntStack WarnConstComparison= INTSTACK(1); /* - constant comparison results */ IntStack WarnNoEffect = INTSTACK(1); /* - statements without an effect */ +IntStack WarnRemapZero = INTSTACK(1); /* - remapping character code zero */ IntStack WarnStructParam = INTSTACK(1); /* - structs passed by val */ +IntStack WarnUnknownPragma = INTSTACK(1); /* - unknown #pragmas */ IntStack WarnUnusedLabel = INTSTACK(1); /* - unused labels */ IntStack WarnUnusedParam = INTSTACK(1); /* - unused parameters */ IntStack WarnUnusedVar = INTSTACK(1); /* - unused variables */ -IntStack WarnUnknownPragma = INTSTACK(1); /* - unknown #pragmas */ /* Map the name of a warning to the intstack that holds its state */ typedef struct WarnMapEntry WarnMapEntry; @@ -79,10 +80,11 @@ struct WarnMapEntry { const char* Name; }; static WarnMapEntry WarnMap[] = { - /* Keep sorted, even if this isn't used for now */ - { &WarningsAreErrors, "error" }, + /* Keep names sorted, even if it isn't used for now */ { &WarnConstComparison, "const-comparison" }, + { &WarningsAreErrors, "error" }, { &WarnNoEffect, "no-effect" }, + { &WarnRemapZero, "remap-zero" }, { &WarnStructParam, "struct-param" }, { &WarnUnknownPragma, "unknown-pragma" }, { &WarnUnusedLabel, "unused-label" }, diff --git a/src/cc65/error.h b/src/cc65/error.h index 9aec10c77..97ee09591 100644 --- a/src/cc65/error.h +++ b/src/cc65/error.h @@ -65,11 +65,12 @@ extern IntStack WarningsAreErrors; /* Treat warnings as errors */ /* Warn about: */ extern IntStack WarnConstComparison; /* - constant comparison results */ extern IntStack WarnNoEffect; /* - statements without an effect */ +extern IntStack WarnRemapZero; /* - remapping character code zero */ extern IntStack WarnStructParam; /* - structs passed by val */ +extern IntStack WarnUnknownPragma; /* - unknown #pragmas */ extern IntStack WarnUnusedLabel; /* - unused labels */ extern IntStack WarnUnusedParam; /* - unused parameters */ extern IntStack WarnUnusedVar; /* - unused variables */ -extern IntStack WarnUnknownPragma; /* - unknown #pragmas */ diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index f42274922..52af1e722 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -453,13 +453,14 @@ static void CharMapPragma (StrBuf* B) return; } if (Index < 1 || Index > 255) { - if (Index == 0) { - /* For groepaz */ - Error ("Remapping 0 is not allowed"); - } else { + if (Index != 0) { Error ("Character index out of range"); + return; + } + /* For groepaz and Christian */ + if (IS_Get (&WarnRemapZero)) { + Warning ("Remapping from 0 is dangerous with string functions"); } - return; } /* Comma follows */ @@ -472,13 +473,14 @@ static void CharMapPragma (StrBuf* B) return; } if (C < 1 || C > 255) { - if (C == 0) { - /* For groepaz */ - Error ("Remapping 0 is not allowed"); - } else { + if (C != 0) { Error ("Character code out of range"); + return; + } + /* For groepaz and Christian */ + if (IS_Get (&WarnRemapZero)) { + Warning ("Remapping to 0 can make string functions stop unexpectedly"); } - return; } /* Remap the character */ diff --git a/src/cc65/pragma.h b/src/cc65/pragma.h index f12dbaa83..d1b94fa23 100644 --- a/src/cc65/pragma.h +++ b/src/cc65/pragma.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@cc65.org */ +/* (C) 1998-2002, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ diff --git a/src/common/tgttrans.c b/src/common/tgttrans.c index 95bdf8662..bd2056505 100644 --- a/src/common/tgttrans.c +++ b/src/common/tgttrans.c @@ -124,6 +124,6 @@ void TgtTranslateStrBuf (StrBuf* Buf) void TgtTranslateSet (unsigned Index, unsigned char C) /* Set the translation code for the given character */ { - CHECK (Index > 0 && Index < sizeof (Tab)); + CHECK (Index < sizeof (Tab)); Tab[Index] = C; } From 524813ff609b205ca68b0f90df43236b95a2835e Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 12 Jun 2016 22:54:23 +0200 Subject: [PATCH 098/407] Allow to build samples from the main Makefile. --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a10df8db0..808689c82 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all mostlyclean clean install zip avail unavail bin lib doc +.PHONY: all mostlyclean clean install zip avail unavail bin lib doc samples .SUFFIXES: @@ -17,6 +17,9 @@ lib: doc: @$(MAKE) -C doc --no-print-directory $@ +samples: + @$(MAKE) -C samples --no-print-directory $@ + %65: @$(MAKE) -C src --no-print-directory $@ From 98973ee90127b944fe5947e97f080d0ee4d092c3 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 12 Jun 2016 22:56:26 +0200 Subject: [PATCH 099/407] Avoid warnings on monochrom targets (and remove unnecessary code). --- samples/hello.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/samples/hello.c b/samples/hello.c index 385112367..854e9a4b4 100644 --- a/samples/hello.c +++ b/samples/hello.c @@ -34,11 +34,10 @@ int main (void) { unsigned char XSize, YSize; - /* Set screen colors, hide the cursor */ - textcolor (COLOR_WHITE); - bordercolor (COLOR_BLACK); - bgcolor (COLOR_BLACK); - cursor (0); + /* Set screen colors */ + (void) textcolor (COLOR_WHITE); + (void) bordercolor (COLOR_BLACK); + (void) bgcolor (COLOR_BLACK); /* Clear the screen, put cursor in upper left corner */ clrscr (); From 271b65aa70d85b0d1e30c798c2fe270760538f6b Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 12 Jun 2016 23:48:19 +0200 Subject: [PATCH 100/407] Added hint on how to quit program. --- samples/ascii.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ascii.c b/samples/ascii.c index fd293e213..0d191c966 100644 --- a/samples/ascii.c +++ b/samples/ascii.c @@ -58,7 +58,7 @@ int main(void) { /* This prompt fits on the VIC-20's narrow screen. */ - PRINT("Type characters to see\r\ntheir hexadecimal code\r\nnumbers:\r\n\n"); + PRINT("Type characters to see\r\ntheir hexadecimal code\r\nnumbers - 'Q' quits:\r\n\n"); screensize(&width, &height); /* get the screen's dimensions */ width /= 6; /* get number of codes on a line */ cursor(true); From 94ba9575ec4c9a0b2d164ccba93e9685d92f71f3 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 13 Jun 2016 20:40:01 +0200 Subject: [PATCH 101/407] Implement exec() for Atari XDOS. - Adds new ENOEXEC error code, also used by Apple2 targets. - Maximum command line length is 40, incl. program name. This is an XDOS restriction. - testcode/lib/tinyshell.c has been extended to be able to run programs. --- asminc/atari.inc | 5 + asminc/errno.inc | 1 + include/errno.h | 3 +- libsrc/apple2/oserror.s | 2 +- libsrc/atari/crt0.s | 8 +- libsrc/atari/exec.s | 207 +++++++++++++++++++++++++++++++++++++++ libsrc/atari/oserror.s | 2 +- libsrc/common/errormsg.c | 1 + testcode/lib/tinyshell.c | 44 +++++++-- 9 files changed, 260 insertions(+), 13 deletions(-) create mode 100644 libsrc/atari/exec.s diff --git a/asminc/atari.inc b/asminc/atari.inc index f7a7ab223..453c370f4 100644 --- a/asminc/atari.inc +++ b/asminc/atari.inc @@ -183,6 +183,7 @@ FNTFND = 170 ;($AA) file not found PNTINV = 171 ;($AB) point invalid BADDSK = 173 ;($AD) bad disk INCFMT = 176 ;($B0) DOS 3: incompatible file system +XNTBIN = 180 ;($B4) XDOS: file not binary ; DCB Device Bus Equates @@ -889,6 +890,10 @@ SETVBV_org = $E45C ;vector to set VBLANK parameters CIOV = $E456 ;vector to CIO SIOV = $E459 ;vector to SIO SETVBV = $E45C ;vector to set VBLANK parameters +; aliases in order not to have to sprinkle common code with .ifdefs +CIOV_org = CIOV +SIOV_org = SIOV +SETVBV_org = SETVBV .endif SYSVBV = $E45F ;vector to process immediate VBLANK XITVBV = $E462 ;vector to process deferred VBLANK diff --git a/asminc/errno.inc b/asminc/errno.inc index 83cd9a75d..6e5cce42b 100644 --- a/asminc/errno.inc +++ b/asminc/errno.inc @@ -28,6 +28,7 @@ ESPIPE ; Illegal seek ERANGE ; Range error EBADF ; Bad file number + ENOEXEC ; Exec format error EUNKNOWN ; Unknown OS specific error - must be last! EMAX = EUNKNOWN ; Highest error code diff --git a/include/errno.h b/include/errno.h index 0b3d67bc7..ae76b6c05 100644 --- a/include/errno.h +++ b/include/errno.h @@ -72,7 +72,8 @@ extern int _errno; #define ESPIPE 14 /* Illegal seek */ #define ERANGE 15 /* Range error */ #define EBADF 16 /* Bad file number */ -#define EUNKNOWN 17 /* Unknown OS specific error */ +#define ENOEXEC 17 /* Exec format error */ +#define EUNKNOWN 18 /* Unknown OS specific error */ diff --git a/libsrc/apple2/oserror.s b/libsrc/apple2/oserror.s index f16aa4960..ae3efcacc 100644 --- a/libsrc/apple2/oserror.s +++ b/libsrc/apple2/oserror.s @@ -45,7 +45,7 @@ ErrTab: .byte $01, ENOSYS ; Bad system call number .byte $47, EEXIST ; Duplicate filename .byte $48, ENOSPC ; Volume full .byte $49, ENOSPC ; Volume directory full -; .byte $4A, EUNKNOWN ; Incompatible file format + .byte $4A, ENOEXEC ; Incompatible file format .byte $4B, EINVAL ; Unsupported storage_type ; .byte $4C, EUNKNOWN ; End of file encountered .byte $4D, ESPIPE ; Position out of range diff --git a/libsrc/atari/crt0.s b/libsrc/atari/crt0.s index 87d7d036f..d14567491 100644 --- a/libsrc/atari/crt0.s +++ b/libsrc/atari/crt0.s @@ -9,7 +9,7 @@ ; .export __STARTUP__ : absolute = 1 ; Mark as startup - .export _exit, start + .export _exit, start, excexit, SP_save .import initlib, donelib .import callmain, zerobss @@ -109,12 +109,12 @@ start: ; Call the module destructors. This is also the exit() entry. -_exit: jsr donelib ; Run module destructors +_exit: ldx SP_save + txs ; Restore stack pointer ; Restore the system stuff. - ldx SP_save - txs ; Restore stack pointer +excexit:jsr donelib ; Run module destructors; 'excexit' is called from the exec routine ; Restore the left margin. diff --git a/libsrc/atari/exec.s b/libsrc/atari/exec.s new file mode 100644 index 000000000..2835a2206 --- /dev/null +++ b/libsrc/atari/exec.s @@ -0,0 +1,207 @@ +; +; Christian Groessler, 12-Jun-2016 +; +; int __fastcall__ exec (const char* progname, const char* cmdline); +; +; supports only XDOS at the moment + + .export _exec + + .import popax + .import __dos_type + .import findfreeiocb + .import incsp2 + .import __do_oserror + .import excexit ; from crt0.s + .import SP_save ; from crt0.s +.ifdef UCASE_FILENAME + .importzp tmp3 + .import ucase_fn + .import addysp +.endif + + .include "zeropage.inc" + .include "errno.inc" + .include "atari.inc" + +CMDLINE_BUFFER = $0100 ; put progname + cmdline as one single string there +CMDLINE_MAX = 40+3 ; max. length of drive + progname + cmdline + + .code + +notsupp:lda #ENOSYS ; "unsupported system call" + .byte $2C ; bit opcode, eats the next 2 bytes +noiocb: lda #EMFILE ; "too many open files" + jsr incsp2 ; clean up stack +seterr: jsr __directerrno + lda #$FF + tax + rts ; return -1 + +; entry point + +_exec: + ; save cmdline + sta ptr3 + stx ptr3+1 + + ldy __dos_type + cpy #XDOS + bne notsupp + + jsr findfreeiocb + bne noiocb + + stx tmp4 ; remember IOCB index + + ; get program name + jsr popax + +.ifdef UCASE_FILENAME +.ifdef DEFAULT_DEVICE + ldy #$80 +.else + ldy #$00 +.endif + sty tmp2 ; set flag for ucase_fn + jsr ucase_fn + bcc ucok1 +invret: lda #EINVAL ; file name is too long + bne seterr +ucok1: +.endif ; defined UCASE_FILENAME + +; copy program name and arguments to CMDLINE_BUFFER + + sta ptr4 ; ptr4: pointer to program name + stx ptr4+1 + ldy #0 + ; TODO: check stack ptr and and use min(CMDLINE_MAX,available_stack) +copyp: lda (ptr4),y + beq copypd + sta CMDLINE_BUFFER,y + iny + cpy #CMDLINE_MAX + bne copyp + + ; programe name too long + beq invret + +; file name copied, check for args + +copypd: tya ; put Y into X (index into CMDLINE_BUFFER) + tax + lda ptr3 + ora ptr3+1 ; do we have arguments? + beq copycd ; no + ldy #0 + lda (ptr3),y ; get first byte of cmdline parameter + beq copycd ; nothing there... + lda #' ' ; add a space btw. progname and cmdline + bne copyc1 + +; copy args + +copyc: lda (ptr3),y + beq copycd + iny +copyc1: sta CMDLINE_BUFFER,x + inx + cpx #CMDLINE_MAX + bne copyc + ; progname + arguments too long + beq invret + +invexe: jsr close + lda #XNTBIN + bne setmerr + +copycd: lda #ATEOL + sta CMDLINE_BUFFER,x + +; open the program file, read the first two bytes and compare them to $FF + + ldx tmp4 ; get IOCB index + lda ptr4 ; ptr4 points to progname + sta ICBAL,x + lda ptr4+1 + sta ICBAH,x + lda #OPNIN ; open for input + sta ICAX1,x + lda #OPEN + sta ICCOM,x + jsr CIOV + + tya + +.ifdef UCASE_FILENAME + ldy tmp3 ; get size + jsr addysp ; free used space on the stack + ; the following 'bpl' depends on 'addysp' restoring A as last command before 'rts' +.endif ; defined UCASE_FILENAME + + bpl openok + pha ; remember error code + jsr close ; close the IOCB (required even if open failed) + pla ; put error code back into A +setmerr:jmp __mappederrno ; update errno from OS specific error code in A + +openok: lda #>buf + sta ICBAH,x ; set buffer address + lda #<buf + sta ICBAL,x + lda #0 ; set buffer length + sta ICBLH,x + lda #2 + sta ICBLL,x + lda #GETCHR ; iocb command code + sta ICCOM,x + jsr CIOV ; read it + bmi invexe ; read operation failed, return error + + lda ICBLL,x ; # of bytes read + cmp #2 + bne invexe + lda #$FF ; check file format (need $FFFF at the beginning) + cmp buf + bne invexe + cmp buf+1 + bne invexe + + jsr close ; close program file + +; program file appears to be available and good +; here's the point of no return + + lda tmp4 ; get IOCB index + pha ; and save it ('excexit' calls destructors and they might destroy tmp4) + jsr excexit + pla + ldx SP_save + txs ; reset stack pointer + tax ; IOCB index in X + + lda #<CMDLINE_BUFFER + sta ICBAL,x ; address + lda #>CMDLINE_BUFFER + sta ICBAH,x + lda #0 + sta ICBLL,x ; length shouldn't be random, but 0 is ok + sta ICBLH,x + sta ICAX1,x + sta ICAX2,x + lda #80 ; XDOS: run DUP command + sta ICCOM,x + jmp CIOV_org ; no way to display an error message in case of failure, and we will return to DOS + + +; close IOCB, index in X +.proc close + lda #CLOSE + sta ICCOM,x + jmp CIOV ; close IOCB +.endproc + + .bss + +buf: .res 2 diff --git a/libsrc/atari/oserror.s b/libsrc/atari/oserror.s index a4ba07c0f..1d95dbc36 100644 --- a/libsrc/atari/oserror.s +++ b/libsrc/atari/oserror.s @@ -95,7 +95,7 @@ maptable: .byte EUNKNOWN ; 177 - haven't found documentation .byte EUNKNOWN ; 178 - haven't found documentation .byte EUNKNOWN ; 179 - haven't found documentation - .byte EUNKNOWN ; 180 - not a binary file + .byte ENOEXEC ; 180 - not a binary file .byte EUNKNOWN ; 181 - [MYDOS] invalid address range .byte EUNKNOWN ; 182 - [XDOS] invalid parameter diff --git a/libsrc/common/errormsg.c b/libsrc/common/errormsg.c index 162dad085..e6df34ad3 100644 --- a/libsrc/common/errormsg.c +++ b/libsrc/common/errormsg.c @@ -24,6 +24,7 @@ const char* const _sys_errlist[] = { "Illegal seek", /* ESPIPE */ "Range error", /* ERANGE */ "Bad file number", /* EBADF */ + "Exec format error", /* ENOEXEC */ "Unknown OS error code", /* EUNKNOWN */ }; diff --git a/testcode/lib/tinyshell.c b/testcode/lib/tinyshell.c index de57a3d0e..b5654983e 100644 --- a/testcode/lib/tinyshell.c +++ b/testcode/lib/tinyshell.c @@ -1,9 +1,9 @@ /* ** Simple ("tiny") shell to test filename and directory functions. -** Copyright (c) 2013, Christian Groessler, chris@groessler.org +** Copyright (c) 2013,2016 Christian Groessler, chris@groessler.org */ -#define VERSION_ASC "0.90" +#define VERSION_ASC "0.91" #ifdef __ATARI__ #define UPPERCASE /* define (e.g. for Atari) to convert filenames etc. to upper case */ @@ -18,7 +18,7 @@ #define CHECK_SP #endif -#define KEYB_BUFSZ 80 +#define KEYB_BUFSZ 127 #define PROMPT ">>> " #include <stdio.h> @@ -55,12 +55,14 @@ extern unsigned int getsp(void); /* comes from getsp.s */ #define CMD_PWD 11 #define CMD_CLS 12 #define CMD_VERBOSE 13 +#define CMD_EXEC 14 static unsigned char verbose; static unsigned char terminate; static unsigned char cmd; -static unsigned char *cmd_asc, *arg1, *arg2, *arg3; -static unsigned char keyb_buf[KEYB_BUFSZ]; +static unsigned char *cmd_asc, *arg1, *arg2, *arg3, *args; /* 'args': everything after command */ +static unsigned char keyb_buf[KEYB_BUFSZ + 1]; +static unsigned char keyb_buf2[KEYB_BUFSZ + 1]; static size_t cpbuf_sz = 4096; struct cmd_table { @@ -88,6 +90,7 @@ struct cmd_table { { "mv", CMD_RENAME }, { "ren", CMD_RENAME }, { "pwd", CMD_PWD }, + { "exec", CMD_EXEC }, #ifdef __ATARI__ { "cls", CMD_CLS }, #endif @@ -134,6 +137,17 @@ static void get_command(void) return; } + /* put everything after first string into 'args' */ + + strcpy(keyb_buf2, keyb_buf); /* use a backup copy for 'args' */ + + /* skip over the first non-whitespace item */ + cmd_asc = strtok(keyb_buf2, " \t\n"); + if (cmd_asc) + args = strtok(NULL, ""); /* get everything */ + else + *args = 0; /* no arguments */ + /* split input into cmd, arg1, arg2, arg3 */ /* get and parse command */ @@ -172,11 +186,11 @@ static void cmd_help(void) puts("cd, chdir - change directory or drive"); puts("md, mkdir - make directory or drive"); puts("rd, rmdir - remove directory or drive"); + puts("exec - run program"); #ifdef __ATARI__ puts("cls - clear screen"); #endif puts("verbose - set verbosity level"); - puts("sorry, you cannot start programs here"); } static void cmd_ls(void) @@ -340,6 +354,23 @@ static void cmd_rename(void) printf("rename failed: %s\n", strerror(errno)); } +static void cmd_exec(void) +{ + int st; + unsigned char *progname, *arguments; + + progname = strtok(args, " \t\n"); + if (! progname) { + puts("usage: exec <progname> [arguments]"); + return; + } + arguments = strtok(NULL, ""); + + /*printf("exec: %s %s\n", progname, arguments ? arguments : "");*/ + st = exec(progname, arguments); + printf("exec error: %s\n", strerror(errno)); +} + static void cmd_copy(void) { int srcfd = -1, dstfd = -1; @@ -446,6 +477,7 @@ static void run_command(void) case CMD_RMDIR: cmd_rmdir(); return; case CMD_PWD: cmd_pwd(); return; #endif + case CMD_EXEC: cmd_exec(); return; case CMD_RENAME: cmd_rename(); return; case CMD_COPY: cmd_copy(); return; #ifdef __ATARI__ From 4aa9a414c661a1e179500b02cf4f27dabf5b9272 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 13 Jun 2016 21:16:27 +0200 Subject: [PATCH 102/407] Fix doesclrscrafterexit() function on atarixl target. On atarixl, the screen is always cleared, regardless of the running DOS. --- libsrc/atari/doesclrscr.s | 15 ++++++++------- libsrc/atari/is_cmdline_dos.s | 11 ++++++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libsrc/atari/doesclrscr.s b/libsrc/atari/doesclrscr.s index c085faebf..2e19e4b98 100644 --- a/libsrc/atari/doesclrscr.s +++ b/libsrc/atari/doesclrscr.s @@ -7,13 +7,14 @@ ; .export _doesclrscrafterexit - .import __dos_type - .include "atari.inc" + .import __is_cmdline_dos + .import return1 +.ifdef __ATARIXL__ +_doesclrscrafterexit = return1 ; the c65 runtime always clears the screen at program termination +.else _doesclrscrafterexit: - ldx #0 - lda __dos_type - cmp #MAX_DOS_WITH_CMDLINE + 1 - txa - rol a + jsr __is_cmdline_dos ; currently (unless a DOS behaving differently is popping up) + eor #$01 ; we can get by with the inverse of __is_cmdline_dos rts +.endif diff --git a/libsrc/atari/is_cmdline_dos.s b/libsrc/atari/is_cmdline_dos.s index b85cb3ca7..71b35fbad 100644 --- a/libsrc/atari/is_cmdline_dos.s +++ b/libsrc/atari/is_cmdline_dos.s @@ -7,9 +7,14 @@ ; .export __is_cmdline_dos - .import _doesclrscrafterexit + .import __dos_type + .include "atari.inc" __is_cmdline_dos: - jsr _doesclrscrafterexit ; currently (unless a DOS behaving differently is popping up) - eor #$01 ; we can get by with the inverse of _doesclrscrafterexit + ldx #0 + lda __dos_type + cmp #MAX_DOS_WITH_CMDLINE + 1 + txa + rol a + eor #$01 rts From d0faf471b8543ffaa32346d3c673f145ead7e068 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 14 Jun 2016 20:44:57 +0200 Subject: [PATCH 103/407] Some improvements to Atari exec() after review. --- libsrc/atari/exec.s | 6 ++---- testcode/lib/tinyshell.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libsrc/atari/exec.s b/libsrc/atari/exec.s index 2835a2206..4ae30fdbf 100644 --- a/libsrc/atari/exec.s +++ b/libsrc/atari/exec.s @@ -33,10 +33,8 @@ notsupp:lda #ENOSYS ; "unsupported system call" .byte $2C ; bit opcode, eats the next 2 bytes noiocb: lda #EMFILE ; "too many open files" jsr incsp2 ; clean up stack -seterr: jsr __directerrno - lda #$FF - tax - rts ; return -1 +seterr: jmp __directerrno + ; entry point diff --git a/testcode/lib/tinyshell.c b/testcode/lib/tinyshell.c index b5654983e..c83bd14e8 100644 --- a/testcode/lib/tinyshell.c +++ b/testcode/lib/tinyshell.c @@ -356,7 +356,6 @@ static void cmd_rename(void) static void cmd_exec(void) { - int st; unsigned char *progname, *arguments; progname = strtok(args, " \t\n"); @@ -367,7 +366,7 @@ static void cmd_exec(void) arguments = strtok(NULL, ""); /*printf("exec: %s %s\n", progname, arguments ? arguments : "");*/ - st = exec(progname, arguments); + (void)exec(progname, arguments); printf("exec error: %s\n", strerror(errno)); } From ec7751332fd72daeb8eb5be811f1e86be9adbc02 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 15 Jun 2016 23:52:16 +0200 Subject: [PATCH 104/407] Fix exec() for atarixl target. The final part of exec() called 'excexit' and only then restored the stack pointer to its value at program entry. 'excexit' does all cleanup (the same as '_exit()'), which means that on the atarixl target the ROM is banked in again. On big programs the 'SP_save' variable might reside at a high memory address which is no longer accessible after the ROM has been banked in. The change just moves the restoration of the stack pointer before the call to 'excexit'. Another change lets exec.s compile if UCASE_FILENAME is not defined. And some other small cleanups, also in open.s. --- libsrc/atari/exec.s | 20 +++++++++++++------- libsrc/atari/open.s | 3 +-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/libsrc/atari/exec.s b/libsrc/atari/exec.s index 4ae30fdbf..260a772b4 100644 --- a/libsrc/atari/exec.s +++ b/libsrc/atari/exec.s @@ -11,11 +11,9 @@ .import __dos_type .import findfreeiocb .import incsp2 - .import __do_oserror .import excexit ; from crt0.s .import SP_save ; from crt0.s .ifdef UCASE_FILENAME - .importzp tmp3 .import ucase_fn .import addysp .endif @@ -24,7 +22,10 @@ .include "errno.inc" .include "atari.inc" -CMDLINE_BUFFER = $0100 ; put progname + cmdline as one single string there +; area $0100 to $0128 might be in use (e.g. Hias' high speed patch) +CMDLINE_BUFFER = $0129 ; put progname + cmdline as one single string there +; alternatively: +;CMDLINE_BUFFER = $0480 ; put progname + cmdline as one single string there CMDLINE_MAX = 40+3 ; max. length of drive + progname + cmdline .code @@ -85,6 +86,11 @@ copyp: lda (ptr4),y ; programe name too long beq invret +.ifndef UCASE_FILENAME +invret: lda #EINVAL + bne seterr +.endif + ; file name copied, check for args copypd: tya ; put Y into X (index into CMDLINE_BUFFER) @@ -172,11 +178,11 @@ openok: lda #>buf ; here's the point of no return lda tmp4 ; get IOCB index - pha ; and save it ('excexit' calls destructors and they might destroy tmp4) - jsr excexit - pla ldx SP_save - txs ; reset stack pointer + txs ; reset stack pointer to what it was at program entry + pha ; and save it ('excexit' calls destructors and they might destroy tmp4) + jsr excexit ; on atarixl this will enable the ROM again, making all high variables inaccessible + pla tax ; IOCB index in X lda #<CMDLINE_BUFFER diff --git a/libsrc/atari/open.s b/libsrc/atari/open.s index d5ff4ca52..721519525 100644 --- a/libsrc/atari/open.s +++ b/libsrc/atari/open.s @@ -8,6 +8,7 @@ .include "fcntl.inc" .include "errno.inc" .include "fd.inc" + .include "zeropage.inc" .export _open .destructor closeallfiles, 5 @@ -19,9 +20,7 @@ .import incsp4 .import ldaxysp,addysp .import __oserror - .importzp tmp4,tmp2 .ifdef UCASE_FILENAME - .importzp tmp3 .import ucase_fn .endif From a9c69bb8c9fef39903b27971ed5c9c7c0f83e71b Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Thu, 16 Jun 2016 00:47:13 +0200 Subject: [PATCH 105/407] A small rearrangement of instructions in Atari's exec() to let the comments make sense again. --- libsrc/atari/exec.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/exec.s b/libsrc/atari/exec.s index 260a772b4..16062a294 100644 --- a/libsrc/atari/exec.s +++ b/libsrc/atari/exec.s @@ -177,9 +177,9 @@ openok: lda #>buf ; program file appears to be available and good ; here's the point of no return - lda tmp4 ; get IOCB index ldx SP_save txs ; reset stack pointer to what it was at program entry + lda tmp4 ; get IOCB index pha ; and save it ('excexit' calls destructors and they might destroy tmp4) jsr excexit ; on atarixl this will enable the ROM again, making all high variables inaccessible pla From f91a7e749b869ab51c0e26ab628191d9d831e5a8 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sat, 18 Jun 2016 13:18:26 -0400 Subject: [PATCH 106/407] Fixed the Plus/4 joystick driver. It chooses a stick correctly. And, it reads the fire button. --- libsrc/plus4/joy/plus4-stdjoy.s | 34 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/libsrc/plus4/joy/plus4-stdjoy.s b/libsrc/plus4/joy/plus4-stdjoy.s index 29316bf22..4a5132887 100644 --- a/libsrc/plus4/joy/plus4-stdjoy.s +++ b/libsrc/plus4/joy/plus4-stdjoy.s @@ -1,17 +1,15 @@ ; -; Standard joystick driver for the Plus/4. May be used multiple times when linked -; to the statically application. +; Standard joystick driver for the Plus/4 and C16. +; May be used multiple times when linked statically to an application. ; -; Ullrich von Bassewitz, 2002-12-21 +; 2002-12-21, Ullrich von Bassewitz +; 2016-06-18, Greg King ; - .include "zeropage.inc" - .include "joy-kernel.inc" .include "joy-error.inc" .include "plus4.inc" - .macpack generic .macpack module @@ -26,7 +24,7 @@ ; Driver signature - .byte $6A, $6F, $79 ; "joy" + .byte $6A, $6F, $79 ; ASCII "joy" .byte JOY_API_VERSION ; Driver API version number ; Library reference @@ -39,7 +37,7 @@ .byte $02 ; JOY_DOWN .byte $04 ; JOY_LEFT .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE + .byte $80 ; JOY_FIRE .byte $00 ; JOY_FIRE2 unavailable .byte $00 ; Future expansion .byte $00 ; Future expansion @@ -98,16 +96,20 @@ COUNT: ; READ: Read a particular joystick passed in A. ; -READ: ldy #$FA ; Load index for joystick #1 +READ: ldy #%11111011 ; Load index for joystick #1 tax ; Test joystick number beq @L1 - ldy #$FB ; Load index for joystick #2 + ldy #%11111101 ; Load index for joystick #2 + ldx #>$0000 ; (Return unsigned int) @L1: sei - sty TED_KBD - lda TED_KBD + sty TED_KBD ; Read a joystick ... + lda TED_KBD ; ... and some keys -- it's unavoidable cli - ldx #$00 ; Clear high byte - and #$1F - eor #$1F - rts + eor #%11111111 +; The fire buttons are in bits 6 and 7. Both of them cannot be %1 together. +; Therefore, bit 6 can be merged with bit 7. + + clc + adc #%01000000 + rts From 9bc096d9b02255cab6d4225e28c0685714ca3ae3 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sat, 18 Jun 2016 23:35:57 +0200 Subject: [PATCH 107/407] Make use of doesclrscrafterexit(). --- samples/diodemo.c | 6 ++++++ samples/enumdevdir.c | 6 ++++-- samples/gunzip65.c | 12 ++++++++++++ samples/mandelbrot.c | 29 ++++++++++++++++++----------- samples/mousetest.c | 5 ++++- samples/multidemo.c | 10 ++++++---- samples/overlaydemo.c | 6 ++++-- samples/tgidemo.c | 3 +++ 8 files changed, 57 insertions(+), 20 deletions(-) diff --git a/samples/diodemo.c b/samples/diodemo.c index 752c2f78a..3e52f2fa9 100644 --- a/samples/diodemo.c +++ b/samples/diodemo.c @@ -36,6 +36,7 @@ #include <conio.h> #include <ctype.h> #include <errno.h> +#include <cc65.h> #include <dio.h> @@ -123,6 +124,11 @@ int main (int argc, const char* argv[]) clrscr (); screensize (&ScreenX, &ScreenY); + /* Allow user to read exit messages */ + if (doesclrscrafterexit ()) { + atexit ((void (*)) cgetc); + } + cputs ("Floppy Disk Copy\r\n"); chline (16); cputs ("\r\n"); diff --git a/samples/enumdevdir.c b/samples/enumdevdir.c index f270b43af..ce2dc99ec 100644 --- a/samples/enumdevdir.c +++ b/samples/enumdevdir.c @@ -8,12 +8,12 @@ #include <stdio.h> -#include <conio.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #include <device.h> #include <dirent.h> +#include <cc65.h> void printdir (char *newdir) @@ -97,5 +97,7 @@ void main (void) device = getnextdevice (device); } - cgetc (); + if (doesclrscrafterexit ()) { + getchar (); + } } diff --git a/samples/gunzip65.c b/samples/gunzip65.c index 2ad029467..9d21c2137 100644 --- a/samples/gunzip65.c +++ b/samples/gunzip65.c @@ -14,6 +14,11 @@ #include <string.h> #include <zlib.h> +#ifdef __CC65__ +#include <stdlib.h> +#include <cc65.h> +#endif + #ifndef __CC65__ /* ** Emulate inflatemem() if using original zlib. @@ -191,6 +196,13 @@ int main(void) FILE* fp; unsigned length; +#ifdef __CC65__ + /* allow user to read exit messages */ + if (doesclrscrafterexit()) { + atexit((void (*)) getchar); + } +#endif /* __CC65__ */ + /* read GZIP file */ puts("GZIP file name:"); fp = fopen(get_fname(), "rb"); diff --git a/samples/mandelbrot.c b/samples/mandelbrot.c index 5d3d661c9..d7291c5b5 100644 --- a/samples/mandelbrot.c +++ b/samples/mandelbrot.c @@ -10,6 +10,7 @@ #include <time.h> #include <conio.h> #include <tgi.h> +#include <cc65.h> @@ -51,7 +52,7 @@ void mandelbrot (signed short x1, signed short y1, signed short x2, register signed short xs, ys, xx, yy; register signed short x, y; - /* calc stepwidth */ + /* Calc stepwidth */ xs = ((x2 - x1) / (SCREEN_X)); ys = ((y2 - y1) / (SCREEN_Y)); @@ -61,7 +62,7 @@ void mandelbrot (signed short x1, signed short y1, signed short x2, xx = x1; for (x = 0; x < (SCREEN_X); x++) { xx += xs; - /* do iterations */ + /* Do iterations */ r = 0; i = 0; for (count = 0; (count < maxiterations) && @@ -75,12 +76,13 @@ void mandelbrot (signed short x1, signed short y1, signed short x2, if (count == maxiterations) { tgi_setcolor (0); } else { - if (MAXCOL == 2) + if (MAXCOL == 2) { tgi_setcolor (1); - else + } else { tgi_setcolor (count % MAXCOL); + } } - /* set pixel */ + /* Set pixel */ tgi_setpixel (x, y); } } @@ -107,6 +109,9 @@ int main (void) if (err != TGI_ERR_OK) { cprintf ("Error #%d initializing graphics.\r\n%s\r\n", err, tgi_geterrormsg (err)); + if (doesclrscrafterexit ()) { + cgetc (); + } exit (EXIT_FAILURE); }; cprintf ("ok.\n\r"); @@ -117,15 +122,15 @@ int main (void) t = clock (); - /* calc mandelbrot set */ + /* Calc mandelbrot set */ mandelbrot (tofp (-2), tofp (-2), tofp (2), tofp (2)); t = clock () - t; /* Fetch the character from the keyboard buffer and discard it */ - (void) cgetc (); + cgetc (); - /* shut down gfx mode and return to textmode */ + /* Shut down gfx mode and return to textmode */ tgi_done (); /* Calculate stats */ @@ -136,9 +141,11 @@ int main (void) /* Output stats */ cprintf ("time : %lu.%us\n\r", sec, sec10); - /* Wait for a key, then end */ - cputs ("Press any key when done...\n\r"); - (void) cgetc (); + if (doesclrscrafterexit ()) { + /* Wait for a key, then end */ + cputs ("Press any key when done...\n\r"); + cgetc (); + } /* Done */ return EXIT_SUCCESS; diff --git a/samples/mousetest.c b/samples/mousetest.c index 4a849cb98..3910d5a0a 100644 --- a/samples/mousetest.c +++ b/samples/mousetest.c @@ -17,6 +17,7 @@ #include <conio.h> #include <ctype.h> #include <dbg.h> +#include <cc65.h> #define max(a,b) (((a) > (b)) ? (a) : (b)) #define min(a,b) (((a) < (b)) ? (a) : (b)) @@ -57,7 +58,9 @@ static void __fastcall__ CheckError (const char* S, unsigned char Error) /* Wait for a key-press, so that some platforms can show the error ** message before they remove the current screen. */ - cgetc(); + if (doesclrscrafterexit ()) { + cgetc (); + } exit (EXIT_FAILURE); } } diff --git a/samples/multidemo.c b/samples/multidemo.c index 74039cfd6..038b74d64 100644 --- a/samples/multidemo.c +++ b/samples/multidemo.c @@ -11,11 +11,11 @@ #include <string.h> -#include <conio.h> #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <em.h> +#include <cc65.h> #ifndef __CBM__ #include <fcntl.h> #include <unistd.h> @@ -229,7 +229,7 @@ void main (void) } log ("Press any key..."); - cgetc (); + getchar (); if (loadoverlay (1)) { log ("Calling overlay 1 from main"); @@ -254,6 +254,8 @@ void main (void) foobar (); } - log ("Press any key..."); - cgetc (); + if (doesclrscrafterexit ()) { + log ("Press any key..."); + getchar (); + } } diff --git a/samples/overlaydemo.c b/samples/overlaydemo.c index 42e757153..a4dc53931 100644 --- a/samples/overlaydemo.c +++ b/samples/overlaydemo.c @@ -10,7 +10,7 @@ #include <stdio.h> -#include <conio.h> +#include <cc65.h> #ifndef __CBM__ #include <fcntl.h> #include <unistd.h> @@ -130,5 +130,7 @@ void main (void) foobar (); } - cgetc (); + if (doesclrscrafterexit ()) { + getchar (); + } } diff --git a/samples/tgidemo.c b/samples/tgidemo.c index a08020640..d8c2a6f50 100644 --- a/samples/tgidemo.c +++ b/samples/tgidemo.c @@ -40,6 +40,9 @@ static void CheckError (const char* S) unsigned char Error = tgi_geterror (); if (Error != TGI_ERR_OK) { printf ("%s: %d\n", S, Error); + if (doesclrscrafterexit ()) { + cgetc (); + } exit (EXIT_FAILURE); } } From 64c10aa2fe36a4becf473b63cb883fb9c22b6015 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sat, 18 Jun 2016 23:39:21 +0200 Subject: [PATCH 108/407] Minor simplification. --- samples/hello.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello.c b/samples/hello.c index 854e9a4b4..dd15128d2 100644 --- a/samples/hello.c +++ b/samples/hello.c @@ -77,7 +77,7 @@ int main (void) #else /* Wait for the user to press a key */ - (void) cgetc (); + cgetc (); #endif From 66561c23c10fe1a8e62dd276e4740fd0e5c8e4f4 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Jun 2016 01:22:59 +0200 Subject: [PATCH 109/407] Made Makefile actually work. Supported target systems: * c64 (default) * apple2 * apple2enh * atari * atarixl --- samples/Makefile | 207 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 140 insertions(+), 67 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index c138c1c2e..bbf69c820 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -4,7 +4,7 @@ # This Makefile requires GNU make # -# Enter the target system here +# Run 'make samples SYS=<target>' to build for another target system SYS = c64 ifneq ($(shell echo),) @@ -14,74 +14,74 @@ endif ifdef CMD_EXE NULLDEV = nul: DEL = -del /f + RMDIR = rmdir /s /q else NULLDEV = /dev/null DEL = $(RM) + RMDIR = $(RM) -r endif -# Determine the path to the executables and libraries. If the samples -# directory is part of a complete source tree, use the stuff from that -# source tree; otherwise, use the "install" directories. -ifeq "$(wildcard ../src)" "" -# No source tree -installdir = /usr/lib/cc65 -ifneq "$(wildcard /usr/local/lib/cc65)" "" -installdir = /usr/local/lib/cc65 -endif -ifneq "$(wildcard /opt/local/share/cc65)" "" -installdir = /opt/local/share/cc65 -endif ifdef CC65_HOME -installdir = $(CC65_HOME) -endif - -MOUS := $(wildcard $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou) -TGI := $(wildcard $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi) -CLIB = --lib $(SYS).lib -CL = cl65 -CC = cc65 -AS = ca65 -LD = ld65 - + AS = $(CC65_HOME)/bin/ca65 + CC = $(CC65_HOME)/bin/cc65 + CL = $(CC65_HOME)/bin/cl65 + LD = $(CC65_HOME)/bin/ld65 else -# "samples/" is a part of a complete source tree. -export CC65_HOME := $(abspath ..) -MOUS := $(wildcard ../target/$(SYS)/drv/mou/$(SYS)*.mou) -TGI := $(wildcard ../target/$(SYS)/drv/tgi/$(SYS)*.tgi) -CLIB = ../lib/$(SYS).lib -CL = ../bin/cl65 -CC = ../bin/cc65 -AS = ../bin/ca65 -LD = ../bin/ld65 + AS := $(if $(wildcard ../bin/ca65*),../bin/ca65,ca65) + CC := $(if $(wildcard ../bin/cc65*),../bin/cc65,cc65) + CL := $(if $(wildcard ../bin/cl65*),../bin/cl65,cl65) + LD := $(if $(wildcard ../bin/ld65*),../bin/ld65,ld65) endif +TARGET_PATH := $(shell $(CL) --print-target-path) + +EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*) +MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*) +TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*) + # This one comes with VICE C1541 ?= c1541 +# For this one see http://applecommander.sourceforge.net/ +AC ?= ac.jar + +# For this one see http://www.horus.com/~hias/atari/ +DIR2ATR ?= dir2atr + +DISK_c64 = samples.d64 +DISK_apple2 = samples.dsk +DISK_apple2enh = samples.dsk +DISK_atari = samples.atr +DISK_atarixl = samples.atr + # -------------------------------------------------------------------------- # System-dependent settings # The Apple machines need the start address adjusted when using TGI -LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000 -LDFLAGS_tgidemo_apple2 = --start-addr 0x4000 +LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000 LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000 -LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000 +LDFLAGS_tgidemo_apple2 = --start-addr 0x4000 +LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000 # The Apple ][ needs the start address adjusted for the mousetest LDFLAGS_mousetest_apple2 = --start-addr 0x4000 -# The atarixl target needs the start address adjusted when using TGI -LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000 -LDFLAGS_tgidemo_atarixl = --start-addr 0x4000 +# The Apple machines need the end address adjusted for large programs +LDFLAGS_gunzip65_apple2 = -D __HIMEM__=0xBF00 +LDFLAGS_gunzip65_apple2enh = -D __HIMEM__=0xBF00 # The atari target needs to reserve some memory when using TGI LDFLAGS_mandelbrot_atari = -D __RESERVED_MEMORY__=0x2000 -LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000 +LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000 + +# The atarixl target needs the start address adjusted when using TGI +LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000 +LDFLAGS_tgidemo_atarixl = --start-addr 0x4000 # -------------------------------------------------------------------------- # Generic rules -.PHONY: all mostlyclean clean install zip samples d64 +.PHONY: all mostlyclean clean install zip samples disk %: %.c %: %.s @@ -96,43 +96,72 @@ LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000 .PRECIOUS: %.o .o: - $(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB) + $(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(SYS).lib # -------------------------------------------------------------------------- -# List of executables. This list could be made target-dependent by checking -# $(SYS). +# List of executables -EXELIST = ascii \ - diodemo \ - enumdevdir \ - fire \ - gunzip65 \ - hello \ - mandelbrot \ - mousetest \ - multdemo \ - nachtm \ - ovrldemo \ - plasma \ - sieve \ - tgidemo +EXELIST_c64 = \ + ascii \ + enumdevdir \ + fire \ + gunzip65 \ + hello \ + mandelbrot \ + mousetest \ + multdemo \ + nachtm \ + ovrldemo \ + plasma \ + sieve \ + tgidemo + +EXELIST_apple2 = \ + ascii \ + diodemo \ + enumdevdir \ + gunzip65 \ + hello \ + mandelbrot \ + mousetest \ + multdemo \ + ovrldemo \ + sieve \ + tgidemo + +EXELIST_apple2enh = $(EXELIST_apple2) + +EXELIST_atari = \ + ascii \ + gunzip65 \ + hello \ + mandelbrot \ + mousetest \ + multdemo \ + ovrldemo \ + sieve \ + tgidemo + +EXELIST_atarixl = $(EXELIST_atari) # -------------------------------------------------------------------------- -# Rules to make the binaries +# Rules to make the binaries and the disk all: -samples: $(EXELIST) +samples: $(EXELIST_$(SYS)) + +disk: $(DISK_$(SYS)) # -------------------------------------------------------------------------- # Overlay rules. Overlays need special ld65 configuration files. Also, the # overlay file-names are shortenned to fit the Atari's 8.3-character limit. multdemo: multidemo.o - $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB) + $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(SYS).lib ovrldemo: overlaydemo.o - $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB) + $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(SYS).lib OVERLAYLIST := $(foreach I,1 2 3,multdemo.$I ovrldemo.$I) @@ -140,8 +169,6 @@ OVERLAYLIST := $(foreach I,1 2 3,multdemo.$I ovrldemo.$I) # Rule to make a CBM disk with all samples. Needs the c1541 program that comes # with the VICE emulator. -d64: samples.d64 - define D64_WRITE_recipe $(C1541) -attach $@ -write $(file) $(notdir $(file)) >$(NULLDEV) @@ -150,9 +177,55 @@ endef # D64_WRITE_recipe samples.d64: samples @$(C1541) -format samples,AA d64 $@ >$(NULLDEV) - $(foreach file,$(EXELIST),$(D64_WRITE_recipe)) + $(foreach file,$(EXELIST_$(SYS)),$(D64_WRITE_recipe)) $(foreach file,$(OVERLAYLIST),$(D64_WRITE_recipe)) - $(foreach file,$(TGI) $(MOUS),$(D64_WRITE_recipe)) + $(foreach file,$(EMD) $(MOU) $(TGI),$(D64_WRITE_recipe)) + +# -------------------------------------------------------------------------- +# Rule to make an Apple II disk with all samples. Needs the Apple Commander +# program available at http://applecommander.sourceforge.net/ and a template +# disk named 'prodos.dsk'. + +define DSK_WRITE_BIN_recipe + +$(if $(findstring BF00,$(LDFLAGS_$(notdir $(file))_$(SYS))), \ + java -jar $(AC) -p $@ $(notdir $(file)).system sys <$(TARGET_PATH)/$(SYS)/util/loader.system) +java -jar $(AC) -cc65 $@ $(notdir $(file)) bin <$(file) + +endef # DSK_WRITE_BIN_recipe + +define DSK_WRITE_REL_recipe + +java -jar $(AC) -p $@ $(notdir $(file)) rel 0 <$(file) + +endef # DSK_WRITE_REL_recipe + +samples.dsk: samples + cp prodos.dsk $@ + $(foreach file,$(EXELIST_$(SYS)),$(DSK_WRITE_BIN_recipe)) + $(foreach file,$(OVERLAYLIST),$(DSK_WRITE_REL_recipe)) + $(foreach file,$(EMD) $(MOU) $(TGI),$(DSK_WRITE_REL_recipe)) + +# -------------------------------------------------------------------------- +# Rule to make an Atari disk with all samples. Needs the dir2atr program +# available at http://www.horus.com/~hias/atari/ and the MyDos4534 variant +# of dos.sys and dup.sys. + +define ATR_WRITE_recipe + +cp $(file) atr/$(notdir $(file)) + +endef # ATR_WRITE_recipe + +samples.atr: samples + @mkdir atr + cp dos.sys atr/dos.sys + cp dup.sys atr/dup.sys + @$(foreach file,$(EXELIST_$(SYS)),$(ATR_WRITE_recipe)) + @$(foreach file,$(OVERLAYLIST),$(ATR_WRITE_recipe)) + @$(foreach file,$(EMD) $(MOU) $(TGI),$(ATR_WRITE_recipe)) + $(DIR2ATR) -d -b MyDos4534 3200 $@ atr + @$(RMDIR) atr # -------------------------------------------------------------------------- # Installation rules @@ -184,5 +257,5 @@ mostlyclean: @$(DEL) *.map *.o *.s 2>$(NULLDEV) clean: mostlyclean - @$(DEL) $(EXELIST) samples.d64 2>$(NULLDEV) + @$(DEL) $(EXELIST_$(SYS)) $(DISK_$(SYS)) 2>$(NULLDEV) @$(DEL) multdemo.? ovrldemo.? 2>$(NULLDEV) From 2ef43e425adf3834e4fb7b768dbba5e8d6c282ec Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Jun 2016 01:39:27 +0200 Subject: [PATCH 110/407] Adjusted to recent change. --- samples/README | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/samples/README b/samples/README index edd06ff02..b7476e354 100644 --- a/samples/README +++ b/samples/README @@ -7,14 +7,13 @@ the supported platforms. Please note: * The supplied makefile needs GNU make. It works out of the box on Linux - and similar systems. If you're using Windows, you will have to compile - the programs manually. + and similar systems. If you're using Windows, consider installing Cygwin. - * The makefile specifies the C64 as the default target platform, because all - but one - of the programs run on this platform. When compiling for another platform, - you will have to change the line that specifies the target system at the - top of the makefile. + * The makefile specifies the C64 as the default target system, because all + but one of the programs run on this platform. When compiling for another + system, you will have to change the line that specifies the target system + at the top of the makefile or specify the system with SYS=<target> on the + make command line. List of supplied sample programs: From e47485f925375978cc95cd3ceaec1ba1a7bbd96a Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Jun 2016 15:03:20 +0200 Subject: [PATCH 111/407] Added CONIO cursor support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For quite some time I deliberately didn't add cursor support to the Apple II CONIO imöplementation. I consider it inappropriate to increase the size of cgetc() unduly for a rather seldom used feature. There's no hardware cursor on the Apple II so displaying a cursor during keyboard input means reading the character stored at the cursor location, writing the cursor character, reading the keyboard and finally writing back the character read initially. The naive approach is to reuse the part of cputc() that determines the memory location of the character at the cursor position in order to read the character stored there. However that means to add at least one additional JSR / RTS pair to cputc() adding 4 bytes and 12 cycles :-( Apart from that this approach means still a "too" large cgetc(). The approach implemented instead is to include all functionality required by cgetc() into cputc() - which is to read the current character before writing a new one. This may seem surprising at first glance but an LDA(),Y / TAX sequence adds only 3 bytes and 7 cycles so it cheaper than the JSR / RTS pair and allows to brings down the code increase in cgetc() down to a reasonable value. However so far the internal cputc() code in question saved the X register. Now it uses the X register to return the old character present before writing the new character for cgetc(). This requires some rather small adjustments in other functions using that internal cputc() code. --- doc/apple2.sgml | 4 ---- doc/apple2enh.sgml | 4 ---- libsrc/apple2/cgetc.s | 38 +++++++++++++++++++++++++++++++------- libsrc/apple2/chline.s | 7 ++++--- libsrc/apple2/cputc.s | 30 +++++++++++++++++------------- libsrc/apple2/cvline.s | 7 ++++--- libsrc/apple2/textframe.s | 8 ++++---- 7 files changed, 60 insertions(+), 38 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 00cd565b4..d0405b6de 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -449,10 +449,6 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3: The Apple ][ has no color text mode. Therefore the functions textcolor(), bgcolor() and bordercolor() have no effect. - <tag/Cursor/ - The Apple ][ has no hardware cursor. Therefore the function cursor() has - no effect. - </descrip><p> diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 7c17c24f2..b5231b4cd 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -450,10 +450,6 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3: The enhanced Apple //e has no color text mode. Therefore the functions textcolor(), bgcolor() and bordercolor() have no effect. - <tag/Cursor/ - The enhanced Apple //e has no hardware cursor. Therefore the function - cursor() has no effect. - </descrip><p> diff --git a/libsrc/apple2/cgetc.s b/libsrc/apple2/cgetc.s index 511e434df..b1bda8b91 100644 --- a/libsrc/apple2/cgetc.s +++ b/libsrc/apple2/cgetc.s @@ -6,20 +6,44 @@ ; If open_apple key is pressed then the high-bit of the key is set. ; - .export _cgetc + .export _cgetc + .import cursor, putchardirect - .include "apple2.inc" + .include "apple2.inc" _cgetc: - lda KBD - bpl _cgetc ; If < 128, no key pressed + ; Cursor on ? + lda cursor + beq :+ - ; At this time, the high bit of the key pressed is set - bit KBDSTRB ; Clear keyboard strobe + ; Show caret. + .ifdef __APPLE2ENH__ + lda #$7F | $80 ; Checkerboard, screen code + .else + lda #' ' | $40 ; Blank, flashing + .endif + jsr putchardirect ; Returns old character in X + + ; Wait for keyboard strobe. +: lda KBD + bpl :- ; If < 128, no key pressed + + ; Cursor on ? + ldy cursor + beq :+ + + ; Restore old character. + pha + txa + jsr putchardirect + pla + + ; At this time, the high bit of the key pressed is set. +: bit KBDSTRB ; Clear keyboard strobe .ifdef __APPLE2ENH__ bit BUTN0 ; Check if OpenApple is down bmi done .endif and #$7F ; If not down, then clear high bit -done: ldx #$00 +done: ldx #>$0000 rts diff --git a/libsrc/apple2/chline.s b/libsrc/apple2/chline.s index 6cf77de1b..ca1ee707c 100644 --- a/libsrc/apple2/chline.s +++ b/libsrc/apple2/chline.s @@ -26,11 +26,12 @@ _chline: ldx #'-' | $80 ; Horizontal line, screen code chlinedirect: + stx tmp1 cmp #$00 ; Is the length zero? beq done ; Jump if done - sta tmp1 -: txa ; Screen code + sta tmp2 +: lda tmp1 ; Screen code jsr cputdirect ; Direct output - dec tmp1 + dec tmp2 bne :- done: rts diff --git a/libsrc/apple2/cputc.s b/libsrc/apple2/cputc.s index 6607c6178..6f610fe92 100644 --- a/libsrc/apple2/cputc.s +++ b/libsrc/apple2/cputc.s @@ -9,7 +9,7 @@ .constructor initconio .endif .export _cputcxy, _cputc - .export cputdirect, newline, putchar + .export cputdirect, newline, putchar, putchardirect .import gotoxy, VTABZ .include "apple2.inc" @@ -62,32 +62,36 @@ newline: lda WNDTOP ; Goto top of screen sta CV : jmp VTABZ - + putchar: .ifdef __APPLE2ENH__ ldy INVFLG cpy #$FF ; Normal character display mode? - beq put + beq putchardirect cmp #$E0 ; Lowercase? bcc mask and #$7F ; Inverse lowercase - bra put + bra putchardirect .endif mask: and INVFLG ; Apply normal, inverse, flash -put: ldy CH + +putchardirect: + pha + ldy CH .ifdef __APPLE2ENH__ bit RD80VID ; In 80 column mode? - bpl col40 ; No, in 40 cols - pha + bpl put ; No, just go ahead tya lsr ; Div by 2 tay - pla - bcs col40 ; Odd cols go in 40 col memory + bcs put ; Odd cols go in main memory bit HISCR ; Assume SET80COL - sta (BASL),Y - bit LOWSCR ; Assume SET80COL - rts .endif -col40: sta (BASL),Y +put: lda (BASL),Y ; Get current character + tax ; Return old character for _cgetc + pla + sta (BASL),Y + .ifdef __APPLE2ENH__ + bit LOWSCR ; Doesn't hurt in 40 column mode + .endif rts diff --git a/libsrc/apple2/cvline.s b/libsrc/apple2/cvline.s index a26cc7063..c8ae1e269 100644 --- a/libsrc/apple2/cvline.s +++ b/libsrc/apple2/cvline.s @@ -23,12 +23,13 @@ _cvline: .endif cvlinedirect: + stx tmp1 cmp #$00 ; Is the length zero? beq done ; Jump if done - sta tmp1 -: txa ; Screen code + sta tmp2 +: lda tmp1 ; Screen code jsr putchar ; Write, no cursor advance jsr newline ; Advance cursor to next line - dec tmp1 + dec tmp2 bne :- done: rts diff --git a/libsrc/apple2/textframe.s b/libsrc/apple2/textframe.s index d5e9b80d7..55ac235b8 100644 --- a/libsrc/apple2/textframe.s +++ b/libsrc/apple2/textframe.s @@ -16,10 +16,10 @@ .include "zeropage.inc" .include "apple2.inc" -WIDTH = tmp2 -HEIGHT = tmp3 -XORIGIN = tmp4 -YORIGIN = ptr1 +WIDTH = ptr1 +HEIGHT = ptr1+1 +XORIGIN = ptr2 +YORIGIN = ptr2+1 _textframexy: sec From c9e9679a06afd86fe8caeb32177c11736b98a974 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Jun 2016 18:55:00 +0200 Subject: [PATCH 112/407] Improved doc and samples default target. The 'all' target deliberately doesn't build the doc nor the samples. But that doesn't mean that the Makefiles in the 'doc' and 'samples' directories must default to the (empty) 'all' target. --- doc/Makefile | 42 +++++++++++++++++++++--------------------- samples/Makefile | 9 +++++---- samples/README | 4 ++-- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 862164e1b..96a3ba59b 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -9,11 +9,9 @@ endif htmldir = $(prefix)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html infodir = $(prefix)/share/info -all mostlyclean: - ifdef CMD_EXE -clean install zip doc: +doc clean install zip: else # CMD_EXE @@ -26,6 +24,24 @@ TOC_LEVEL = 2 INSTALL = install +doc: html info + +html: $(addprefix ../html/,$(SGMLS:.sgml=.html) doc.css doc.png) + +info: $(addprefix ../info/,$(SGMLS:.sgml=.info)) + +../html ../info: + @mkdir $@ + +../html/%.html: %.sgml header.html | ../html + @cd ../html && linuxdoc -B html -s 0 -T $(TOC_LEVEL) -H ../doc/header.html ../doc/$< + +../html/doc.%: doc.% | ../html + cp $< ../html + +../info/%.info: %.sgml | ../info + @cd ../info && linuxdoc -B info ../doc/$< + clean: $(RM) -r ../html ../info @@ -45,22 +61,6 @@ ifneq "$(wildcard ../html)" "" @cd .. && zip cc65 html/*.* endif -doc: html info - -html: $(addprefix ../html/,$(SGMLS:.sgml=.html) doc.css doc.png) - -info: $(addprefix ../info/,$(SGMLS:.sgml=.info)) - -../html ../info: - @mkdir $@ - -../html/%.html: %.sgml header.html | ../html - @cd ../html && linuxdoc -B html -s 0 -T $(TOC_LEVEL) -H ../doc/header.html ../doc/$< - -../html/doc.%: doc.% | ../html - cp $< ../html - -../info/%.info: %.sgml | ../info - @cd ../info && linuxdoc -B info ../doc/$< - endif # CMD_EXE + +all mostlyclean: diff --git a/samples/Makefile b/samples/Makefile index bbf69c820..fc88d94b7 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -4,8 +4,9 @@ # This Makefile requires GNU make # -# Run 'make samples SYS=<target>' to build for another target system -SYS = c64 +# Run 'make SYS=<target>' or set a SYS env +# var to build for another target system. +SYS ?= c64 ifneq ($(shell echo),) CMD_EXE = 1 @@ -147,12 +148,12 @@ EXELIST_atarixl = $(EXELIST_atari) # -------------------------------------------------------------------------- # Rules to make the binaries and the disk -all: - samples: $(EXELIST_$(SYS)) disk: $(DISK_$(SYS)) +all: + # -------------------------------------------------------------------------- # Overlay rules. Overlays need special ld65 configuration files. Also, the # overlay file-names are shortenned to fit the Atari's 8.3-character limit. diff --git a/samples/README b/samples/README index b7476e354..a576c4032 100644 --- a/samples/README +++ b/samples/README @@ -12,8 +12,8 @@ Please note: * The makefile specifies the C64 as the default target system, because all but one of the programs run on this platform. When compiling for another system, you will have to change the line that specifies the target system - at the top of the makefile or specify the system with SYS=<target> on the - make command line. + at the top of the makefile, specify the system with SYS=<target> on the + make command line or set a SYS env var. List of supplied sample programs: From 5d9f4dc89d01ba8f5907e2a99ef4111554058e45 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 19 Jun 2016 17:38:37 -0400 Subject: [PATCH 113/407] Made the overlay demo programs compile for CBM targets again. <conio.h> includes target-specific headers; so, we didn't bother to include <cbm.h> where it is needed. But, '#include <conio.h>' was removed from some files; so now, we must include <cbm.h> explicitly. --- samples/multidemo.c | 1 + samples/overlaydemo.c | 1 + 2 files changed, 2 insertions(+) diff --git a/samples/multidemo.c b/samples/multidemo.c index 038b74d64..396d7344a 100644 --- a/samples/multidemo.c +++ b/samples/multidemo.c @@ -20,6 +20,7 @@ #include <fcntl.h> #include <unistd.h> #else +#include <cbm.h> #include <device.h> #endif diff --git a/samples/overlaydemo.c b/samples/overlaydemo.c index a4dc53931..7553f3d0e 100644 --- a/samples/overlaydemo.c +++ b/samples/overlaydemo.c @@ -15,6 +15,7 @@ #include <fcntl.h> #include <unistd.h> #else +#include <cbm.h> #include <device.h> #endif From ab10bd401446b4a886d475a909e23f932e59abad Mon Sep 17 00:00:00 2001 From: Joni Lapilainen <joni.lapilainen@gmail.com> Date: Thu, 23 Jun 2016 15:41:03 +0300 Subject: [PATCH 114/407] Fix typo in samples makefile --- samples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index fc88d94b7..e7fdfd393 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -238,7 +238,7 @@ install: $(if $(prefix),,$(error variable `prefix' must be set)) $(INSTALL) -d $(DESTDIR)$(samplesdir) $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos - $(INSTALL) -d $$(DESTDIR)$(samplesdir)/tutorial + $(INSTALL) -d $(DESTDIR)$(samplesdir)/tutorial $(INSTALL) -m0644 *.* $(DESTDIR)$(samplesdir) $(INSTALL) -m0644 README $(DESTDIR)$(samplesdir) $(INSTALL) -m0644 Makefile $(DESTDIR)$(samplesdir) From 90b2f5aff86d1d22816831b4441f1c2aa482e726 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sat, 2 Jul 2016 10:26:33 -0400 Subject: [PATCH 115/407] Fixed some code that adjusts an index after a deletion from a collection. --- src/common/coll.c | 13 +++++++------ src/common/coll.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/common/coll.c b/src/common/coll.c index aa2aa6470..8fb702bdc 100644 --- a/src/common/coll.c +++ b/src/common/coll.c @@ -161,7 +161,7 @@ void CollAppend (Collection* C, void* Item) { /* Insert the item at the end of the current list */ CollInsert (C, Item, C->Count); -} +} #endif @@ -341,22 +341,23 @@ void CollReplaceExpand (Collection* C, void* Item, unsigned Index) void CollMove (Collection* C, unsigned OldIndex, unsigned NewIndex) /* Move an item from one position in the collection to another. OldIndex -** is the current position of the item, NewIndex is the new index after +** is the current position of the item, NewIndex is the new index before ** the function has done it's work. Existing entries with indices NewIndex -** and up are moved one position upwards. +** and up might be moved one position upwards. */ { - /* Get the item and remove it from the collection */ + /* Get the item; and, remove it from the collection */ void* Item = CollAt (C, OldIndex); + CollDelete (C, OldIndex); /* Correct NewIndex if needed */ - if (NewIndex >= OldIndex) { + if (NewIndex > OldIndex) { /* Position has changed with removal */ --NewIndex; } - /* Now insert it at the new position */ + /* Now, insert it at the new position */ CollInsert (C, Item, NewIndex); } diff --git a/src/common/coll.h b/src/common/coll.h index 5114862c4..99e337d7a 100644 --- a/src/common/coll.h +++ b/src/common/coll.h @@ -268,9 +268,9 @@ void CollReplaceExpand (Collection* C, void* Item, unsigned Index); void CollMove (Collection* C, unsigned OldIndex, unsigned NewIndex); /* Move an item from one position in the collection to another. OldIndex -** is the current position of the item, NewIndex is the new index after +** is the current position of the item, NewIndex is the new index before ** the function has done it's work. Existing entries with indices NewIndex -** and up are moved one position upwards. +** and up might be moved one position upwards. */ void CollMoveMultiple (Collection* C, unsigned Start, unsigned Count, unsigned Target); From 401478327523e9b99bc32f557a51230bfdcd1b36 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 3 Jul 2016 02:14:33 -0400 Subject: [PATCH 116/407] Made the samples Makefile run cl65 only when we want a disk image. That change avoids an error message when we "make clean" from the top-level make-file (it removes the tools before it cleans the samples). --- samples/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/Makefile b/samples/Makefile index e7fdfd393..00a9ce41d 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -34,6 +34,7 @@ else LD := $(if $(wildcard ../bin/ld65*),../bin/ld65,ld65) endif +ifneq ($(filter disk samples.%,$(MAKECMDGOALS)),) TARGET_PATH := $(shell $(CL) --print-target-path) EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*) @@ -54,6 +55,7 @@ DISK_apple2 = samples.dsk DISK_apple2enh = samples.dsk DISK_atari = samples.atr DISK_atarixl = samples.atr +endif # -------------------------------------------------------------------------- # System-dependent settings From a6eb7d076377db051e58d3656dd9e5adcb7f5c7d Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 3 Jul 2016 07:07:09 -0400 Subject: [PATCH 117/407] Fixed how ca65 handles some debug info from cc65. ca65 used to claim that an assembler error/warning was found on a C code line; and, that an Assembly line is only indirectly related to it. Now, ca65 says that the Assembly line has the problem; and, that the Assembly line was produced from the C line. --- src/ca65/error.c | 2 +- src/ca65/lineinfo.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ca65/error.c b/src/ca65/error.c index 38195d669..69446b3fc 100644 --- a/src/ca65/error.c +++ b/src/ca65/error.c @@ -144,7 +144,7 @@ static void AddNotifications (const Collection* LineInfos) break; case LI_TYPE_EXT: - Msg = "Assembler code generated from this line"; + Msg = "Assembly code generated from this line"; break; case LI_TYPE_MACRO: diff --git a/src/ca65/lineinfo.c b/src/ca65/lineinfo.c index 92fecec58..e6707dac4 100644 --- a/src/ca65/lineinfo.c +++ b/src/ca65/lineinfo.c @@ -368,6 +368,14 @@ void NewAsmLine (void) /* Start a new line using the current line info */ AsmLineInfo = StartLine (&CurTok.Pos, LI_TYPE_ASM, 0); + + /* If the first LineInfo in the list came from a .dbg line, then we want + ** errors and warnings to show it as an additional note, not as the primary + ** line. Therefore, swap the first two LineInfo items. + */ + if (GetLineInfoType (CollAtUnchecked (&CurLineInfo, 0)) == LI_TYPE_EXT) { + CollMove (&CurLineInfo, 1, 0); + } } From 97b517a8923e028ba06b4aab3e98aa2fd8d627f1 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 5 Jul 2016 17:07:39 +0200 Subject: [PATCH 118/407] sim65: add command line parameter to print number of CPU cycles at exit --- doc/sim65.sgml | 11 ++++++++++- src/sim65/6502.c | 2 ++ src/sim65/6502.h | 2 ++ src/sim65/main.c | 18 +++++++++++++++++- src/sim65/paravirt.c | 3 +++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index 24b43831c..a2ebbac25 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -4,7 +4,7 @@ <title>sim65 Users Guide <author><url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal"> -<date>2016-01-05 +<date>2016-07-05 <abstract> sim65 is a simulator for 6502 and 65C02 CPUs. It allows to test target @@ -31,12 +31,14 @@ The simulator is called as follows: Usage: sim65 [options] file [arguments] Short options: -h Help (this text) + -c Print amount of executed CPU cycles -v Increase verbosity -V Print the simulator version number -x <num> Exit simulator after <num> cycles Long options: --help Help (this text) + --cycles Print amount of executed CPU cycles --verbose Increase verbosity --version Print the simulator version number </verb></tscreen> @@ -53,6 +55,13 @@ Here is a description of all the command line options: Print the short option summary shown above. + <tag><tt>-c, --cycles</tt></tag> + + Print the number of executed CPU cycles when the program terminates. + The cycles for the final "<tt>jmp exit</tt>" are not included in this + count. + + <tag><tt>-v, --verbose</tt></tag> Increase the simulator verbosity. diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 312eb2fe1..e6f358295 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -67,6 +67,8 @@ static unsigned HaveNMIRequest; /* IRQ request active */ static unsigned HaveIRQRequest; +/* flag to print cycles at program termination */ +int PrintCycles; /*****************************************************************************/ diff --git a/src/sim65/6502.h b/src/sim65/6502.h index 2cf2d4f1e..f8e894567 100644 --- a/src/sim65/6502.h +++ b/src/sim65/6502.h @@ -99,6 +99,8 @@ unsigned ExecuteInsn (void); unsigned long GetCycles (void); /* Return the total number of clock cycles executed */ +extern int PrintCycles; +/* flag to print cycles at program termination */ /* End of 6502.h */ diff --git a/src/sim65/main.c b/src/sim65/main.c index dab9b0be8..5405af29f 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -61,7 +61,7 @@ const char* ProgramFile; /* exit simulator after MaxCycles Cycles */ -unsigned long MaxCycles = 0; +unsigned long MaxCycles; /*****************************************************************************/ /* Code */ @@ -74,12 +74,14 @@ static void Usage (void) printf ("Usage: %s [options] file [arguments]\n" "Short options:\n" " -h\t\t\tHelp (this text)\n" + " -c\t\t\tPrint amount of executed CPU cycles\n" " -v\t\t\tIncrease verbosity\n" " -V\t\t\tPrint the simulator version number\n" " -x <num>\t\tExit simulator after <num> cycles\n" "\n" "Long options:\n" " --help\t\tHelp (this text)\n" + " --cycles\t\tPrint amount of executed CPU cycles\n" " --verbose\t\tIncrease verbosity\n" " --version\t\tPrint the simulator version number\n", ProgName); @@ -106,6 +108,15 @@ static void OptVerbose (const char* Opt attribute ((unused)), +static void OptCycles (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Set flag to print amount of cycles at the end */ +{ + PrintCycles = 1; +} + + + static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the simulator version */ @@ -166,6 +177,7 @@ int main (int argc, char* argv[]) /* Program long options */ static const LongOpt OptTab[] = { { "--help", 0, OptHelp }, + { "--cycles", 0, OptCycles }, { "--verbose", 0, OptVerbose }, { "--version", 0, OptVersion }, }; @@ -196,6 +208,10 @@ int main (int argc, char* argv[]) OptHelp (Arg, 0); break; + case 'c': + OptCycles (Arg, 0); + break; + case 'v': OptVerbose (Arg, 0); break; diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index 56211b5c1..f4fc3e285 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -156,6 +156,9 @@ static void PVArgs (CPURegs* Regs) static void PVExit (CPURegs* Regs) { Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC); + if (PrintCycles) { + Print (stdout, 0, "%lu cycles\n", GetCycles ()); + } exit (Regs->AC); } From 85d755f2140afe67db35cd2e317c0e2ecb92b4ad Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 5 Jul 2016 17:10:10 +0200 Subject: [PATCH 119/407] fix indentation --- src/sim65/paravirt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index f4fc3e285..a13c670a2 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -157,7 +157,7 @@ static void PVExit (CPURegs* Regs) { Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC); if (PrintCycles) { - Print (stdout, 0, "%lu cycles\n", GetCycles ()); + Print (stdout, 0, "%lu cycles\n", GetCycles ()); } exit (Regs->AC); From c2945bf1ff2a0faf48af0733e14fb0315f0cff5e Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 10 Jul 2016 04:11:07 -0400 Subject: [PATCH 120/407] Made the zlib's inflatemem()'s source file use enhanced instructions for all 65SC02-compatible CPUs (not only the 65C02). --- libsrc/zlib/inflatemem.s | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libsrc/zlib/inflatemem.s b/libsrc/zlib/inflatemem.s index bcf473bdd..2a0e75e8e 100644 --- a/libsrc/zlib/inflatemem.s +++ b/libsrc/zlib/inflatemem.s @@ -9,6 +9,8 @@ .import incsp2 .importzp sp, sreg, ptr1, ptr2, ptr3, ptr4, tmp1 + .macpack cpu + ; -------------------------------------------------------------------------- ; ; Constants @@ -75,7 +77,7 @@ _inflatemem: sta inputPointer stx inputPointer+1 ; outputPointer = dest -.ifpc02 +.if (.cpu & CPU_ISET_65SC02) lda (sp) ldy #1 .else @@ -106,7 +108,7 @@ inflatemem_1: ; return outputPointer - dest; lda outputPointer -.ifpc02 +.if (.cpu & CPU_ISET_65SC02) sbc (sp) ; C flag is set ldy #1 .else @@ -156,14 +158,14 @@ inflateCopyBlock: moveBlock: ldy moveBlock_len beq moveBlock_1 -.ifpc02 +.if (.cpu & CPU_ISET_65SC02) .else ldy #0 .endif inc moveBlock_len+1 moveBlock_1: lda (0,x) -.ifpc02 +.if (.cpu & CPU_ISET_65SC02) sta (outputPointer) .else sta (outputPointer),y @@ -176,7 +178,7 @@ moveBlock_2: bne moveBlock_3 inc outputPointer+1 moveBlock_3: -.ifpc02 +.if (.cpu & CPU_ISET_65SC02) dey .else dec moveBlock_len @@ -312,7 +314,7 @@ inflateCodes_1: jsr fetchPrimaryCode bcs inflateCodes_2 ; Literal code -.ifpc02 +.if (.cpu & CPU_ISET_65SC02) sta (outputPointer) .else ldy #0 @@ -512,7 +514,7 @@ getValue: getBits: cpx #0 beq getBits_ret -.ifpc02 +.if (.cpu & CPU_ISET_65SC02) stz getBits_tmp dec getBits_tmp .else @@ -542,7 +544,7 @@ getBit: lsr getBit_hold bne getBit_ret pha -.ifpc02 +.if (.cpu & CPU_ISET_65SC02) lda (inputPointer) .else sty getBit_hold @@ -554,7 +556,7 @@ getBit: bne getBit_1 inc inputPointer+1 getBit_1: - ror a ; C flag is set + ror a ; (C flag was set) sta getBit_hold pla getBit_ret: @@ -668,6 +670,3 @@ bitsPointer_h: ; Sorted codes. sortedCodes: .res 256+1+29+30+2 - - - From 32d000fb4cfa292ee34dfb8dc025518be145cf9d Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Mon, 11 Jul 2016 20:48:47 -0400 Subject: [PATCH 121/407] Fix broken rand() implementation. The high 8 bits were unused, reducing it to a 24-bit implementation (while still doing all the work for a 32-bit one). The best entropy is in the unused high byte, returning these bits in A instead of bits 8-15, which had considerably lower entropy (i.e. rand() & 255 was effectively a 16-bit LCG). --- libsrc/common/rand.s | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libsrc/common/rand.s b/libsrc/common/rand.s index 48a88b7c4..8ad7bcdb4 100644 --- a/libsrc/common/rand.s +++ b/libsrc/common/rand.s @@ -44,7 +44,6 @@ _rand: clc lda rand+1 adc #$59 sta rand+1 - pha lda rand+2 adc #$41 sta rand+2 @@ -53,8 +52,7 @@ _rand: clc lda rand+3 adc #$31 sta rand+3 - pla ; return bit 8-22 in (X,A) - rts + rts ; return bit (16-22,24-31) in (X,A) _srand: sta rand+0 ; Store the seed stx rand+1 From e7e65044e607f15b7d5b4e55abf7cdcb123993a8 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 19 Jul 2016 10:42:49 -0400 Subject: [PATCH 122/407] Used more mundane addressing in some of the instructions in "zlib/inflatemem.s". That avoids conflicts with ca65's future .setdp feature. --- libsrc/zlib/inflatemem.s | 41 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/libsrc/zlib/inflatemem.s b/libsrc/zlib/inflatemem.s index 2a0e75e8e..ea550c074 100644 --- a/libsrc/zlib/inflatemem.s +++ b/libsrc/zlib/inflatemem.s @@ -1,5 +1,6 @@ ; -; Piotr Fusik, 21.09.2003 +; 2003-09-21, Piotr Fusik +; 2016-07-19, Greg King ; ; unsigned __fastcall__ inflatemem (char* dest, const char* source); ; @@ -40,30 +41,30 @@ TREES_SIZE = 2*MAX_BITS ; ; Pointer to the compressed data. -inputPointer = ptr1 ; 2 bytes +inputPointer := ptr1 ; 2 bytes ; Pointer to the uncompressed data. -outputPointer = ptr2 ; 2 bytes +outputPointer := ptr2 ; 2 bytes ; Local variables. ; As far as there is no conflict, same memory locations are used ; for different variables. -inflateDynamicBlock_cnt = ptr3 ; 1 byte -inflateCodes_src = ptr3 ; 2 bytes -buildHuffmanTree_src = ptr3 ; 2 bytes -getNextLength_last = ptr3 ; 1 byte -getNextLength_index = ptr3+1 ; 1 byte +inflateDynamicBlock_cnt := ptr3 ; 1 byte +inflateCodes_src := ptr3 ; 2 bytes +buildHuffmanTree_src := ptr3 ; 2 bytes +getNextLength_last := ptr3 ; 1 byte +getNextLength_index := ptr3+1 ; 1 byte -buildHuffmanTree_ptr = ptr4 ; 2 bytes -fetchCode_ptr = ptr4 ; 2 bytes -getBits_tmp = ptr4 ; 1 byte +buildHuffmanTree_ptr := ptr4 ; 2 bytes +fetchCode_ptr := ptr4 ; 2 bytes +getBits_tmp := ptr4 ; 1 byte -moveBlock_len = sreg ; 2 bytes -inflateDynamicBlock_np = sreg ; 1 byte -inflateDynamicBlock_nd = sreg+1 ; 1 byte +moveBlock_len := sreg ; 2 bytes +inflateDynamicBlock_np := sreg ; 1 byte +inflateDynamicBlock_nd := sreg+1 ; 1 byte -getBit_hold = tmp1 ; 1 byte +getBit_hold := tmp1 ; 1 byte ; -------------------------------------------------------------------------- @@ -138,8 +139,8 @@ inflateCopyBlock: ldy #1 sty getBit_hold ; Get 16-bit length - ldx #inputPointer - lda (0,x) + ldx #0 + lda (inputPointer,x) sta moveBlock_len lda (inputPointer),y sta moveBlock_len+1 @@ -164,15 +165,15 @@ moveBlock: .endif inc moveBlock_len+1 moveBlock_1: - lda (0,x) + lda (inputPointer,x) .if (.cpu & CPU_ISET_65SC02) sta (outputPointer) .else sta (outputPointer),y .endif - inc 0,x + inc inputPointer bne moveBlock_2 - inc 1,x + inc inputPointer+1 moveBlock_2: inc outputPointer bne moveBlock_3 From 8f0146f14ad539da109d64ba5535ebe211c67e6c Mon Sep 17 00:00:00 2001 From: "David M. Lloyd" <david.lloyd@redhat.com> Date: Thu, 28 Jul 2016 11:43:52 -0500 Subject: [PATCH 123/407] Add missing WDC instructions --- src/ca65/instr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ca65/instr.c b/src/ca65/instr.c index 500db1985..966a5cd98 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -376,7 +376,7 @@ static const struct { /* Instruction table for the 65C02 */ static const struct { unsigned Count; - InsDesc Ins[98]; + InsDesc Ins[100]; } InsTab65C02 = { sizeof (InsTab65C02.Ins) / sizeof (InsTab65C02.Ins[0]), { @@ -467,6 +467,7 @@ static const struct { { "SMB6", 0x0000004, 0xE7, 1, PutAll }, { "SMB7", 0x0000004, 0xF7, 1, PutAll }, { "STA", 0x000A66C, 0x80, 0, PutAll }, + { "STP", 0x0000001, 0xdb, 0, PutAll }, { "STX", 0x000010c, 0x82, 1, PutAll }, { "STY", 0x000002c, 0x80, 1, PutAll }, { "STZ", 0x000006c, 0x04, 5, PutAll }, @@ -477,7 +478,8 @@ static const struct { { "TSX", 0x0000001, 0xba, 0, PutAll }, { "TXA", 0x0000001, 0x8a, 0, PutAll }, { "TXS", 0x0000001, 0x9a, 0, PutAll }, - { "TYA", 0x0000001, 0x98, 0, PutAll } + { "TYA", 0x0000001, 0x98, 0, PutAll }, + { "WAI", 0x0000001, 0xcb, 0, PutAll } } }; From 9accf983e1ceb4635493b72ed0971deeba31e2d0 Mon Sep 17 00:00:00 2001 From: Chris Cacciatore <chris.cacciatore@gmail.com> Date: Tue, 2 Aug 2016 11:31:09 -0700 Subject: [PATCH 124/407] Reporting sym name for incompatible pointer types. --- src/cc65/typeconv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/typeconv.c b/src/cc65/typeconv.c index e4edd6a2e..78f43a50c 100644 --- a/src/cc65/typeconv.c +++ b/src/cc65/typeconv.c @@ -237,7 +237,7 @@ void TypeConversion (ExprDesc* Expr, Type* NewType) switch (TypeCmp (NewType, Expr->Type)) { case TC_INCOMPATIBLE: - Error ("Incompatible pointer types"); + Error ("Incompatible pointer types at '%s'", (!Expr->Sym? Expr->Sym->Name : "Unknown")); break; case TC_QUAL_DIFF: From 33b1d82791fde5e8e06bc2c06d276a4d0fafdcbb Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 2 Aug 2016 16:38:39 -0400 Subject: [PATCH 125/407] Added the WDC65c02S WAI and STP mnemonics to the disassembler. --- src/da65/opc65c02.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/da65/opc65c02.c b/src/da65/opc65c02.c index 00520e729..1351f5eee 100644 --- a/src/da65/opc65c02.c +++ b/src/da65/opc65c02.c @@ -250,7 +250,7 @@ const OpcDesc OpcTable_65C02[256] = { { "iny", 1, flNone, OH_Implicit }, /* $c8 */ { "cmp", 2, flNone, OH_Immediate }, /* $c9 */ { "dex", 1, flNone, OH_Implicit }, /* $ca */ - { "", 1, flIllegal, OH_Illegal, }, /* $cb */ + { "wai", 1, flNone, OH_Implicit }, /* $cb */ { "cpy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cc */ { "cmp", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cd */ { "dec", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ce */ @@ -266,7 +266,7 @@ const OpcDesc OpcTable_65C02[256] = { { "cld", 1, flNone, OH_Implicit }, /* $d8 */ { "cmp", 3, flUseLabel, OH_AbsoluteY }, /* $d9 */ { "phx", 1, flNone, OH_Implicit }, /* $da */ - { "", 1, flIllegal, OH_Illegal, }, /* $db */ + { "stp", 1, flNone, OH_Implicit }, /* $db */ { "", 1, flIllegal, OH_Illegal, }, /* $dc */ { "cmp", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $dd */ { "dec", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $de */ From 2c03b9a1bc0dd722d6e56b488a0e3289ecfb795f Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 7 Aug 2016 15:47:45 -0400 Subject: [PATCH 126/407] Added C-code interfaces for the CBM Kernal functions SCNKEY and UDTIM. --- doc/funcref.sgml | 71 +++++++++++++++++++++++++++++++++++++----- include/cbm.h | 2 ++ libsrc/cbm/c_scnkey.s | 8 +++++ libsrc/cbm/c_udtim.s | 8 +++++ libsrc/plus4/kscnkey.s | 19 +++++++++++ libsrc/plus4/kudtim.s | 19 +++++++++++ 6 files changed, 119 insertions(+), 8 deletions(-) create mode 100644 libsrc/cbm/c_scnkey.s create mode 100644 libsrc/cbm/c_udtim.s create mode 100644 libsrc/plus4/kscnkey.s create mode 100644 libsrc/plus4/kudtim.s diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 64e519238..d4c2f3fe1 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -3,7 +3,7 @@ <article> <title>cc65 function reference <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>2016-06-08 +<date>2016-08-07 <abstract> cc65 is a C compiler for 6502 based systems. This function reference describes @@ -169,8 +169,11 @@ function. <item><ref id="cbm_k_open" name="cbm_k_open"> <item><ref id="cbm_k_readst" name="cbm_k_readst"> <item><ref id="cbm_k_save" name="cbm_k_save"> +<item><ref id="cbm_k_scnkey" name="cbm_k_scnkey"> <item><ref id="cbm_k_setlfs" name="cbm_k_setlfs"> <item><ref id="cbm_k_setnam" name="cbm_k_setnam"> +<item><ref id="cbm_k_talk" name="cbm_k_talk"> +<item><ref id="cbm_k_udtim" name="cbm_k_udtim"> <item><ref id="cbm_k_unlsn" name="cbm_k_unlsn"> <!-- <item><ref id="cbm_load" name="cbm_load"> --> <!-- <item><ref id="cbm_open" name="cbm_open"> --> @@ -2020,6 +2023,31 @@ only be used in presence of a prototype. </quote> +<sect1>cbm_k_scnkey<label id="cbm_k_scnkey"><p> + +<quote> +<descrip> +<tag/Function/Scan the keyboard matrix. +<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ +<tag/Declaration/<tt/void cbm_k_scnkey (void);/ +<tag/Description/This function looks at the switches in the keyboard, to see +if any of them are being pressed. If they are, then code numbers for them are +stored in RAM. Other functions use those numbers to input text. Normally, +the keyboard is scanned by the Kernal's Interrupt Service Routine. But, if +you divert the "Jiffy interrupt" to a C-code ISR, then that ISR must call this +function, in order to provide input from the keyboard. +<tag/Availability/cc65 +<tag/See also/ +<ref id="cbm_k_getin" name="cbm_k_getin">, +<ref id="cbm_k_udtim" name="cbm_k_udtim">, +<ref id="cgetc" name="cgetc">, +<!-- <ref id="getc" name="getc"> --> +<!-- <ref id="getchar" name="getchar"> --> +<tag/Example/None. +</descrip> +</quote> + + <sect1>cbm_k_setlfs<label id="cbm_k_setlfs"><p> <quote> @@ -2085,6 +2113,27 @@ only be used in presence of a prototype. </quote> +<sect1>cbm_k_udtim<label id="cbm_k_udtim"><p> + +<quote> +<descrip> +<tag/Function/Update the Jiffy clock. +<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/ +<tag/Declaration/<tt/void cbm_k_udtim (void);/ +<tag/Description/This function adds one count to the Jiffy clock. That clock +counts sixtieths of a second. It is used by the library's <tt/clock()/ +function. Normally, the Jiffy clock is updated by the Kernal's Interrupt +Service Routine. But, if you divert the "Jiffy interrupt" to a C-code ISR, +then that ISR must call this function, in order to keep the clock valid. +<tag/Availability/cc65 +<tag/See also/ +<ref id="cbm_k_scnkey" name="cbm_k_scnkey">, +<ref id="clock" name="clock"> +<tag/Example/None. +</descrip> +</quote> + + <sect1>cbm_k_unlsn<label id="cbm_k_unlsn"><p> <quote> @@ -2164,15 +2213,18 @@ only be used in presence of a prototype. <tag/Header/<tt/<ref id="conio.h" name="conio.h">/ <tag/Declaration/<tt/char cgetc (void);/ <tag/Description/The function reads a character from the keyboard. If there is -no character available, <tt/cgetc/ waits until the user presses a key. If the +no character available, <tt/cgetc()/ waits until the user presses a key. If the cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is displayed while waiting. <tag/Notes/<itemize> -<item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key -from this buffer and wait only if the buffer is empty. +<item>If the system supports a keyboard buffer, <tt/cgetc()/ will fetch a key +from that buffer; and, wait only if the buffer is empty. +<item>The keyboard must be scanned periodically, in order for this function to +see anything that you type. (See the description of <tt/cbm_k_scnkey()/.) </itemize> <tag/Availability/cc65 <tag/See also/ +<ref id="cbm_k_scnkey" name="cbm_k_scnkey">, <ref id="cursor" name="cursor">, <ref id="kbhit" name="kbhit"> <tag/Example/None. @@ -2262,16 +2314,19 @@ used in presence of a prototype. <tag/Header/<tt/<ref id="time.h" name="time.h">/ <tag/Declaration/<tt/clock_t clock (void);/ <tag/Description/The <tt/clock/ function returns an approximaton of processor -time used by the program. The time is returned in implementation defined +time used by the program. The time is returned in implementation-defined units. It can be converted to seconds by dividing by the value of the macro <tt/CLOCKS_PER_SEC/. <tag/Notes/<itemize> -<item>Since the machines, cc65 generated programs run on, cannot run multiple -processes, the function will actually return the time since some -implementation defined point in the past. +<item>Since the machines that cc65-generated programs run on cannot run multiple +processes, the function actually will return the time since some +implementation-defined point in the past. +<item>The Jiffy clock must be "running", in order for this function to return +changing values. (See the description of <tt/cbm_k_udtim()/.) </itemize> <tag/Availability/ISO 9899 <tag/See also/ +<ref id="cbm_k_udtim" name="cbm_k_udtim">, <ref id="time" name="time"> <tag/Example/None. </descrip> diff --git a/include/cbm.h b/include/cbm.h index 701924d57..241d70a6e 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -187,10 +187,12 @@ unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr); unsigned char cbm_k_open (void); unsigned char cbm_k_readst (void); unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end); +void cbm_k_scnkey (void); void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA); void __fastcall__ cbm_k_setnam (const char* Name); void __fastcall__ cbm_k_talk (unsigned char dev); +void cbm_k_udtim (void); void cbm_k_unlsn (void); diff --git a/libsrc/cbm/c_scnkey.s b/libsrc/cbm/c_scnkey.s new file mode 100644 index 000000000..cdae50e7b --- /dev/null +++ b/libsrc/cbm/c_scnkey.s @@ -0,0 +1,8 @@ +; +; 2016-08-07, Greg King +; +; void cbm_k_scnkey (void); +; + + .import SCNKEY + .export _cbm_k_scnkey := SCNKEY diff --git a/libsrc/cbm/c_udtim.s b/libsrc/cbm/c_udtim.s new file mode 100644 index 000000000..b867efaba --- /dev/null +++ b/libsrc/cbm/c_udtim.s @@ -0,0 +1,8 @@ +; +; 2016-08-07, Greg King +; +; void cbm_k_udtim (void); +; + + .import UDTIM + .export _cbm_k_udtim := UDTIM diff --git a/libsrc/plus4/kscnkey.s b/libsrc/plus4/kscnkey.s new file mode 100644 index 000000000..e7e2ab986 --- /dev/null +++ b/libsrc/plus4/kscnkey.s @@ -0,0 +1,19 @@ +; +; 2002-11-22, Ullrich von Bassewitz +; 2016-08-07, Greg King +; +; SCNKEY replacement function +; + + .export SCNKEY + + .include "plus4.inc" + +.segment "LOWCODE" ; Must go into low memory + +.proc SCNKEY + sta ENABLE_ROM ; Enable the ROM + jsr $FF9F ; Call the ROM routine + sta ENABLE_RAM ; Switch back to RAM + rts ; Return to caller +.endproc diff --git a/libsrc/plus4/kudtim.s b/libsrc/plus4/kudtim.s new file mode 100644 index 000000000..d35190788 --- /dev/null +++ b/libsrc/plus4/kudtim.s @@ -0,0 +1,19 @@ +; +; 2002-11-22, Ullrich von Bassewitz +; 2016-08-07, Greg King +; +; UDTIM replacement function +; + + .export UDTIM + + .include "plus4.inc" + +.segment "LOWCODE" ; Must go into low memory + +.proc UDTIM + sta ENABLE_ROM ; Enable the ROM + jsr $FFEA ; Call the ROM routine + sta ENABLE_RAM ; Switch back to RAM + rts ; Return to caller +.endproc From f9482a1b72c33becfdb0106bf06a1a66f29dd006 Mon Sep 17 00:00:00 2001 From: Chris Cacciatore <chris.cacciatore@gmail.com> Date: Tue, 9 Aug 2016 12:46:51 -0700 Subject: [PATCH 127/407] Fixed test negation. (#329) Fixed test negation. --- src/cc65/typeconv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/typeconv.c b/src/cc65/typeconv.c index 78f43a50c..47ab993c1 100644 --- a/src/cc65/typeconv.c +++ b/src/cc65/typeconv.c @@ -237,7 +237,7 @@ void TypeConversion (ExprDesc* Expr, Type* NewType) switch (TypeCmp (NewType, Expr->Type)) { case TC_INCOMPATIBLE: - Error ("Incompatible pointer types at '%s'", (!Expr->Sym? Expr->Sym->Name : "Unknown")); + Error ("Incompatible pointer types at '%s'", (Expr->Sym? Expr->Sym->Name : "Unknown")); break; case TC_QUAL_DIFF: From 22d1f1da1b481bafc7247f8e2531077a1cc34c20 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 10 Aug 2016 11:38:11 +0200 Subject: [PATCH 128/407] Minor style fix. --- samples/Makefile | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index 00a9ce41d..3a60798da 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -35,26 +35,26 @@ else endif ifneq ($(filter disk samples.%,$(MAKECMDGOALS)),) -TARGET_PATH := $(shell $(CL) --print-target-path) + TARGET_PATH := $(shell $(CL) --print-target-path) -EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*) -MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*) -TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*) + EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*) + MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*) + TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*) -# This one comes with VICE -C1541 ?= c1541 + # This one comes with VICE + C1541 ?= c1541 -# For this one see http://applecommander.sourceforge.net/ -AC ?= ac.jar + # For this one see http://applecommander.sourceforge.net/ + AC ?= ac.jar -# For this one see http://www.horus.com/~hias/atari/ -DIR2ATR ?= dir2atr + # For this one see http://www.horus.com/~hias/atari/ + DIR2ATR ?= dir2atr -DISK_c64 = samples.d64 -DISK_apple2 = samples.dsk -DISK_apple2enh = samples.dsk -DISK_atari = samples.atr -DISK_atarixl = samples.atr + DISK_c64 = samples.d64 + DISK_apple2 = samples.dsk + DISK_apple2enh = samples.dsk + DISK_atari = samples.atr + DISK_atarixl = samples.atr endif # -------------------------------------------------------------------------- From bad84121319ab4846de73b62e14b3cdcd19a9399 Mon Sep 17 00:00:00 2001 From: Chris Cacciatore <chris.cacciatore@gmail.com> Date: Thu, 11 Aug 2016 16:46:48 -0700 Subject: [PATCH 129/407] All programs print version and exit successfully. * All programs are now using the ProgName variable as well. --- src/ar65/main.c | 2 +- src/ca65/main.c | 3 ++- src/cc65/main.c | 2 +- src/chrcvt65/main.c | 1 + src/cl65/main.c | 3 ++- src/co65/main.c | 3 ++- src/da65/main.c | 3 ++- src/grc65/main.c | 3 ++- src/ld65/main.c | 3 ++- src/od65/main.c | 1 + src/sim65/main.c | 3 ++- src/sp65/main.c | 1 + 12 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/ar65/main.c b/src/ar65/main.c index 9b9097ea4..a1839bad2 100644 --- a/src/ar65/main.c +++ b/src/ar65/main.c @@ -121,7 +121,7 @@ int main (int argc, char* argv []) break; case 'V': - fprintf (stderr, "ar65 V%s\n", GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); break; default: diff --git a/src/ca65/main.c b/src/ca65/main.c index 0016c46f3..a67319747 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -619,7 +619,8 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the assembler version */ { - fprintf (stderr, "ca65 V%s\n", GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } diff --git a/src/cc65/main.c b/src/cc65/main.c index abe2af56e..afbec43d7 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -742,7 +742,7 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the compiler version */ { - fprintf (stderr, "cc65 V%s\n", GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); exit (EXIT_SUCCESS); } diff --git a/src/chrcvt65/main.c b/src/chrcvt65/main.c index 8685e06b9..7e7183e0a 100644 --- a/src/chrcvt65/main.c +++ b/src/chrcvt65/main.c @@ -220,6 +220,7 @@ static void OptVersion (const char* Opt attribute ((unused)), { fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } diff --git a/src/cl65/main.c b/src/cl65/main.c index 654bd97b2..7bdbe7a8a 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -1233,7 +1233,8 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print version number */ { - fprintf (stderr, "cl65 V%s\n", GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } diff --git a/src/co65/main.c b/src/co65/main.c index 5e0ee2ed7..43d263516 100644 --- a/src/co65/main.c +++ b/src/co65/main.c @@ -263,7 +263,8 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the assembler version */ { - fprintf (stderr, "co65 V%s\n", GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } diff --git a/src/da65/main.c b/src/da65/main.c index 8c37e1ae2..0b0bf19e7 100644 --- a/src/da65/main.c +++ b/src/da65/main.c @@ -340,7 +340,8 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the disassembler version */ { - fprintf (stderr, "da65 V%s\n", GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } diff --git a/src/grc65/main.c b/src/grc65/main.c index 1b417c64d..2a1fef953 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -166,7 +166,8 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the program version */ { - fprintf (stderr, "grc65 V%s\n", GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } diff --git a/src/ld65/main.c b/src/ld65/main.c index 95ed14396..74511a48a 100644 --- a/src/ld65/main.c +++ b/src/ld65/main.c @@ -543,7 +543,8 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the assembler version */ { - fprintf (stderr, "ld65 V%s\n", GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } diff --git a/src/od65/main.c b/src/od65/main.c index 802290ffd..2d23f4202 100644 --- a/src/od65/main.c +++ b/src/od65/main.c @@ -209,6 +209,7 @@ static void OptVersion (const char* Opt attribute ((unused)), /* Print the assembler version */ { fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } diff --git a/src/sim65/main.c b/src/sim65/main.c index 5405af29f..f7f73165a 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -121,7 +121,8 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the simulator version */ { - fprintf (stderr, "sim65 V%s\n", GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } static void OptQuitXIns (const char* Opt attribute ((unused)), diff --git a/src/sp65/main.c b/src/sp65/main.c index 32cc1b936..828a48fc8 100644 --- a/src/sp65/main.c +++ b/src/sp65/main.c @@ -286,6 +286,7 @@ static void OptVersion (const char* Opt attribute ((unused)), /* Print the assembler version */ { fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit(EXIT_SUCCESS); } From 7f4b14ee49464b32743159408ac23e02ca1e8c07 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sun, 14 Aug 2016 19:33:09 +0200 Subject: [PATCH 130/407] SMC macro fixes for changed .paramcount and byte overflow behavior --- asminc/smc.inc | 52 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/asminc/smc.inc b/asminc/smc.inc index 383417c3d..8a06f3222 100644 --- a/asminc/smc.inc +++ b/asminc/smc.inc @@ -1,7 +1,7 @@ ; smc.mac ; ca65 Macro-Pack for Self Modifying Code (SMC) ; -; (c) Christian Krüger, latest change: 09-Nov-2011 +; (c) Christian Krüger, latest change: 17-Jul-2016 ; ; This software is provided 'as-is', without any expressed or implied ; warranty. In no event will the authors be held liable for any damages @@ -53,7 +53,7 @@ _SMCDesignator: statement .endmacro .macro SMC_TransferOpcode label, opcode, register -.if .paramcount = 2 .or .match ({register}, a) +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) lda #opcode sta _SMCDesignator .elseif .match ({register}, x) @@ -62,44 +62,52 @@ _SMCDesignator: statement .elseif .match ({register}, y) ldy #opcode sty _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_TransferOpcode'" .endif .endmacro .macro SMC_LoadOpcode label, register -.if .paramcount = 1 .or .match ({register}, a) +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) lda _SMCDesignator .elseif .match ({register}, x) ldx _SMCDesignator .elseif .match ({register}, y) ldy _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_TransferOpcode'" .endif .endmacro .macro SMC_StoreOpcode label, register -.if .paramcount = 1 .or .match ({register}, a) +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) sta _SMCDesignator .elseif .match ({register}, x) stx _SMCDesignator .elseif .match ({register}, y) sty _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_StoreOpcode'" .endif .endmacro .macro SMC_ChangeBranch label, destination, register -.if .paramcount = 2 .or .match ({register}, a) - lda #(destination - _SMCDesignator -2) +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda #(<(destination - _SMCDesignator -2)) sta _SMCDesignator+1 .elseif .match ({register}, x) - ldx #(destination - _SMCDesignator - 2) + ldx #(<(destination - _SMCDesignator - 2)) stx _SMCDesignator+1 .elseif .match ({register}, y) - ldy #(destination - _SMCDesignator - 2) + ldy #(<(destination - _SMCDesignator - 2)) sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_ChangeBranch'" .endif .endmacro .macro SMC_TransferValue label, value, register -.if .paramcount = 2 .or .match ({register}, a) +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) lda value sta _SMCDesignator+1 .elseif .match ({register}, x) @@ -108,26 +116,32 @@ _SMCDesignator: statement .elseif .match ({register}, y) ldy value sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_TransferValue'" .endif .endmacro .macro SMC_LoadValue label, register -.if .paramcount = 1 .or .match ({register}, a) +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) lda _SMCDesignator+1 .elseif .match ({register}, x) ldx _SMCDesignator+1 .elseif .match ({register}, y) ldy _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_LoadValue'" .endif .endmacro .macro SMC_StoreValue label, register -.if .paramcount = 1 .or .match ({register}, a) +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) sta _SMCDesignator+1 .elseif .match ({register}, x) stx _SMCDesignator+1 .elseif .match ({register}, y) sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_StoreValue'" .endif .endmacro @@ -145,7 +159,7 @@ SMC_StoreValue label, register .endmacro .macro SMC_TransferHighByte label, value, register -.if .paramcount = 2 .or .match ({register}, a) +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) lda value sta _SMCDesignator+2 .elseif .match ({register}, x) @@ -154,31 +168,37 @@ SMC_StoreValue label, register .elseif .match ({register}, y) ldy value sty _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_TransferHighByte'" .endif .endmacro .macro SMC_LoadHighByte label, register -.if .paramcount = 1 .or .match ({register}, a) +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) lda _SMCDesignator+2 .elseif .match ({register}, x) ldx _SMCDesignator+2 .elseif .match ({register}, y) ldy _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_LoadHighByte'" .endif .endmacro .macro SMC_StoreHighByte label, register -.if .paramcount = 1 .or .match ({register}, a) +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) sta _SMCDesignator+2 .elseif .match ({register}, x) stx _SMCDesignator+2 .elseif .match ({register}, y) sty _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_StoreHighByte'" .endif .endmacro .macro SMC_TransferAddressSingle label, address, register -.if .paramcount = 2 .or .match ((register), a) +.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, ) .if (.match (.left (1, {address}), #)) ; immediate mode lda #<(.right (.tcount ({address})-1, {address})) @@ -220,6 +240,8 @@ SMC_StoreValue label, register ldy 1+(address) sty _SMCDesignator+2 .endif +.else + .error "Invalid usage of macro 'SMC_TransferAddressSingle'" .endif .endmacro From aea312746b595aad1d76097672edee4a2a2ec071 Mon Sep 17 00:00:00 2001 From: Irgendwer <C.Krueger.B@web.de> Date: Sun, 14 Aug 2016 19:35:35 +0200 Subject: [PATCH 131/407] Update smc.inc --- asminc/smc.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asminc/smc.inc b/asminc/smc.inc index 8a06f3222..d5752a5f5 100644 --- a/asminc/smc.inc +++ b/asminc/smc.inc @@ -1,7 +1,7 @@ ; smc.mac ; ca65 Macro-Pack for Self Modifying Code (SMC) ; -; (c) Christian Krüger, latest change: 17-Jul-2016 +; (c) Christian Krüger, latest change: 17-Jul-2016 ; ; This software is provided 'as-is', without any expressed or implied ; warranty. In no event will the authors be held liable for any damages @@ -75,7 +75,7 @@ _SMCDesignator: statement .elseif .match ({register}, y) ldy _SMCDesignator .else - .error "Invalid usage of macro 'SMC_TransferOpcode'" + .error "Invalid usage of macro 'SMC_LoadOpcode'" .endif .endmacro From 3bd3fd874994a669a554b41e3b9d3b31f3c65534 Mon Sep 17 00:00:00 2001 From: Chris Cacciatore <chris.cacciatore@gmail.com> Date: Sun, 14 Aug 2016 19:55:03 -0700 Subject: [PATCH 132/407] Removed check for LCURLY in switch statements. --- src/cc65/swstmt.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/cc65/swstmt.c b/src/cc65/swstmt.c index 0aefc051c..f71c3e40a 100644 --- a/src/cc65/swstmt.c +++ b/src/cc65/swstmt.c @@ -144,11 +144,6 @@ void SwitchStatement (void) /* Create a loop so we may use break. */ AddLoop (ExitLabel, 0); - /* Make sure a curly brace follows */ - if (CurTok.Tok != TOK_LCURLY) { - Error ("`{' expected"); - } - /* Parse the following statement, which will actually be a compound ** statement because of the curly brace at the current input position */ From c4823c6fd4c152c6cdf037984a804b35969114d2 Mon Sep 17 00:00:00 2001 From: Chris Cacciatore <chris.cacciatore@gmail.com> Date: Mon, 15 Aug 2016 11:26:03 -0700 Subject: [PATCH 133/407] Added Duff's Device to tests. --- test/val/duffs-device.c | 76 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 test/val/duffs-device.c diff --git a/test/val/duffs-device.c b/test/val/duffs-device.c new file mode 100644 index 000000000..effb33bb2 --- /dev/null +++ b/test/val/duffs-device.c @@ -0,0 +1,76 @@ +/* + !!DESCRIPTION!! Implementation of Duff's device (loop unrolling). + !!ORIGIN!! + !!LICENCE!! GPL, read COPYING.GPL +*/ + +#include <stdio.h> +#include <limits.h> + +#define ASIZE (100) + +unsigned char success=0; +unsigned char failures=0; +unsigned char dummy=0; + +#ifdef SUPPORT_BIT_TYPES +bit bit0 = 0; +#endif + +void done() +{ + dummy++; +} + +int acmp(char* a, char* b, int count) +{ + int i; + + for(i = 0; i < count; i++) { + if(a[i] != b[i]) { + return 1; + } + } + return 0; +} + +void duffit (char* to, char* from, int count) +{ + int n = (count + 7) / 8; + + switch(count % 8) { + case 0: do { *to++ = *from++; + case 7: *to++ = *from++; + case 6: *to++ = *from++; + case 5: *to++ = *from++; + case 4: *to++ = *from++; + case 3: *to++ = *from++; + case 2: *to++ = *from++; + case 1: *to++ = *from++; + } while(--n > 0); + } +} + +int main(void) +{ + char a[ASIZE] = {1}; + char b[ASIZE] = {2}; + + /* a and b should be different */ + if(!acmp(a, b, ASIZE)) { + failures++; + } + + duffit(a, b, ASIZE); + + /* a and b should be the same */ + if(acmp(a, b, ASIZE)) { + failures++; + } + + success=failures; + done(); + printf("failures: %d\n",failures); + + return failures; +} From ac4bdbd411af5cafe1062693816b806f51f3b6e7 Mon Sep 17 00:00:00 2001 From: Chris Cacciatore <chris.cacciatore@gmail.com> Date: Mon, 15 Aug 2016 11:36:50 -0700 Subject: [PATCH 134/407] Now testing switch statements with empty bodies. --- test/val/switch2.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/val/switch2.c diff --git a/test/val/switch2.c b/test/val/switch2.c new file mode 100644 index 000000000..00206b0f6 --- /dev/null +++ b/test/val/switch2.c @@ -0,0 +1,39 @@ +/* + !!DESCRIPTION!! Testing empty bodied switch statements. + !!ORIGIN!! + !!LICENCE!! GPL, read COPYING.GPL +*/ + +#include <stdio.h> + +unsigned char success=0; +unsigned char failures=0; +unsigned char dummy=0; + +void done() +{ + dummy++; +} + +void switch_no_body(void) +{ + switch(0); +} + +void switch_empty_body(void) +{ + switch(0) {}; +} + +/* only worried about this file compiling successfully */ +int main(void) +{ + switch_no_body(); + switch_empty_body(); + + success=failures; + done(); + printf("failures: %d\n",failures); + + return failures; +} From 024f66a84f48cc78193a473e2aff5bd670380797 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Fri, 19 Aug 2016 17:27:41 +0200 Subject: [PATCH 135/407] Allow use of different charmaps on Atari target --- include/atari_atascii_charmap.h | 304 +++++++++++++++++++++++++++++++ include/atari_screen_charmap.h | 304 +++++++++++++++++++++++++++++++ testcode/lib/atari/charmapping.c | 63 +++++++ 3 files changed, 671 insertions(+) create mode 100644 include/atari_atascii_charmap.h create mode 100644 include/atari_screen_charmap.h create mode 100644 testcode/lib/atari/charmapping.c diff --git a/include/atari_atascii_charmap.h b/include/atari_atascii_charmap.h new file mode 100644 index 000000000..78a297f4c --- /dev/null +++ b/include/atari_atascii_charmap.h @@ -0,0 +1,304 @@ +/*****************************************************************************/ +/* */ +/* atari_atascii_charmap.h */ +/* */ +/* Atari system standard string mapping (ISO-8859-1 -> AtASCII) */ +/* */ +/* */ +/* */ +/* (C) 2016 Christian Krueger */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +/* No include guard here! Multiple use in one file may be intentional. */ + +#pragma charmap (0x00, 0x00) +#pragma charmap (0x01, 0x01) +#pragma charmap (0x02, 0x02) +#pragma charmap (0x03, 0x03) +#pragma charmap (0x04, 0x04) +#pragma charmap (0x05, 0x05) +#pragma charmap (0x06, 0x06) +#pragma charmap (0x07, 0xFD) +#pragma charmap (0x08, 0x08) +#pragma charmap (0x09, 0x7F) +#pragma charmap (0x0A, 0x9B) +#pragma charmap (0x0B, 0x0B) +#pragma charmap (0x0C, 0x7D) +#pragma charmap (0x0D, 0x0D) +#pragma charmap (0x0E, 0x0E) +#pragma charmap (0x0F, 0x0F) + +#pragma charmap (0x10, 0x10) +#pragma charmap (0x11, 0x11) +#pragma charmap (0x12, 0x12) +#pragma charmap (0x13, 0x13) +#pragma charmap (0x14, 0x14) +#pragma charmap (0x15, 0x15) +#pragma charmap (0x16, 0x16) +#pragma charmap (0x17, 0x17) +#pragma charmap (0x18, 0x18) +#pragma charmap (0x19, 0x19) +#pragma charmap (0x1A, 0x1A) +#pragma charmap (0x1B, 0x1B) +#pragma charmap (0x1C, 0x1C) +#pragma charmap (0x1D, 0x1D) +#pragma charmap (0x1E, 0x1E) +#pragma charmap (0x1F, 0x1F) + +#pragma charmap (0x20, 0x20) +#pragma charmap (0x21, 0x21) +#pragma charmap (0x22, 0x22) +#pragma charmap (0x23, 0x23) +#pragma charmap (0x24, 0x24) +#pragma charmap (0x25, 0x25) +#pragma charmap (0x26, 0x26) +#pragma charmap (0x27, 0x27) +#pragma charmap (0x28, 0x28) +#pragma charmap (0x29, 0x29) +#pragma charmap (0x2A, 0x2A) +#pragma charmap (0x2B, 0x2B) +#pragma charmap (0x2C, 0x2C) +#pragma charmap (0x2D, 0x2D) +#pragma charmap (0x2E, 0x2E) +#pragma charmap (0x2F, 0x2F) + +#pragma charmap (0x30, 0x30) +#pragma charmap (0x31, 0x31) +#pragma charmap (0x32, 0x32) +#pragma charmap (0x33, 0x33) +#pragma charmap (0x34, 0x34) +#pragma charmap (0x35, 0x35) +#pragma charmap (0x36, 0x36) +#pragma charmap (0x37, 0x37) +#pragma charmap (0x38, 0x38) +#pragma charmap (0x39, 0x39) +#pragma charmap (0x3A, 0x3A) +#pragma charmap (0x3B, 0x3B) +#pragma charmap (0x3C, 0x3C) +#pragma charmap (0x3D, 0x3D) +#pragma charmap (0x3E, 0x3E) +#pragma charmap (0x3F, 0x3F) + +#pragma charmap (0x40, 0x40) +#pragma charmap (0x41, 0x41) +#pragma charmap (0x42, 0x42) +#pragma charmap (0x43, 0x43) +#pragma charmap (0x44, 0x44) +#pragma charmap (0x45, 0x45) +#pragma charmap (0x46, 0x46) +#pragma charmap (0x47, 0x47) +#pragma charmap (0x48, 0x48) +#pragma charmap (0x49, 0x49) +#pragma charmap (0x4A, 0x4A) +#pragma charmap (0x4B, 0x4B) +#pragma charmap (0x4C, 0x4C) +#pragma charmap (0x4D, 0x4D) +#pragma charmap (0x4E, 0x4E) +#pragma charmap (0x4F, 0x4F) + +#pragma charmap (0x50, 0x50) +#pragma charmap (0x51, 0x51) +#pragma charmap (0x52, 0x52) +#pragma charmap (0x53, 0x53) +#pragma charmap (0x54, 0x54) +#pragma charmap (0x55, 0x55) +#pragma charmap (0x56, 0x56) +#pragma charmap (0x57, 0x57) +#pragma charmap (0x58, 0x58) +#pragma charmap (0x59, 0x59) +#pragma charmap (0x5A, 0x5A) +#pragma charmap (0x5B, 0x5B) +#pragma charmap (0x5C, 0x5C) +#pragma charmap (0x5D, 0x5D) +#pragma charmap (0x5E, 0x5E) +#pragma charmap (0x5F, 0x5F) + +#pragma charmap (0x60, 0x60) +#pragma charmap (0x61, 0x61) +#pragma charmap (0x62, 0x62) +#pragma charmap (0x63, 0x63) +#pragma charmap (0x64, 0x64) +#pragma charmap (0x65, 0x65) +#pragma charmap (0x66, 0x66) +#pragma charmap (0x67, 0x67) +#pragma charmap (0x68, 0x68) +#pragma charmap (0x69, 0x69) +#pragma charmap (0x6A, 0x6A) +#pragma charmap (0x6B, 0x6B) +#pragma charmap (0x6C, 0x6C) +#pragma charmap (0x6D, 0x6D) +#pragma charmap (0x6E, 0x6E) +#pragma charmap (0x6F, 0x6F) + +#pragma charmap (0x70, 0x70) +#pragma charmap (0x71, 0x71) +#pragma charmap (0x72, 0x72) +#pragma charmap (0x73, 0x73) +#pragma charmap (0x74, 0x74) +#pragma charmap (0x75, 0x75) +#pragma charmap (0x76, 0x76) +#pragma charmap (0x77, 0x77) +#pragma charmap (0x78, 0x78) +#pragma charmap (0x79, 0x79) +#pragma charmap (0x7A, 0x7A) +#pragma charmap (0x7B, 0x7B) +#pragma charmap (0x7C, 0x7C) +#pragma charmap (0x7D, 0x7D) +#pragma charmap (0x7E, 0x7E) +#pragma charmap (0x7F, 0x7F) + +#pragma charmap (0x80, 0x80) +#pragma charmap (0x81, 0x81) +#pragma charmap (0x82, 0x82) +#pragma charmap (0x83, 0x83) +#pragma charmap (0x84, 0x84) +#pragma charmap (0x85, 0x85) +#pragma charmap (0x86, 0x86) +#pragma charmap (0x87, 0x87) +#pragma charmap (0x88, 0x88) +#pragma charmap (0x89, 0x89) +#pragma charmap (0x8A, 0x8A) +#pragma charmap (0x8B, 0x8B) +#pragma charmap (0x8C, 0x8C) +#pragma charmap (0x8D, 0x8D) +#pragma charmap (0x8E, 0x8E) +#pragma charmap (0x8F, 0x8F) + +#pragma charmap (0x90, 0x90) +#pragma charmap (0x91, 0x91) +#pragma charmap (0x92, 0x92) +#pragma charmap (0x93, 0x93) +#pragma charmap (0x94, 0x94) +#pragma charmap (0x95, 0x95) +#pragma charmap (0x96, 0x96) +#pragma charmap (0x97, 0x97) +#pragma charmap (0x98, 0x98) +#pragma charmap (0x99, 0x99) +#pragma charmap (0x9A, 0x9A) +#pragma charmap (0x9B, 0x9B) +#pragma charmap (0x9C, 0x9C) +#pragma charmap (0x9D, 0x9D) +#pragma charmap (0x9E, 0x9E) +#pragma charmap (0x9F, 0x9F) + +#pragma charmap (0xA0, 0xA0) +#pragma charmap (0xA1, 0xA1) +#pragma charmap (0xA2, 0xA2) +#pragma charmap (0xA3, 0xA3) +#pragma charmap (0xA4, 0xA4) +#pragma charmap (0xA5, 0xA5) +#pragma charmap (0xA6, 0xA6) +#pragma charmap (0xA7, 0xA7) +#pragma charmap (0xA8, 0xA8) +#pragma charmap (0xA9, 0xA9) +#pragma charmap (0xAA, 0xAA) +#pragma charmap (0xAB, 0xAB) +#pragma charmap (0xAC, 0xAC) +#pragma charmap (0xAD, 0xAD) +#pragma charmap (0xAE, 0xAE) +#pragma charmap (0xAF, 0xAF) + +#pragma charmap (0xB0, 0xB0) +#pragma charmap (0xB1, 0xB1) +#pragma charmap (0xB2, 0xB2) +#pragma charmap (0xB3, 0xB3) +#pragma charmap (0xB4, 0xB4) +#pragma charmap (0xB5, 0xB5) +#pragma charmap (0xB6, 0xB6) +#pragma charmap (0xB7, 0xB7) +#pragma charmap (0xB8, 0xB8) +#pragma charmap (0xB9, 0xB9) +#pragma charmap (0xBA, 0xBA) +#pragma charmap (0xBB, 0xBB) +#pragma charmap (0xBC, 0xBC) +#pragma charmap (0xBD, 0xBD) +#pragma charmap (0xBE, 0xBE) +#pragma charmap (0xBF, 0xBF) + +#pragma charmap (0xC0, 0xC0) +#pragma charmap (0xC1, 0xC1) +#pragma charmap (0xC2, 0xC2) +#pragma charmap (0xC3, 0xC3) +#pragma charmap (0xC4, 0xC4) +#pragma charmap (0xC5, 0xC5) +#pragma charmap (0xC6, 0xC6) +#pragma charmap (0xC7, 0xC7) +#pragma charmap (0xC8, 0xC8) +#pragma charmap (0xC9, 0xC9) +#pragma charmap (0xCA, 0xCA) +#pragma charmap (0xCB, 0xCB) +#pragma charmap (0xCC, 0xCC) +#pragma charmap (0xCD, 0xCD) +#pragma charmap (0xCE, 0xCE) +#pragma charmap (0xCF, 0xCF) + +#pragma charmap (0xD0, 0xD0) +#pragma charmap (0xD1, 0xD1) +#pragma charmap (0xD2, 0xD2) +#pragma charmap (0xD3, 0xD3) +#pragma charmap (0xD4, 0xD4) +#pragma charmap (0xD5, 0xD5) +#pragma charmap (0xD6, 0xD6) +#pragma charmap (0xD7, 0xD7) +#pragma charmap (0xD8, 0xD8) +#pragma charmap (0xD9, 0xD9) +#pragma charmap (0xDA, 0xDA) +#pragma charmap (0xDB, 0xDB) +#pragma charmap (0xDC, 0xDC) +#pragma charmap (0xDD, 0xDD) +#pragma charmap (0xDE, 0xDE) +#pragma charmap (0xDF, 0xDF) + +#pragma charmap (0xE0, 0xE0) +#pragma charmap (0xE1, 0xE1) +#pragma charmap (0xE2, 0xE2) +#pragma charmap (0xE3, 0xE3) +#pragma charmap (0xE4, 0xE4) +#pragma charmap (0xE5, 0xE5) +#pragma charmap (0xE6, 0xE6) +#pragma charmap (0xE7, 0xE7) +#pragma charmap (0xE8, 0xE8) +#pragma charmap (0xE9, 0xE9) +#pragma charmap (0xEA, 0xEA) +#pragma charmap (0xEB, 0xEB) +#pragma charmap (0xEC, 0xEC) +#pragma charmap (0xED, 0xED) +#pragma charmap (0xEE, 0xEE) +#pragma charmap (0xEF, 0xEF) + +#pragma charmap (0xF0, 0xF0) +#pragma charmap (0xF1, 0xF1) +#pragma charmap (0xF2, 0xF2) +#pragma charmap (0xF3, 0xF3) +#pragma charmap (0xF4, 0xF4) +#pragma charmap (0xF5, 0xF5) +#pragma charmap (0xF6, 0xF6) +#pragma charmap (0xF7, 0xF7) +#pragma charmap (0xF8, 0xF8) +#pragma charmap (0xF9, 0xF9) +#pragma charmap (0xFA, 0xFA) +#pragma charmap (0xFB, 0xFB) +#pragma charmap (0xFC, 0xFC) +#pragma charmap (0xFD, 0xFD) +#pragma charmap (0xFE, 0xFE) +#pragma charmap (0xFF, 0xFF) + diff --git a/include/atari_screen_charmap.h b/include/atari_screen_charmap.h new file mode 100644 index 000000000..4a76d479a --- /dev/null +++ b/include/atari_screen_charmap.h @@ -0,0 +1,304 @@ +/*****************************************************************************/ +/* */ +/* atari_screen_charmap.h */ +/* */ +/* Atari system internal string mapping (ISO-8859-1 -> Internal/Screen-Code) */ +/* */ +/* */ +/* */ +/* (C) 2016 Christian Krueger */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +/* No include guard here! Multiple use in one file may be intentional. */ + +#pragma charmap (0x00, 0x40) +#pragma charmap (0x01, 0x41) +#pragma charmap (0x02, 0x42) +#pragma charmap (0x03, 0x43) +#pragma charmap (0x04, 0x44) +#pragma charmap (0x05, 0x45) +#pragma charmap (0x06, 0x46) +#pragma charmap (0x07, 0xFD) +#pragma charmap (0x08, 0x48) +#pragma charmap (0x09, 0x7F) +#pragma charmap (0x0A, 0xDB) +#pragma charmap (0x0B, 0x4B) +#pragma charmap (0x0C, 0x7D) +#pragma charmap (0x0D, 0x4D) +#pragma charmap (0x0E, 0x4E) +#pragma charmap (0x0F, 0x4F) + +#pragma charmap (0x10, 0x50) +#pragma charmap (0x11, 0x51) +#pragma charmap (0x12, 0x52) +#pragma charmap (0x13, 0x53) +#pragma charmap (0x14, 0x54) +#pragma charmap (0x15, 0x55) +#pragma charmap (0x16, 0x56) +#pragma charmap (0x17, 0x57) +#pragma charmap (0x18, 0x58) +#pragma charmap (0x19, 0x59) +#pragma charmap (0x1A, 0x5A) +#pragma charmap (0x1B, 0x5B) +#pragma charmap (0x1C, 0x5C) +#pragma charmap (0x1D, 0x5D) +#pragma charmap (0x1E, 0x5E) +#pragma charmap (0x1F, 0x5F) + +#pragma charmap (0x20, 0x00) +#pragma charmap (0x21, 0x01) +#pragma charmap (0x22, 0x02) +#pragma charmap (0x23, 0x03) +#pragma charmap (0x24, 0x04) +#pragma charmap (0x25, 0x05) +#pragma charmap (0x26, 0x06) +#pragma charmap (0x27, 0x07) +#pragma charmap (0x28, 0x08) +#pragma charmap (0x29, 0x09) +#pragma charmap (0x2A, 0x0A) +#pragma charmap (0x2B, 0x0B) +#pragma charmap (0x2C, 0x0C) +#pragma charmap (0x2D, 0x0D) +#pragma charmap (0x2E, 0x0E) +#pragma charmap (0x2F, 0x0F) + +#pragma charmap (0x30, 0x10) +#pragma charmap (0x31, 0x11) +#pragma charmap (0x32, 0x12) +#pragma charmap (0x33, 0x13) +#pragma charmap (0x34, 0x14) +#pragma charmap (0x35, 0x15) +#pragma charmap (0x36, 0x16) +#pragma charmap (0x37, 0x17) +#pragma charmap (0x38, 0x18) +#pragma charmap (0x39, 0x19) +#pragma charmap (0x3A, 0x1A) +#pragma charmap (0x3B, 0x1B) +#pragma charmap (0x3C, 0x1C) +#pragma charmap (0x3D, 0x1D) +#pragma charmap (0x3E, 0x1E) +#pragma charmap (0x3F, 0x1F) + +#pragma charmap (0x40, 0x20) +#pragma charmap (0x41, 0x21) +#pragma charmap (0x42, 0x22) +#pragma charmap (0x43, 0x23) +#pragma charmap (0x44, 0x24) +#pragma charmap (0x45, 0x25) +#pragma charmap (0x46, 0x26) +#pragma charmap (0x47, 0x27) +#pragma charmap (0x48, 0x28) +#pragma charmap (0x49, 0x29) +#pragma charmap (0x4A, 0x2A) +#pragma charmap (0x4B, 0x2B) +#pragma charmap (0x4C, 0x2C) +#pragma charmap (0x4D, 0x2D) +#pragma charmap (0x4E, 0x2E) +#pragma charmap (0x4F, 0x2F) + +#pragma charmap (0x50, 0x30) +#pragma charmap (0x51, 0x31) +#pragma charmap (0x52, 0x32) +#pragma charmap (0x53, 0x33) +#pragma charmap (0x54, 0x34) +#pragma charmap (0x55, 0x35) +#pragma charmap (0x56, 0x36) +#pragma charmap (0x57, 0x37) +#pragma charmap (0x58, 0x38) +#pragma charmap (0x59, 0x39) +#pragma charmap (0x5A, 0x3A) +#pragma charmap (0x5B, 0x3B) +#pragma charmap (0x5C, 0x3C) +#pragma charmap (0x5D, 0x3D) +#pragma charmap (0x5E, 0x3E) +#pragma charmap (0x5F, 0x3F) + +#pragma charmap (0x60, 0x60) +#pragma charmap (0x61, 0x61) +#pragma charmap (0x62, 0x62) +#pragma charmap (0x63, 0x63) +#pragma charmap (0x64, 0x64) +#pragma charmap (0x65, 0x65) +#pragma charmap (0x66, 0x66) +#pragma charmap (0x67, 0x67) +#pragma charmap (0x68, 0x68) +#pragma charmap (0x69, 0x69) +#pragma charmap (0x6A, 0x6A) +#pragma charmap (0x6B, 0x6B) +#pragma charmap (0x6C, 0x6C) +#pragma charmap (0x6D, 0x6D) +#pragma charmap (0x6E, 0x6E) +#pragma charmap (0x6F, 0x6F) + +#pragma charmap (0x70, 0x70) +#pragma charmap (0x71, 0x71) +#pragma charmap (0x72, 0x72) +#pragma charmap (0x73, 0x73) +#pragma charmap (0x74, 0x74) +#pragma charmap (0x75, 0x75) +#pragma charmap (0x76, 0x76) +#pragma charmap (0x77, 0x77) +#pragma charmap (0x78, 0x78) +#pragma charmap (0x79, 0x79) +#pragma charmap (0x7A, 0x7A) +#pragma charmap (0x7B, 0x7B) +#pragma charmap (0x7C, 0x7C) +#pragma charmap (0x7D, 0x7D) +#pragma charmap (0x7E, 0x7E) +#pragma charmap (0x7F, 0x7F) + +#pragma charmap (0x80, 0xC0) +#pragma charmap (0x81, 0xC1) +#pragma charmap (0x82, 0xC2) +#pragma charmap (0x83, 0xC3) +#pragma charmap (0x84, 0xC4) +#pragma charmap (0x85, 0xC5) +#pragma charmap (0x86, 0xC6) +#pragma charmap (0x87, 0xC7) +#pragma charmap (0x88, 0xC8) +#pragma charmap (0x89, 0xC9) +#pragma charmap (0x8A, 0xCA) +#pragma charmap (0x8B, 0xCB) +#pragma charmap (0x8C, 0xCC) +#pragma charmap (0x8D, 0xCD) +#pragma charmap (0x8E, 0xCE) +#pragma charmap (0x8F, 0xCF) + +#pragma charmap (0x90, 0xD0) +#pragma charmap (0x91, 0xD1) +#pragma charmap (0x92, 0xD2) +#pragma charmap (0x93, 0xD3) +#pragma charmap (0x94, 0xD4) +#pragma charmap (0x95, 0xD5) +#pragma charmap (0x96, 0xD6) +#pragma charmap (0x97, 0xD7) +#pragma charmap (0x98, 0xD8) +#pragma charmap (0x99, 0xD9) +#pragma charmap (0x9A, 0xDA) +#pragma charmap (0x9B, 0xDB) +#pragma charmap (0x9C, 0xDC) +#pragma charmap (0x9D, 0xDD) +#pragma charmap (0x9E, 0xDE) +#pragma charmap (0x9F, 0xDF) + +#pragma charmap (0xA0, 0x80) +#pragma charmap (0xA1, 0x81) +#pragma charmap (0xA2, 0x82) +#pragma charmap (0xA3, 0x83) +#pragma charmap (0xA4, 0x84) +#pragma charmap (0xA5, 0x85) +#pragma charmap (0xA6, 0x86) +#pragma charmap (0xA7, 0x87) +#pragma charmap (0xA8, 0x88) +#pragma charmap (0xA9, 0x89) +#pragma charmap (0xAA, 0x8A) +#pragma charmap (0xAB, 0x8B) +#pragma charmap (0xAC, 0x8C) +#pragma charmap (0xAD, 0x8D) +#pragma charmap (0xAE, 0x8E) +#pragma charmap (0xAF, 0x8F) + +#pragma charmap (0xB0, 0x90) +#pragma charmap (0xB1, 0x91) +#pragma charmap (0xB2, 0x92) +#pragma charmap (0xB3, 0x93) +#pragma charmap (0xB4, 0x94) +#pragma charmap (0xB5, 0x95) +#pragma charmap (0xB6, 0x96) +#pragma charmap (0xB7, 0x97) +#pragma charmap (0xB8, 0x98) +#pragma charmap (0xB9, 0x99) +#pragma charmap (0xBA, 0x9A) +#pragma charmap (0xBB, 0x9B) +#pragma charmap (0xBC, 0x9C) +#pragma charmap (0xBD, 0x9D) +#pragma charmap (0xBE, 0x9E) +#pragma charmap (0xBF, 0x9F) + +#pragma charmap (0xC0, 0xA0) +#pragma charmap (0xC1, 0xA1) +#pragma charmap (0xC2, 0xA2) +#pragma charmap (0xC3, 0xA3) +#pragma charmap (0xC4, 0xA4) +#pragma charmap (0xC5, 0xA5) +#pragma charmap (0xC6, 0xA6) +#pragma charmap (0xC7, 0xA7) +#pragma charmap (0xC8, 0xA8) +#pragma charmap (0xC9, 0xA9) +#pragma charmap (0xCA, 0xAA) +#pragma charmap (0xCB, 0xAB) +#pragma charmap (0xCC, 0xAC) +#pragma charmap (0xCD, 0xAD) +#pragma charmap (0xCE, 0xAE) +#pragma charmap (0xCF, 0xAF) + +#pragma charmap (0xD0, 0xB0) +#pragma charmap (0xD1, 0xB1) +#pragma charmap (0xD2, 0xB2) +#pragma charmap (0xD3, 0xB3) +#pragma charmap (0xD4, 0xB4) +#pragma charmap (0xD5, 0xB5) +#pragma charmap (0xD6, 0xB6) +#pragma charmap (0xD7, 0xB7) +#pragma charmap (0xD8, 0xB8) +#pragma charmap (0xD9, 0xB9) +#pragma charmap (0xDA, 0xBA) +#pragma charmap (0xDB, 0xBB) +#pragma charmap (0xDC, 0xBC) +#pragma charmap (0xDD, 0xBD) +#pragma charmap (0xDE, 0xBE) +#pragma charmap (0xDF, 0xBF) + +#pragma charmap (0xE0, 0xE0) +#pragma charmap (0xE1, 0xE1) +#pragma charmap (0xE2, 0xE2) +#pragma charmap (0xE3, 0xE3) +#pragma charmap (0xE4, 0xE4) +#pragma charmap (0xE5, 0xE5) +#pragma charmap (0xE6, 0xE6) +#pragma charmap (0xE7, 0xE7) +#pragma charmap (0xE8, 0xE8) +#pragma charmap (0xE9, 0xE9) +#pragma charmap (0xEA, 0xEA) +#pragma charmap (0xEB, 0xEB) +#pragma charmap (0xEC, 0xEC) +#pragma charmap (0xED, 0xED) +#pragma charmap (0xEE, 0xEE) +#pragma charmap (0xEF, 0xEF) + +#pragma charmap (0xF0, 0xF0) +#pragma charmap (0xF1, 0xF1) +#pragma charmap (0xF2, 0xF2) +#pragma charmap (0xF3, 0xF3) +#pragma charmap (0xF4, 0xF4) +#pragma charmap (0xF5, 0xF5) +#pragma charmap (0xF6, 0xF6) +#pragma charmap (0xF7, 0xF7) +#pragma charmap (0xF8, 0xF8) +#pragma charmap (0xF9, 0xF9) +#pragma charmap (0xFA, 0xFA) +#pragma charmap (0xFB, 0xFB) +#pragma charmap (0xFC, 0xFC) +#pragma charmap (0xFD, 0xFD) +#pragma charmap (0xFE, 0xFE) +#pragma charmap (0xFF, 0xFF) + diff --git a/testcode/lib/atari/charmapping.c b/testcode/lib/atari/charmapping.c new file mode 100644 index 000000000..5fce663ee --- /dev/null +++ b/testcode/lib/atari/charmapping.c @@ -0,0 +1,63 @@ +/* +** testprogram for includes "atari_screen_charmap.h" and "atari_atascii_charmap.h" +** +** 19-Aug-2016, Christian Krueger +*/ + +#include <conio.h> +#include <atari.h> +#include <peekpoke.h> +#include <string.h> + + +char pcDefaultMappingString[] = "Hello Atari!"; + +#include <atari_screen_charmap.h> +char pcScreenMappingString[] = "Hello Atari!"; + +#include <atari_atascii_charmap.h> +char pcAtasciiMappingString[] = "Hello Atari!"; + +/* THIS WON'T work due to string merging/collection problems! +char* pcDefaultMappingString = "Hello Atari!"; + +#include <atari_screen_charmap.h> +char* pcScreenMappingString = "Hello Atari!"; + +#include <atari_atascii_charmap.h> +char* pcAtasciiMappingString = "Hello Atari!"; +*/ + +int +main(void) +{ + static unsigned char expectedAtasciiValues[] = { 40,101,108,108,111,0,33,116,97,114,105,1}; + + int returnValue = 0; + unsigned char* screen = (unsigned char*) PEEKW(88); + + // check default (=atascii) + clrscr(); + cputs(pcDefaultMappingString); + returnValue |= memcmp(screen, expectedAtasciiValues, sizeof(expectedAtasciiValues)); + + clrscr(); + memcpy(screen, pcScreenMappingString, sizeof(expectedAtasciiValues)); + returnValue |= memcmp(screen, expectedAtasciiValues, sizeof(expectedAtasciiValues)); + + clrscr(); + cputs(pcAtasciiMappingString); + returnValue |= memcmp(screen, expectedAtasciiValues, sizeof(expectedAtasciiValues)); + + clrscr(); + if (returnValue) + cputs("Test FAILED!"); + else + cputs("Test passed."); + + cputs("\n\rHit any key to exit..."); + cgetc(); + + return returnValue; +} + From 791981237851b289533696a0583b340a0613fb7f Mon Sep 17 00:00:00 2001 From: Chris Cacciatore <chris.cacciatore@gmail.com> Date: Fri, 19 Aug 2016 20:21:10 -0700 Subject: [PATCH 136/407] Updated switch statement comments. * Now comments represent the fact that there may not be curly braces. --- src/cc65/swstmt.c | 4 ++-- test/val/switch2.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc65/swstmt.c b/src/cc65/swstmt.c index f71c3e40a..e995bd0b7 100644 --- a/src/cc65/swstmt.c +++ b/src/cc65/swstmt.c @@ -144,8 +144,8 @@ void SwitchStatement (void) /* Create a loop so we may use break. */ AddLoop (ExitLabel, 0); - /* Parse the following statement, which will actually be a compound - ** statement because of the curly brace at the current input position + /* Parse the following statement, which may actually be a compound + ** statement if there is a curly brace at the current input position */ HaveBreak = Statement (&RCurlyBrace); diff --git a/test/val/switch2.c b/test/val/switch2.c index 00206b0f6..65c24eeda 100644 --- a/test/val/switch2.c +++ b/test/val/switch2.c @@ -22,7 +22,7 @@ void switch_no_body(void) void switch_empty_body(void) { - switch(0) {}; + switch(0) {} } /* only worried about this file compiling successfully */ From e9295b2a98734dc7a422f4a5b161a024d2f4ec22 Mon Sep 17 00:00:00 2001 From: Chris Cacciatore <chris.cacciatore@gmail.com> Date: Sat, 20 Aug 2016 09:42:29 -0700 Subject: [PATCH 137/407] Updated comment regarding curly braces. --- src/cc65/swstmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/swstmt.c b/src/cc65/swstmt.c index e995bd0b7..512f4257d 100644 --- a/src/cc65/swstmt.c +++ b/src/cc65/swstmt.c @@ -194,7 +194,7 @@ void SwitchStatement (void) /* Free the case value tree */ FreeCaseNodeColl (SwitchData.Nodes); - /* If the case statement was (correctly) terminated by a closing curly + /* If the case statement was terminated by a closing curly ** brace, skip it now. */ if (RCurlyBrace) { From 2f6fb1de1c81b147cbf25cb1c1b3e1b149eb0622 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 26 Aug 2016 11:06:58 +0200 Subject: [PATCH 138/407] Added -Wc to the (pseudo) output dump. --- doc/cl65.sgml | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/cl65.sgml b/doc/cl65.sgml index b9a6cd1e4..eef6a12a3 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -62,6 +62,7 @@ Short options: -V Print the version number -W name[,...] Supress compiler warnings -Wa options Pass options to the assembler + -Wc options Pass options to the compiler -Wl options Pass options to the linker Long options: From 1dee57bf1fc6c9781ee51c85c0cd614338266d63 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Fri, 26 Aug 2016 07:39:39 -0400 Subject: [PATCH 139/407] Made cc65 not warn us when we change character code 0x00 back to itself. --- src/cc65/pragma.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 52af1e722..86739ce22 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -452,15 +452,9 @@ static void CharMapPragma (StrBuf* B) if (!GetNumber (B, &Index)) { return; } - if (Index < 1 || Index > 255) { - if (Index != 0) { - Error ("Character index out of range"); - return; - } - /* For groepaz and Christian */ - if (IS_Get (&WarnRemapZero)) { - Warning ("Remapping from 0 is dangerous with string functions"); - } + if (Index < 0 || Index > 255) { + Error ("Character index out of range"); + return; } /* Comma follows */ @@ -472,13 +466,19 @@ static void CharMapPragma (StrBuf* B) if (!GetNumber (B, &C)) { return; } - if (C < 1 || C > 255) { - if (C != 0) { - Error ("Character code out of range"); - return; + if (C < 0 || C > 255) { + Error ("Character code out of range"); + return; + } + + /* Warn about remapping character code 0x00 + ** (except when remapping it back to itself). + */ + if (Index + C != 0 && IS_Get (&WarnRemapZero)) { + if (Index == 0) { + Warning ("Remapping from 0 is dangerous with string functions"); } - /* For groepaz and Christian */ - if (IS_Get (&WarnRemapZero)) { + else if (C == 0) { Warning ("Remapping to 0 can make string functions stop unexpectedly"); } } From e786d1cf4911e3c82fcf2687f5798145f2334b17 Mon Sep 17 00:00:00 2001 From: alexthissen <athissen@killer-apps.nl> Date: Sat, 27 Aug 2016 21:58:13 +0200 Subject: [PATCH 140/407] Update exehdr.s Fix for memory bank 1 which should be zero for almost all cartridges for emulators to work correctly. --- libsrc/lynx/exehdr.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/lynx/exehdr.s b/libsrc/lynx/exehdr.s index 4f077fb82..3be926bb3 100644 --- a/libsrc/lynx/exehdr.s +++ b/libsrc/lynx/exehdr.s @@ -12,7 +12,7 @@ .segment "EXEHDR" .byte 'L','Y','N','X' ; magic .word __BLOCKSIZE__ ; bank 0 page size - .word __BLOCKSIZE__ ; bank 1 page size + .word 0 ; bank 1 page size .word 1 ; version number .asciiz "Cart name " ; 32 bytes cart name .asciiz "Manufacturer " ; 16 bytes manufacturer From d65f587f69ff5569223b77ac6f4b2e3500512252 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 27 Aug 2016 22:02:08 +0200 Subject: [PATCH 141/407] Internal/screen character mapping: Supressed warnings for re-map and added documentation. --- doc/atari.sgml | 52 ++++++++++++++++++++++++++++++++++ include/atari_screen_charmap.h | 8 +++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/doc/atari.sgml b/doc/atari.sgml index e65a7869e..54f3aab78 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -318,6 +318,58 @@ chip registers. </descrip><p> +<sect1>Character mapping<p> + +The Atari has two representations for characters: +<enum> +<item> ATASCII is character mapping which is similar to ASCII and used +by the CIO system of the OS. This is the default mapping of cc65 when +producing code for the atari target. +<item> The internal/screen mapping represents the real value of the +screen ram when showing a character. +</enum> + +For direct memory access (simplicity and speed) enabling the internal +mapping can be useful. This can be achieved by including the +"<tt/atari_screen_charmap.h/" header. + +A word of caution: Since the <tt/0x00/ character has to be mapped in an +incompatible way to the C-standard, the usage of string functions in +conjunction with internal character mapped strings delivers unexpected +results regarding the string length. The end of strings are detected where +you may not expect them (to early or (much) to late). Internal mapped +strings typically support the "<tt/mem...()/" functions. + +<em>For assembler sources the macro "<tt/scrcode/" from the "<tt/atari.mac/" +package delivers the same feature.</em> + +You can switch back to the ATASCII mapping by including +"<tt/atari_atascii_charmap.h/". + +A final note: Since cc65 has currently some difficulties with string merging +under different mappings, defining remapped strings works only flawlessly +with static array initialization: + +<verb> +#include <atari\_screen\_charmap.h> +char pcScreenMappingString[] = "Hello Atari!"; + +#include <atari_atascii_charmap.h> +char pcAtasciiMappingString[] = "Hello Atari!"; +</verb> + +delivers correct results, while + +<verb> +#include <atari_screen_charmap.h> +char* pcScreenMappingString = "Hello Atari!"; + +#include <atari_atascii_charmap.h> +char* pcAtasciiMappingString = "Hello Atari!"; +</verb> + +does not. + <sect>Loadable drivers<p> diff --git a/include/atari_screen_charmap.h b/include/atari_screen_charmap.h index 4a76d479a..78051584f 100644 --- a/include/atari_screen_charmap.h +++ b/include/atari_screen_charmap.h @@ -30,7 +30,10 @@ /* No include guard here! Multiple use in one file may be intentional. */ +#pragma warn (remap-zero, push, off) #pragma charmap (0x00, 0x40) +#pragma warn (remap-zero, pop) + #pragma charmap (0x01, 0x41) #pragma charmap (0x02, 0x42) #pragma charmap (0x03, 0x43) @@ -64,7 +67,10 @@ #pragma charmap (0x1E, 0x5E) #pragma charmap (0x1F, 0x5F) -#pragma charmap (0x20, 0x00) +#pragma warn (remap-zero, push, off) +#pragma charmap (0x20, 0x00) +#pragma warn (remap-zero, pop) + #pragma charmap (0x21, 0x01) #pragma charmap (0x22, 0x02) #pragma charmap (0x23, 0x03) From 0538184699358b9f2f3427277cfe1c30d7c64fef Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Mon, 29 Aug 2016 10:45:18 +0200 Subject: [PATCH 142/407] Add 4510 support for C65/C64DX --- doc/ca65.sgml | 39 +++-- src/ca65/ea65.c | 19 ++- src/ca65/instr.c | 234 +++++++++++++++++++++++++-- src/ca65/instr.h | 6 +- src/ca65/main.c | 4 + src/ca65/scanner.c | 104 ++++++------ src/ca65/token.h | 1 + src/common/cpu.c | 2 + src/common/cpu.h | 2 + src/common/target.c | 2 + src/common/target.h | 1 + testcode/assembler/.gitignore | 9 +- testcode/assembler/4510all.ref | Bin 0 -> 564 bytes testcode/assembler/4510all.s | 278 +++++++++++++++++++++++++++++++++ testcode/assembler/Makefile | 11 +- 15 files changed, 630 insertions(+), 82 deletions(-) create mode 100644 testcode/assembler/4510all.ref create mode 100644 testcode/assembler/4510all.s diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 050e75628..f59ce44cb 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -152,7 +152,7 @@ Here is a description of all the command line options: Set the default for the CPU type. The option takes a parameter, which may be one of - 6502, 65SC02, 65C02, 65816, sweet16, HuC6280 + 6502, 6502X, 65SC02, 65C02, 65816, sweet16, HuC6280, 4510 <label id="option-create-dep"> @@ -434,16 +434,16 @@ The assembler accepts In 65816 mode, several aliases are accepted, in addition to the official mnemonics: -<tscreen><verb> -CPA is an alias for CMP -DEA is an alias for DEC A -INA is an alias for INC A -SWA is an alias for XBA -TAD is an alias for TCD -TAS is an alias for TCS -TDA is an alias for TDC -TSA is an alias for TSC -</verb></tscreen> +<itemize> +<item><tt>CPA</tt> is an alias for <tt>CMP</tt> +<item><tt>DEA</tt> is an alias for <tt>DEC A</tt> +<item><tt>INA</tt> is an alias for <tt>INC A</tt> +<item><tt>SWA</tt> is an alias for <tt>XBA</tt> +<item><tt>TAD</tt> is an alias for <tt>TCD</tt> +<item><tt>TAS</tt> is an alias for <tt>TCS</tt> +<item><tt>TDA</tt> is an alias for <tt>TDC</tt> +<item><tt>TSA</tt> is an alias for <tt>TSC</tt> +</itemize> <sect1>6502X mode<label id="6502X-mode"><p> @@ -473,6 +473,23 @@ from the mentioned web page, for more information, see there. </itemize> +<sect1>4510 mode<p> + +The 4510 is a microcontroller that is the core of the Commodore C65 aka C64DX. +It contains among other functions a slightly modified 65CE02 CPU, to allow +address mapping for 20 bits of address space (1 megabyte addressable area). +As compared to the description of the CPU in the System Specification of the +Commodore C65 aka C64DX prototypes ca65 uses these changes: +<itemize> +<item><tt>LDA (d,SP),Y</tt> may also be written as <tt>LDA (d,S),Y</tt> +(matching the 65816 notataion). +<item>All branch instruction allow now 16 bit offsets. To use a 16 bit +branch you have to prefix these with an "L" (e.g. "<tt>LBNE</tt>" instead of +"<tt>BNE</tt>"). This might change at a later implementation of the assember. +</itemize> +For more information about the Commodore C65/C64DX and the 4510 CPU, see +<url url="http://www.zimmers.net/anonftp/pub/cbm/c65/c65manualupdated.txt.gz">. + <sect1>sweet16 mode<label id="sweet16-mode"><p> diff --git a/src/ca65/ea65.c b/src/ca65/ea65.c index 69468c072..e146ab8c9 100644 --- a/src/ca65/ea65.c +++ b/src/ca65/ea65.c @@ -140,16 +140,27 @@ void GetEA (EffAddr* A) } else { - /* (adr) or (adr),y */ + /* (adr), (adr),y or (adr),z */ Consume (IndirectLeave, IndirectExpect); if (CurTok.Tok == TOK_COMMA) { /* (adr),y */ NextTok (); - Consume (TOK_Y, "`Y' expected"); - A->AddrModeSet = AM65_DIR_IND_Y; + switch(CurTok.Tok) { + case TOK_Z: + if (CPU == CPU_4510) { + NextTok (); + A->AddrModeSet = AM65_DIR_IND; + } + break; + default: + Consume (TOK_Y, "`Y' expected"); + A->AddrModeSet = AM65_DIR_IND_Y; + break; + } } else { /* (adr) */ - A->AddrModeSet = AM65_ABS_IND | AM65_ABS_IND_LONG | AM65_DIR_IND; + A->AddrModeSet = (CPU == CPU_4510) ? AM65_ABS_IND + : AM65_ABS_IND | AM65_ABS_IND_LONG | AM65_DIR_IND; } } diff --git a/src/ca65/instr.c b/src/ca65/instr.c index 966a5cd98..a4365402d 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -73,6 +73,9 @@ static void PutPCRel8 (const InsDesc* Ins); static void PutPCRel16 (const InsDesc* Ins); /* Handle branches with an 16 bit distance and PER */ +static void PutPCRel4510 (const InsDesc* Ins); +/* Handle branches with a 16 bit distance for 4510 */ + static void PutBlockMove (const InsDesc* Ins); /* Handle the blockmove instructions (65816) */ @@ -125,6 +128,9 @@ static void PutRTS (const InsDesc* Ins attribute ((unused))); static void PutAll (const InsDesc* Ins); /* Handle all other instructions */ +static void Put4510 (const InsDesc* Ins); +/* Handle instructions of 4510 not matching any EATab */ + static void PutSweet16 (const InsDesc* Ins); /* Handle a generic sweet16 instruction */ @@ -483,6 +489,149 @@ static const struct { } }; +/* Instruction table for the 4510 */ +static const struct { + unsigned Count; + InsDesc Ins[133]; +} InsTab4510 = { + sizeof (InsTab4510.Ins) / sizeof (InsTab4510.Ins[0]), + { + { "ADC", 0x080A66C, 0x60, 0, PutAll }, + { "AND", 0x080A66C, 0x20, 0, PutAll }, + { "ASL", 0x000006e, 0x02, 1, PutAll }, + { "ASR", 0x0000026, 0x43, 0, Put4510 }, + { "ASW", 0x0000008, 0xcb, 6, PutAll }, + { "BBR0", 0x0000000, 0x0F, 0, PutBitBranch }, + { "BBR1", 0x0000000, 0x1F, 0, PutBitBranch }, + { "BBR2", 0x0000000, 0x2F, 0, PutBitBranch }, + { "BBR3", 0x0000000, 0x3F, 0, PutBitBranch }, + { "BBR4", 0x0000000, 0x4F, 0, PutBitBranch }, + { "BBR5", 0x0000000, 0x5F, 0, PutBitBranch }, + { "BBR6", 0x0000000, 0x6F, 0, PutBitBranch }, + { "BBR7", 0x0000000, 0x7F, 0, PutBitBranch }, + { "BBS0", 0x0000000, 0x8F, 0, PutBitBranch }, + { "BBS1", 0x0000000, 0x9F, 0, PutBitBranch }, + { "BBS2", 0x0000000, 0xAF, 0, PutBitBranch }, + { "BBS3", 0x0000000, 0xBF, 0, PutBitBranch }, + { "BBS4", 0x0000000, 0xCF, 0, PutBitBranch }, + { "BBS5", 0x0000000, 0xDF, 0, PutBitBranch }, + { "BBS6", 0x0000000, 0xEF, 0, PutBitBranch }, + { "BBS7", 0x0000000, 0xFF, 0, PutBitBranch }, + { "BCC", 0x0020000, 0x90, 0, PutPCRel8 }, + { "BCS", 0x0020000, 0xb0, 0, PutPCRel8 }, + { "BEQ", 0x0020000, 0xf0, 0, PutPCRel8 }, + { "BIT", 0x0A0006C, 0x00, 2, PutAll }, + { "BMI", 0x0020000, 0x30, 0, PutPCRel8 }, + { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, + { "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, + { "BRA", 0x0020000, 0x80, 0, PutPCRel8 }, + { "BRK", 0x0000001, 0x00, 0, PutAll }, + { "BSR", 0x0040000, 0x63, 0, PutPCRel4510 }, + { "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, + { "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, + { "CLC", 0x0000001, 0x18, 0, PutAll }, + { "CLD", 0x0000001, 0xd8, 0, PutAll }, + { "CLE", 0x0000001, 0x02, 0, PutAll }, + { "CLI", 0x0000001, 0x58, 0, PutAll }, + { "CLV", 0x0000001, 0xb8, 0, PutAll }, + { "CMP", 0x080A66C, 0xc0, 0, PutAll }, + { "CPX", 0x080000C, 0xe0, 1, PutAll }, + { "CPY", 0x080000C, 0xc0, 1, PutAll }, + { "CPZ", 0x080000C, 0xd0, 1, Put4510 }, + { "DEA", 0x0000001, 0x00, 3, PutAll }, /* == DEC */ + { "DEC", 0x000006F, 0x00, 3, PutAll }, + { "DEW", 0x0000004, 0xc3, 7, PutAll }, /* trial'n'error */ + { "DEX", 0x0000001, 0xca, 0, PutAll }, + { "DEY", 0x0000001, 0x88, 0, PutAll }, + { "DEZ", 0x0000001, 0x3B, 0, PutAll }, + { "EOM", 0x0000001, 0xea, 0, PutAll }, + { "EOR", 0x080A66C, 0x40, 0, PutAll }, + { "INA", 0x0000001, 0x00, 4, PutAll }, /* == INC */ + { "INC", 0x000006f, 0x00, 4, PutAll }, + { "INW", 0x0000004, 0xe3, 7, PutAll }, /* trial'n'error */ + { "INX", 0x0000001, 0xe8, 0, PutAll }, + { "INY", 0x0000001, 0xc8, 0, PutAll }, + { "INZ", 0x0000001, 0x1B, 0, PutAll }, + { "JMP", 0x0010808, 0x4c, 6, PutAll }, + { "JSR", 0x0010808, 0x20, 6, Put4510 }, + { "LBCC", 0x0040000, 0x93, 0, PutPCRel4510 }, + { "LBCS", 0x0040000, 0xb3, 0, PutPCRel4510 }, + { "LBEQ", 0x0040000, 0xf3, 0, PutPCRel4510 }, + { "LBMI", 0x0040000, 0x33, 0, PutPCRel4510 }, + { "LBNE", 0x0040000, 0xd3, 0, PutPCRel4510 }, + { "LBPL", 0x0040000, 0x13, 0, PutPCRel4510 }, + { "LBRA", 0x0040000, 0x83, 0, PutPCRel4510 }, + { "LBVC", 0x0040000, 0x53, 0, PutPCRel4510 }, + { "LBVS", 0x0040000, 0x73, 0, PutPCRel4510 }, + { "LDA", 0x090A66C, 0xa0, 0, Put4510 }, + { "LDX", 0x080030C, 0xa2, 1, PutAll }, + { "LDY", 0x080006C, 0xa0, 1, PutAll }, + { "LDZ", 0x0800048, 0xa3, 1, Put4510 }, + { "LSR", 0x000006F, 0x42, 1, PutAll }, + { "MAP", 0x0000001, 0x5C, 0, PutAll }, + { "NEG", 0x0000001, 0x42, 0, PutAll }, + { "NOP", 0x0000001, 0xea, 0, PutAll }, /* == EOM */ + { "ORA", 0x080A66C, 0x00, 0, PutAll }, + { "PHA", 0x0000001, 0x48, 0, PutAll }, + { "PHD", 0x8000008, 0xf4, 1, PutAll }, /* == PHW */ + { "PHP", 0x0000001, 0x08, 0, PutAll }, + { "PHW", 0x8000008, 0xf4, 1, PutAll }, + { "PHX", 0x0000001, 0xda, 0, PutAll }, + { "PHY", 0x0000001, 0x5a, 0, PutAll }, + { "PHZ", 0x0000001, 0xdb, 0, PutAll }, + { "PLA", 0x0000001, 0x68, 0, PutAll }, + { "PLP", 0x0000001, 0x28, 0, PutAll }, + { "PLX", 0x0000001, 0xfa, 0, PutAll }, + { "PLY", 0x0000001, 0x7a, 0, PutAll }, + { "PLZ", 0x0000001, 0xfb, 0, PutAll }, + { "RMB0", 0x0000004, 0x07, 1, PutAll }, + { "RMB1", 0x0000004, 0x17, 1, PutAll }, + { "RMB2", 0x0000004, 0x27, 1, PutAll }, + { "RMB3", 0x0000004, 0x37, 1, PutAll }, + { "RMB4", 0x0000004, 0x47, 1, PutAll }, + { "RMB5", 0x0000004, 0x57, 1, PutAll }, + { "RMB6", 0x0000004, 0x67, 1, PutAll }, + { "RMB7", 0x0000004, 0x77, 1, PutAll }, + { "ROL", 0x000006F, 0x22, 1, PutAll }, + { "ROR", 0x000006F, 0x62, 1, PutAll }, + { "ROW", 0x0000008, 0xeb, 6, PutAll }, + { "RTI", 0x0000001, 0x40, 0, PutAll }, + { "RTN", 0x0800000, 0x62, 1, PutAll }, + { "RTS", 0x0000001, 0x60, 0, PutAll }, + { "SBC", 0x080A66C, 0xe0, 0, PutAll }, + { "SEC", 0x0000001, 0x38, 0, PutAll }, + { "SED", 0x0000001, 0xf8, 0, PutAll }, + { "SEE", 0x0000001, 0x03, 0, PutAll }, + { "SEI", 0x0000001, 0x78, 0, PutAll }, + { "SMB0", 0x0000004, 0x87, 1, PutAll }, + { "SMB1", 0x0000004, 0x97, 1, PutAll }, + { "SMB2", 0x0000004, 0xA7, 1, PutAll }, + { "SMB3", 0x0000004, 0xB7, 1, PutAll }, + { "SMB4", 0x0000004, 0xC7, 1, PutAll }, + { "SMB5", 0x0000004, 0xD7, 1, PutAll }, + { "SMB6", 0x0000004, 0xE7, 1, PutAll }, + { "SMB7", 0x0000004, 0xF7, 1, PutAll }, + { "STA", 0x010A66C, 0x80, 0, Put4510 }, + { "STX", 0x000030c, 0x82, 1, Put4510 }, + { "STY", 0x000006c, 0x80, 1, Put4510 }, + { "STZ", 0x000006c, 0x04, 5, PutAll }, + { "TAB", 0x0000001, 0x5b, 0, PutAll }, + { "TAX", 0x0000001, 0xaa, 0, PutAll }, + { "TAY", 0x0000001, 0xa8, 0, PutAll }, + { "TAZ", 0x0000001, 0x4b, 0, PutAll }, + { "TBA", 0x0000001, 0x7b, 0, PutAll }, + { "TRB", 0x000000c, 0x10, 1, PutAll }, + { "TSB", 0x000000c, 0x00, 1, PutAll }, + { "TSX", 0x0000001, 0xba, 0, PutAll }, + { "TSY", 0x0000001, 0x0b, 0, PutAll }, + { "TXA", 0x0000001, 0x8a, 0, PutAll }, + { "TXS", 0x0000001, 0x9a, 0, PutAll }, + { "TYA", 0x0000001, 0x98, 0, PutAll }, + { "TYS", 0x0000001, 0x2b, 0, PutAll }, + { "TZA", 0x0000001, 0x6b, 0, PutAll }, + } +}; + /* Instruction table for the 65816 */ static const struct { unsigned Count; @@ -786,6 +935,7 @@ static const InsTable* InsTabs[CPU_COUNT] = { (const InsTable*) &InsTabSweet16, (const InsTable*) &InsTabHuC6280, 0, /* Mitsubishi 740 */ + (const InsTable*) &InsTab4510, }; const InsTable* InsTab = (const InsTable*) &InsTab6502; @@ -797,73 +947,73 @@ static unsigned char EATab[12][AM65I_COUNT] = { 0x00, 0x00, 0x05, 0x0D, 0x0F, 0x15, 0x1D, 0x1F, 0x00, 0x19, 0x12, 0x00, 0x07, 0x11, 0x17, 0x01, 0x00, 0x00, 0x00, 0x03, 0x13, 0x09, 0x00, 0x09, - 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }, { /* Table 1 */ 0x08, 0x08, 0x04, 0x0C, 0x00, 0x14, 0x1C, 0x00, 0x14, 0x1C, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80 + 0x00, 0x00, 0x80, 0x00 }, { /* Table 2 */ 0x00, 0x00, 0x24, 0x2C, 0x0F, 0x34, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, - 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }, { /* Table 3 */ 0x3A, 0x3A, 0xC6, 0xCE, 0x00, 0xD6, 0xDE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }, { /* Table 4 */ 0x1A, 0x1A, 0xE6, 0xEE, 0x00, 0xF6, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }, { /* Table 5 */ 0x00, 0x00, 0x60, 0x98, 0x00, 0x70, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }, { /* Table 6 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x90 + 0x00, 0x00, 0x90, 0x00 }, { /* Table 7 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }, { /* Table 8 */ 0x00, 0x40, 0x01, 0x41, 0x00, 0x09, 0x49, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, - 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }, { /* Table 9 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }, { /* Table 10 (NOPs) */ 0xea, 0x00, 0x04, 0x0c, 0x00, 0x14, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }, { /* Table 11 (LAX) */ 0x08, 0x08, 0x04, 0x0C, 0x00, 0x14, 0x1C, 0x00, 0x14, 0x1C, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x80 + 0x00, 0x00, 0x80, 0x00 }, }; @@ -908,6 +1058,7 @@ unsigned char ExtBytes[AM65I_COUNT] = { 2, /* Blockmove (65816) */ 7, /* Block transfer (HuC6280) */ 2, /* Absolute Indirect long */ + 2, /* Immidiate word */ }; /* Table that encodes the additional bytes for each SWEET16 instruction */ @@ -1033,7 +1184,7 @@ static int EvalEA (const InsDesc* Ins, EffAddr* A) ** limit the expression to the maximum possible value. */ if (A->AddrMode == AM65I_IMM_ACCU || A->AddrMode == AM65I_IMM_INDEX || - A->AddrMode == AM65I_IMM_IMPLICIT) { + A->AddrMode == AM65I_IMM_IMPLICIT || A->AddrMode == AM65I_IMM_IMPLICIT_WORD) { if (ForceRange && A->Expr) { A->Expr = MakeBoundedExpr (A->Expr, ExtBytes[A->AddrMode]); } @@ -1136,6 +1287,14 @@ static void PutPCRel16 (const InsDesc* Ins) +static void PutPCRel4510 (const InsDesc* Ins) +/* Handle branches with a 16 bit distance */ +{ + /* 16 bit branch opcode is 8 bit branch opcode or 0x03 */ + EmitPCRel (Ins->BaseCode, GenBranchExpr (2), 2); +} + + static void PutBlockMove (const InsDesc* Ins) /* Handle the blockmove instructions (65816) */ { @@ -1383,6 +1542,55 @@ static void PutAll (const InsDesc* Ins) +static void Put4510 (const InsDesc* Ins) +/* Handle all other instructions */ +{ + /* The 4510 uses all 256 possible opcodes, so the last ones were cramped + * in where an opcode was still undefined. As a result, some of those + * don't follow any rules for encoding the addressmodes. So the EATab + * approach does not work always. In this function, the wrongly calculated + * opcode is replaced by the correct one "on the fly". Suggestions for a + * better approach are welcome. + * + * These are: + * $20 -> $22 : JSR ($1234) NEED TO CHECK FOR ADDRESSING + * $30 -> $23 : JSR ($1234,X) + * $47 -> $44 : ASR $12 + * $57 -> $54 : ASR $12,X + * $93 -> $82 : STA ($12,SP),Y + * $9c -> $8b : STY $1234,X + * $9e -> $9b : STX $1234,Y + * $af -> $ab : LDZ $1234 + * $bf -> $bb : LDZ $1234,X + * $b3 -> $e2 : LDA ($12,SP),Y + * $d0 -> $c2 : CPZ #$00 + */ + EffAddr A; + + /* Evaluate the addressing mode used */ + if (EvalEA (Ins, &A)) { + switch(A.Opcode) { + case 0x20: if(A.AddrModeBit == AM65_ABS_IND) A.Opcode = 0x22; break; + case 0x30: A.Opcode = 0x23; break; + case 0x47: A.Opcode = 0x44; break; + case 0x57: A.Opcode = 0x54; break; + case 0x93: A.Opcode = 0x82; break; + case 0x9C: A.Opcode = 0x8B; break; + case 0x9E: A.Opcode = 0x9B; break; + case 0xAF: A.Opcode = 0xAB; break; + case 0xBF: A.Opcode = 0xBB; break; + case 0xB3: A.Opcode = 0xE2; break; + case 0xD0: A.Opcode = 0xC2; break; + default: /*nothing*/ break; + } + + /* No error, output code */ + EmitCode (&A); + } +} + + + /*****************************************************************************/ /* Handler functions for SWEET16 */ /*****************************************************************************/ diff --git a/src/ca65/instr.h b/src/ca65/instr.h index 1f2ce262b..0a1a5e13d 100644 --- a/src/ca65/instr.h +++ b/src/ca65/instr.h @@ -85,6 +85,7 @@ #define AM65_BLOCKMOVE 0x01000000UL #define AM65_BLOCKXFER 0x02000000UL #define AM65_ABS_IND_LONG 0x04000000UL +#define AM65_IMM_IMPLICIT_WORD 0x08000000UL /* PHW #$1234 (4510 only) */ /* Bitmask for all ZP operations that have correspondent ABS ops */ #define AM65_SET_ZP (AM65_DIR | AM65_DIR_X | AM65_DIR_Y | AM65_DIR_IND | AM65_DIR_X_IND) @@ -102,13 +103,14 @@ #define AM65_ALL_FAR (AM65_ABS_LONG | AM65_ABS_LONG_X) /* Bitmask for all immediate operations */ -#define AM65_ALL_IMM (AM65_IMM_ACCU | AM65_IMM_INDEX | AM65_IMM_IMPLICIT) +#define AM65_ALL_IMM (AM65_IMM_ACCU | AM65_IMM_INDEX | AM65_IMM_IMPLICIT | AM65_IMM_IMPLICIT_WORD) /* Bit numbers and count */ #define AM65I_IMM_ACCU 21 #define AM65I_IMM_INDEX 22 #define AM65I_IMM_IMPLICIT 23 -#define AM65I_COUNT 27 +#define AM65I_IMM_IMPLICIT_WORD 27 +#define AM65I_COUNT 28 diff --git a/src/ca65/main.c b/src/ca65/main.c index a67319747..d6c364e4b 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -226,6 +226,10 @@ static void SetSys (const char* Sys) CBMSystem ("__C64__"); break; + case TGT_C65: + CBMSystem ("__C65__"); + break; + case TGT_VIC20: CBMSystem ("__VIC20__"); break; diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 799321066..4fde5ac5e 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1109,60 +1109,76 @@ Again: /* Check for special names. Bail out if we have identified the type of ** the token. Go on if the token is an identifier. */ - if (SB_GetLen (&CurTok.SVal) == 1) { - switch (toupper (SB_AtUnchecked (&CurTok.SVal, 0))) { + switch (SB_GetLen (&CurTok.SVal)) { + case 1: + switch (toupper (SB_AtUnchecked (&CurTok.SVal, 0))) { - case 'A': - if (C == ':') { - NextChar (); - CurTok.Tok = TOK_OVERRIDE_ABS; - } else { - CurTok.Tok = TOK_A; - } - return; - - case 'F': - if (C == ':') { - NextChar (); - CurTok.Tok = TOK_OVERRIDE_FAR; + case 'A': + if (C == ':') { + NextChar (); + CurTok.Tok = TOK_OVERRIDE_ABS; + } else { + CurTok.Tok = TOK_A; + } return; - } - break; - case 'S': - if (CPU == CPU_65816) { - CurTok.Tok = TOK_S; + case 'F': + if (C == ':') { + NextChar (); + CurTok.Tok = TOK_OVERRIDE_FAR; + return; + } + break; + + case 'S': + if ((CPU == CPU_4510) || (CPU == CPU_65816)) { + CurTok.Tok = TOK_S; + return; + } + break; + + case 'X': + CurTok.Tok = TOK_X; return; - } - break; - case 'X': - CurTok.Tok = TOK_X; - return; - - case 'Y': - CurTok.Tok = TOK_Y; - return; - - case 'Z': - if (C == ':') { - NextChar (); - CurTok.Tok = TOK_OVERRIDE_ZP; + case 'Y': + CurTok.Tok = TOK_Y; return; - } - break; - default: - break; - } + case 'Z': + if (C == ':') { + NextChar (); + CurTok.Tok = TOK_OVERRIDE_ZP; + return; + } else { + if (CPU == CPU_4510) { + CurTok.Tok = TOK_Z; + return; + } + } + break; - } else if (CPU == CPU_SWEET16 && - (CurTok.IVal = Sweet16Reg (&CurTok.SVal)) >= 0) { + default: + break; + } + break; + case 2: + if ((CPU == CPU_4510) && + (toupper (SB_AtUnchecked (&CurTok.SVal, 0)) == 'S') && + (toupper (SB_AtUnchecked (&CurTok.SVal, 1)) == 'P')) { - /* A sweet16 register number in sweet16 mode */ - CurTok.Tok = TOK_REG; - return; + CurTok.Tok = TOK_S; + return; + } + /* fall through */ + default: + if (CPU == CPU_SWEET16 && + (CurTok.IVal = Sweet16Reg (&CurTok.SVal)) >= 0) { + /* A sweet16 register number in sweet16 mode */ + CurTok.Tok = TOK_REG; + return; + } } /* Check for define style macro */ diff --git a/src/ca65/token.h b/src/ca65/token.h index bfc013a3d..93dfaa092 100644 --- a/src/ca65/token.h +++ b/src/ca65/token.h @@ -66,6 +66,7 @@ typedef enum token_t { TOK_A, /* A)ccumulator */ TOK_X, /* X register */ TOK_Y, /* Y register */ + TOK_Z, /* Z register */ TOK_S, /* S register */ TOK_REG, /* Sweet16 R.. register (in sweet16 mode) */ diff --git a/src/common/cpu.c b/src/common/cpu.c index 142d55258..b055fae88 100644 --- a/src/common/cpu.c +++ b/src/common/cpu.c @@ -61,6 +61,7 @@ const char* CPUNames[CPU_COUNT] = { "sweet16", "huc6280", "m740", + "4510", }; /* Tables with CPU instruction sets */ @@ -74,6 +75,7 @@ const unsigned CPUIsets[CPU_COUNT] = { CPU_ISET_SWEET16, CPU_ISET_6502 | CPU_ISET_65SC02 | CPU_ISET_65C02 | CPU_ISET_HUC6280, CPU_ISET_6502 | CPU_ISET_M740, + CPU_ISET_6502 | CPU_ISET_65SC02 | CPU_ISET_65C02 | CPU_ISET_4510, }; diff --git a/src/common/cpu.h b/src/common/cpu.h index 5bdbdef8c..dcf1815db 100644 --- a/src/common/cpu.h +++ b/src/common/cpu.h @@ -56,6 +56,7 @@ typedef enum { CPU_SWEET16, CPU_HUC6280, /* Used in PC engine */ CPU_M740, /* Mitsubishi 740 series MCUs */ + CPU_4510, /* CPU of C65 */ CPU_COUNT /* Number of different CPUs */ } cpu_t; @@ -70,6 +71,7 @@ enum { CPU_ISET_SWEET16 = 1 << CPU_SWEET16, CPU_ISET_HUC6280 = 1 << CPU_HUC6280, CPU_ISET_M740 = 1 << CPU_M740, + CPU_ISET_4510 = 1 << CPU_4510, }; /* CPU used */ diff --git a/src/common/target.c b/src/common/target.c index c7b9a3d98..99a134c43 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -152,6 +152,7 @@ static const TargetEntry TargetMap[] = { { "c128", TGT_C128 }, { "c16", TGT_C16 }, { "c64", TGT_C64 }, + { "c65", TGT_C65 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, { "gamate", TGT_GAMATE }, @@ -205,6 +206,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, + { "c65", CPU_4510, BINFMT_BINARY, CTPET }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 6366b725f..4115ae21a 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -80,6 +80,7 @@ typedef enum { TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, + TGT_C65, TGT_COUNT /* Number of target systems */ } target_t; diff --git a/testcode/assembler/.gitignore b/testcode/assembler/.gitignore index de179f4f3..0f7f86d78 100644 --- a/testcode/assembler/.gitignore +++ b/testcode/assembler/.gitignore @@ -1,6 +1,3 @@ -chkillegal.bin -chklegal.bin -chkall.bin -legal.o -illegal.o -all.o +*.bin +*.o +*.lst diff --git a/testcode/assembler/4510all.ref b/testcode/assembler/4510all.ref new file mode 100644 index 0000000000000000000000000000000000000000..b65b12e616ea7649bc4f0750e57c77870140d231 GIT binary patch literal 564 zcmWN<1$Y%l6b4ZCpX_deJ-D-2aT45inA;XBKDf)`?$F{;q*!oT+=IKjySuv<Noj$g z#T|0Klfbee!eGOJi|`05VWPxLNtlu{g`ku9$sKZ~QXW!>lp+;UrwP0t(xzidZ)64| zGeT!#%4}ybk&!`E6tW^4vLi=MD_8D3OnI5|G3AH$edQEzwNfm86hDcdQLs?p6)sZL z$X|>sW@K^b5+&_YrOUveEXtvL1*>AE%1l+5sxnoBuI|@xYPz+Qsx9h>K-5LO`hnM= zVWY-IHZig(bhGAmi-?v=wL)vOL0hzIZ*}PStBL%LsS{IY=q`R&r<>bdsUD)I=p}wf z?>>Rox8EN@RDUA}7&#DnkU!Xt4n>ECC^ZzrFdQQ=a+EdtPb2?g8pAY}X&m%;e}Xg7 zout%cF-1%bn}+E#0xxD};LT#1ZR8vy=R(i3=GzObh1Mc0#u6;WvgOu_l}xLcRx_<( zS_{3-U+-*iH!8JBY!+L>wqo1%z}vCY$X!P6HgZqk?S<ZF?Y9qD2XP38aRf(k?6`H} zB-1IT(@bZW&O)E_&pQ{~i%MO>WpPDZ#kK2!cjM+QroWB6ZR8#3yVgBBHWVBB2lw$W z{=)-2d}PJNJ!X2s^pxot({tz-{{PNP_mxtwW5VOV5pTsiy#Ek*A3uF&ivPvPuSR}@ F{totBq=Nte literal 0 HcmV?d00001 diff --git a/testcode/assembler/4510all.s b/testcode/assembler/4510all.s new file mode 100644 index 000000000..997ddd05d --- /dev/null +++ b/testcode/assembler/4510all.s @@ -0,0 +1,278 @@ + .setcpu "4510" + + brk + ora ($05,x) + cle + see + tsb $02 + ora $02 + asl $02 + rmb0 $02 + php + ora #$01 + asl + tsy + tsb $1234 + ora $1234 + asl $1234 + bbr0 $02,*+$34 + + bpl *+$32 + ora ($06),y + ora ($07),z + lbpl *+$3133 ; bpl *+$3133 + trb $02 + ora $03,x + asl $03,x + rmb1 $02 + clc + ora $1456,y + inc + inz + trb $1234 + ora $1345,x + asl $1345,x + bbr1 $02,*+$34 + + jsr $1234 + and ($05,x) + jsr ($2345) + jsr ($2456,x) + bit $02 + and $02 + rol $02 + rmb2 $02 + plp + and #$01 + rol + tys + bit $1234 + and $1234 + rol $1234 + bbr2 $02,*+$34 + + bmi *+$32 + and ($06),y + and ($07),z + lbmi *+$3133 ; bmi *+$3133 + bit $03,x + and $03,x + rol $03,x + rmb3 $02 + sec + and $1456,y + dec + dez + bit $1345,x + and $1345,x + rol $1345,x + bbr3 $02,*+$34 + + rti + eor ($05,x) + neg + asr + asr $02 + eor $02 + lsr $02 + rmb4 $02 + pha + eor #$01 + lsr + taz + jmp $1234 + eor $1234 + lsr $1234 + bbr4 $02,*+$34 + + bvc *+$32 + eor ($06),y + eor ($07),z + lbvc *+$3133 ; bvc *+$3133 + asr $03,x + eor $03,x + lsr $03,x + rmb5 $02 + cli + eor $1456,y + phy + tab + map + eor $1345,x + lsr $1345,x + bbr5 $02,*+$34 + + rts + adc ($05,x) + rtn #$09 + bsr *+$3133 + stz $02 + adc $02 + ror $02 + rmb6 $02 + pla + adc #$01 + ror + tza + jmp ($2345) + adc $1234 + ror $1234 + bbr6 $02,*+$34 + + bvs *+$32 + adc ($06),y + adc ($07),z + lbvs *+$3133 ; bvs *+$3133 + stz $03,x + adc $03,x + ror $03,x + rmb7 $02 + sei + adc $1456,y + ply + tba + jmp ($2456,x) + adc $1345,x + ror $1345,x + bbr7 $02,*+$34 + + bra *+$32 + sta ($05,x) + sta ($0f,s),y + sta ($0f,sp),y + lbra *+$3133 ; bra *+$3133 + sty $02 + sta $02 + stx $02 + smb0 $02 + dey + bit #$01 + txa + sty $1345,x + sty $1234 + sta $1234 + stx $1234 + bbs0 $02,*+$34 + + bcc *+$32 + sta ($06),y + sta ($07),z + lbcc *+$3133 ; bcc *+$3133 + sty $03,x + sta $03,x + stx $04,y + smb1 $02 + tya + sta $1456,y + txs + stx $1456,y + stz $1234 + sta $1345,x + stz $1345,x + bbs1 $02,*+$34 + + ldy #$01 + lda ($05,x) + ldx #$01 + ldz #$01 + ldy $02 + lda $02 + ldx $02 + smb2 $02 + tay + lda #$01 + tax + ldz $1234 + ldy $1234 + lda $1234 + ldx $1234 + bbs2 $02,*+$34 + + bcs *+$32 + lda ($06),y + lda ($07),z + lbcs *+$3133 ; bcs *+$3133 + ldy $03,x + lda $03,x + ldx $04,y + smb3 $02 + clv + lda $1456,y + tsx + ldz $1345,x + ldy $1345,x + lda $1345,x + ldx $1456,y + bbs3 $02,*+$34 + + cpy #$01 + cmp ($05,x) + cpz #$01 + dew $02 + cpy $02 + cmp $02 + dec $02 + smb4 $02 + iny + cmp #$01 + dex + asw $1234 + cpy $1234 + cmp $1234 + dec $1234 + bbs4 $02,*+$34 + + bne *+$32 + cmp ($06),y + cmp ($07),z + lbne *+$3133 ; bne *+$3133 + cpz $02 + cmp $03,x + dec $03,x + smb5 $02 + cld + cmp $1456,y + phx + phz + cpz $1234 + cmp $1345,x + dec $1345,x + bbs5 $02,*+$34 + + cpx #$01 + sbc ($05,x) + lda ($0f,s),y + lda ($0f,sp),y + inw $02 + cpx $02 + sbc $02 + inc $02 + smb6 $02 + inx + sbc #$01 + eom + nop + row $1234 + cpx $1234 + sbc $1234 + inc $1234 + bbs6 $02,*+$34 + + beq *+$32 + sbc ($06),y + sbc ($07),z + lbeq *+$3133 ; beq *+$3133 + phd #$089a + phw #$089a + sbc $03,x + inc $03,x + smb7 $02 + sed + sbc $1456,y + plx + plz + phd $1234 + phw $1234 + sbc $1345,x + inc $1345,x + bbs7 $02,*+$34 diff --git a/testcode/assembler/Makefile b/testcode/assembler/Makefile index a9257ce75..35c34235a 100644 --- a/testcode/assembler/Makefile +++ b/testcode/assembler/Makefile @@ -1,8 +1,13 @@ -all: chklegal.bin chkillegal.bin chkall.bin +all: chklegal.bin chkillegal.bin chkall.bin chk4510.bin @# -.PHONY: chklegal.bin chkillegal.bin chkall.bin +.PHONY: chklegal.bin chkillegal.bin chkall.bin chk4510.bin + +chk4510.bin: 4510all.s + $(MAKE) -C ../../src all + ../../bin/cl65 --target none --cpu 4510 --listing 4510all.lst -o $@ $< + diff -q 4510all.ref $@ || cat 4510all.lst chklegal.bin: legal.s ../../bin/cl65 --target none --cpu 6502X -o chklegal.bin legal.s @@ -23,3 +28,5 @@ clean: rm -f legal.o chklegal.bin rm -f illegal.o chkillegal.bin rm -f all.o chkall.bin + rm -f 4510all.o chk4510.bin 4510all.lst + From 91f8e09bcc172a09da2e90177fbf6f1641c6c0dd Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Mon, 29 Aug 2016 23:29:31 +0200 Subject: [PATCH 143/407] 4510 support: fixed some cosmetical stuff and documentation --- doc/ca65.sgml | 12 ++++++++---- src/ca65/ea65.c | 9 ++++----- src/ca65/instr.c | 46 +++++++++++++++++++++++----------------------- src/ca65/scanner.c | 2 +- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index f59ce44cb..80515fc50 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -476,10 +476,13 @@ from the mentioned web page, for more information, see there. <sect1>4510 mode<p> The 4510 is a microcontroller that is the core of the Commodore C65 aka C64DX. -It contains among other functions a slightly modified 65CE02 CPU, to allow +It contains among other functions a slightly modified 65CE02/4502 CPU, to allow address mapping for 20 bits of address space (1 megabyte addressable area). -As compared to the description of the CPU in the System Specification of the -Commodore C65 aka C64DX prototypes ca65 uses these changes: +As compared to the description of the CPU in the +<url url="http://www.zimmers.net/anonftp/pub/cbm/c65/c65manualupdated.txt.gz" +name="C65 System Specification"> +<url url="https://raw.githubusercontent.com/MEGA65/c65-specifications/master/c65manualupdated.txt" +name="(updated version)"> uses these changes: <itemize> <item><tt>LDA (d,SP),Y</tt> may also be written as <tt>LDA (d,S),Y</tt> (matching the 65816 notataion). @@ -488,7 +491,8 @@ branch you have to prefix these with an "L" (e.g. "<tt>LBNE</tt>" instead of "<tt>BNE</tt>"). This might change at a later implementation of the assember. </itemize> For more information about the Commodore C65/C64DX and the 4510 CPU, see -<url url="http://www.zimmers.net/anonftp/pub/cbm/c65/c65manualupdated.txt.gz">. +<url url="http://www.zimmers.net/anonftp/pub/cbm/c65/"> and +<url url="https://en.wikipedia.org/wiki/Commodore_65" name="Wikipedia">. <sect1>sweet16 mode<label id="sweet16-mode"><p> diff --git a/src/ca65/ea65.c b/src/ca65/ea65.c index e146ab8c9..2f7c2bfa9 100644 --- a/src/ca65/ea65.c +++ b/src/ca65/ea65.c @@ -145,12 +145,11 @@ void GetEA (EffAddr* A) if (CurTok.Tok == TOK_COMMA) { /* (adr),y */ NextTok (); - switch(CurTok.Tok) { + switch (CurTok.Tok) { case TOK_Z: - if (CPU == CPU_4510) { - NextTok (); - A->AddrModeSet = AM65_DIR_IND; - } + /* only set by scanner.c if in 4510-mode */ + NextTok (); + A->AddrModeSet = AM65_DIR_IND; break; default: Consume (TOK_Y, "`Y' expected"); diff --git a/src/ca65/instr.c b/src/ca65/instr.c index a4365402d..26722fab3 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -1290,7 +1290,7 @@ static void PutPCRel16 (const InsDesc* Ins) static void PutPCRel4510 (const InsDesc* Ins) /* Handle branches with a 16 bit distance */ { - /* 16 bit branch opcode is 8 bit branch opcode or 0x03 */ + /* 16 bit branch opcode is 8 bit branch opcode or'ed with 0x03 */ EmitPCRel (Ins->BaseCode, GenBranchExpr (2), 2); } @@ -1543,33 +1543,33 @@ static void PutAll (const InsDesc* Ins) static void Put4510 (const InsDesc* Ins) -/* Handle all other instructions */ +/* Handle all other instructions, with modifications for 4510 */ { - /* The 4510 uses all 256 possible opcodes, so the last ones were cramped - * in where an opcode was still undefined. As a result, some of those - * don't follow any rules for encoding the addressmodes. So the EATab - * approach does not work always. In this function, the wrongly calculated - * opcode is replaced by the correct one "on the fly". Suggestions for a - * better approach are welcome. - * - * These are: - * $20 -> $22 : JSR ($1234) NEED TO CHECK FOR ADDRESSING - * $30 -> $23 : JSR ($1234,X) - * $47 -> $44 : ASR $12 - * $57 -> $54 : ASR $12,X - * $93 -> $82 : STA ($12,SP),Y - * $9c -> $8b : STY $1234,X - * $9e -> $9b : STX $1234,Y - * $af -> $ab : LDZ $1234 - * $bf -> $bb : LDZ $1234,X - * $b3 -> $e2 : LDA ($12,SP),Y - * $d0 -> $c2 : CPZ #$00 - */ + /* The 4510 uses all 256 possible opcodes, so the last ones were crammed + ** in where an opcode was still undefined. As a result, some of those + ** don't follow any rules for encoding the addressmodes. So the EATab + ** approach does not work always. In this function, the wrongly calculated + ** opcode is replaced by the correct one "on the fly". Suggestions for a + ** better approach are welcome. + ** + ** These are: + ** $20 -> $22 : JSR ($1234) NEED TO CHECK FOR ADDRESSING + ** $30 -> $23 : JSR ($1234,X) + ** $47 -> $44 : ASR $12 + ** $57 -> $54 : ASR $12,X + ** $93 -> $82 : STA ($12,SP),Y + ** $9c -> $8b : STY $1234,X + ** $9e -> $9b : STX $1234,Y + ** $af -> $ab : LDZ $1234 + ** $bf -> $bb : LDZ $1234,X + ** $b3 -> $e2 : LDA ($12,SP),Y + ** $d0 -> $c2 : CPZ #$00 + */ EffAddr A; /* Evaluate the addressing mode used */ if (EvalEA (Ins, &A)) { - switch(A.Opcode) { + switch (A.Opcode) { case 0x20: if(A.AddrModeBit == AM65_ABS_IND) A.Opcode = 0x22; break; case 0x30: A.Opcode = 0x23; break; case 0x47: A.Opcode = 0x44; break; diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 4fde5ac5e..f33ed5def 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1170,7 +1170,7 @@ Again: CurTok.Tok = TOK_S; return; } - /* fall through */ + /* FALL THROUGH */ default: if (CPU == CPU_SWEET16 && (CurTok.IVal = Sweet16Reg (&CurTok.SVal)) >= 0) { From 4384603eebfa04dba9e625775d1f1f3a009e55f5 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Tue, 30 Aug 2016 22:58:40 +0200 Subject: [PATCH 144/407] 4510 support: added some other small improvements: - fixed typo in doc/ca65.sgml - Greg found a way to get rid of one extra opcode handling in total --- doc/ca65.sgml | 2 +- src/ca65/instr.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 80515fc50..6ce5ecef6 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -488,7 +488,7 @@ name="(updated version)"> uses these changes: (matching the 65816 notataion). <item>All branch instruction allow now 16 bit offsets. To use a 16 bit branch you have to prefix these with an "L" (e.g. "<tt>LBNE</tt>" instead of -"<tt>BNE</tt>"). This might change at a later implementation of the assember. +"<tt>BNE</tt>"). This might change at a later implementation of the assembler. </itemize> For more information about the Commodore C65/C64DX and the 4510 CPU, see <url url="http://www.zimmers.net/anonftp/pub/cbm/c65/"> and diff --git a/src/ca65/instr.c b/src/ca65/instr.c index 26722fab3..e2819e7cc 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -540,7 +540,7 @@ static const struct { { "CPZ", 0x080000C, 0xd0, 1, Put4510 }, { "DEA", 0x0000001, 0x00, 3, PutAll }, /* == DEC */ { "DEC", 0x000006F, 0x00, 3, PutAll }, - { "DEW", 0x0000004, 0xc3, 7, PutAll }, /* trial'n'error */ + { "DEW", 0x0000004, 0xc3, 9, PutAll }, { "DEX", 0x0000001, 0xca, 0, PutAll }, { "DEY", 0x0000001, 0x88, 0, PutAll }, { "DEZ", 0x0000001, 0x3B, 0, PutAll }, @@ -548,12 +548,12 @@ static const struct { { "EOR", 0x080A66C, 0x40, 0, PutAll }, { "INA", 0x0000001, 0x00, 4, PutAll }, /* == INC */ { "INC", 0x000006f, 0x00, 4, PutAll }, - { "INW", 0x0000004, 0xe3, 7, PutAll }, /* trial'n'error */ + { "INW", 0x0000004, 0xe3, 9, PutAll }, { "INX", 0x0000001, 0xe8, 0, PutAll }, { "INY", 0x0000001, 0xc8, 0, PutAll }, { "INZ", 0x0000001, 0x1B, 0, PutAll }, { "JMP", 0x0010808, 0x4c, 6, PutAll }, - { "JSR", 0x0010808, 0x20, 6, Put4510 }, + { "JSR", 0x0010808, 0x20, 7, Put4510 }, { "LBCC", 0x0040000, 0x93, 0, PutPCRel4510 }, { "LBCS", 0x0040000, 0xb3, 0, PutPCRel4510 }, { "LBEQ", 0x0040000, 0xf3, 0, PutPCRel4510 }, @@ -985,9 +985,9 @@ static unsigned char EATab[12][AM65I_COUNT] = { 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00 }, - { /* Table 7 */ + { /* Table 7 (Subroutine opcodes) */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, @@ -1553,8 +1553,6 @@ static void Put4510 (const InsDesc* Ins) ** better approach are welcome. ** ** These are: - ** $20 -> $22 : JSR ($1234) NEED TO CHECK FOR ADDRESSING - ** $30 -> $23 : JSR ($1234,X) ** $47 -> $44 : ASR $12 ** $57 -> $54 : ASR $12,X ** $93 -> $82 : STA ($12,SP),Y @@ -1564,14 +1562,13 @@ static void Put4510 (const InsDesc* Ins) ** $bf -> $bb : LDZ $1234,X ** $b3 -> $e2 : LDA ($12,SP),Y ** $d0 -> $c2 : CPZ #$00 + ** $fc -> $23 : JSR ($1234,X) */ EffAddr A; /* Evaluate the addressing mode used */ if (EvalEA (Ins, &A)) { switch (A.Opcode) { - case 0x20: if(A.AddrModeBit == AM65_ABS_IND) A.Opcode = 0x22; break; - case 0x30: A.Opcode = 0x23; break; case 0x47: A.Opcode = 0x44; break; case 0x57: A.Opcode = 0x54; break; case 0x93: A.Opcode = 0x82; break; @@ -1581,6 +1578,7 @@ static void Put4510 (const InsDesc* Ins) case 0xBF: A.Opcode = 0xBB; break; case 0xB3: A.Opcode = 0xE2; break; case 0xD0: A.Opcode = 0xC2; break; + case 0xFC: A.Opcode = 0x23; break; default: /*nothing*/ break; } From 48f64de72048c0f514df2a616f34c456955333ef Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Wed, 31 Aug 2016 20:18:54 +0200 Subject: [PATCH 145/407] 4510 support: yet another round up little updates --- asminc/cpu.mac | 2 ++ src/ca65/instr.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/asminc/cpu.mac b/asminc/cpu.mac index 6b8aa6d7b..6a5482d1e 100644 --- a/asminc/cpu.mac +++ b/asminc/cpu.mac @@ -7,6 +7,7 @@ CPU_ISET_65C02 = $0010 CPU_ISET_65816 = $0020 CPU_ISET_SWEET16 = $0040 CPU_ISET_HUC6280 = $0080 +CPU_ISET_4510 = $0100 ; CPU capabilities CPU_NONE = CPU_ISET_NONE @@ -17,3 +18,4 @@ CPU_65C02 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02 CPU_65816 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65816 CPU_SWEET16 = CPU_ISET_SWEET16 CPU_HUC6280 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02|CPU_ISET_HUC6280 +CPU_4510 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02|CPU_ISET_4510 diff --git a/src/ca65/instr.c b/src/ca65/instr.c index e2819e7cc..5e7904992 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -1579,7 +1579,7 @@ static void Put4510 (const InsDesc* Ins) case 0xB3: A.Opcode = 0xE2; break; case 0xD0: A.Opcode = 0xC2; break; case 0xFC: A.Opcode = 0x23; break; - default: /*nothing*/ break; + default: /* Keep opcode as it is */ break; } /* No error, output code */ From 579b89ad98869d13a8f65f9a37e61485243a5c38 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 31 Aug 2016 20:41:17 -0400 Subject: [PATCH 146/407] Skipped the bit flag for the (not implemented) Mitsubishi 740 in "cpu.mac". --- asminc/cpu.mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asminc/cpu.mac b/asminc/cpu.mac index 6a5482d1e..93711427c 100644 --- a/asminc/cpu.mac +++ b/asminc/cpu.mac @@ -7,7 +7,7 @@ CPU_ISET_65C02 = $0010 CPU_ISET_65816 = $0020 CPU_ISET_SWEET16 = $0040 CPU_ISET_HUC6280 = $0080 -CPU_ISET_4510 = $0100 +CPU_ISET_4510 = $0200 ; CPU capabilities CPU_NONE = CPU_ISET_NONE From 4b2e3be2fc2211ab5e49867fcd3370e80b6a72f8 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Fri, 2 Sep 2016 14:24:29 -0400 Subject: [PATCH 147/407] Fixed some bugs in da65's HuC6280 section. --- src/da65/handler.c | 40 ++++++++++++++++++++++++++++++++++++---- src/da65/handler.h | 3 ++- src/da65/opchuc6280.c | 38 +++++++++++++++++++------------------- 3 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/da65/handler.c b/src/da65/handler.c index 0806301fe..c034aed14 100644 --- a/src/da65/handler.c +++ b/src/da65/handler.c @@ -36,6 +36,7 @@ #include <stdarg.h> /* common */ +#include "xmalloc.h" #include "xsprintf.h" /* da65 */ @@ -406,6 +407,8 @@ void OH_AbsoluteIndirect (const OpcDesc* D) void OH_BitBranch (const OpcDesc* D) { + char* BranchLabel; + /* Get the operands */ unsigned char TestAddr = GetCodeByte (PC+1); signed char BranchOffs = GetCodeByte (PC+2); @@ -421,8 +424,16 @@ void OH_BitBranch (const OpcDesc* D) GenerateLabel (D->Flags, TestAddr); GenerateLabel (flLabel, BranchAddr); + /* Make a copy of an operand, so that + ** the other operand can't overwrite it. + ** [GetAddrArg() uses a statically-stored buffer.] + */ + BranchLabel = xstrdup (GetAddrArg (flLabel, BranchAddr)); + /* Output the line */ - OneLine (D, "%s,%s", GetAddrArg (D->Flags, TestAddr), GetAddrArg (flLabel, BranchAddr)); + OneLine (D, "%s,%s", GetAddrArg (D->Flags, TestAddr), BranchLabel); + + xfree (BranchLabel); } @@ -518,8 +529,10 @@ void OH_DirectIndirectLongY (const OpcDesc* D attribute ((unused))) -void OH_BlockMove (const OpcDesc* D attribute ((unused))) +void OH_BlockMove (const OpcDesc* D) { + char* DstLabel; + /* Get source operand */ unsigned Src = GetCodeWord (PC+1); /* Get destination operand */ @@ -529,11 +542,19 @@ void OH_BlockMove (const OpcDesc* D attribute ((unused))) GenerateLabel (D->Flags, Src); GenerateLabel (D->Flags, Dst); + /* Make a copy of an operand, so that + ** the other operand can't overwrite it. + ** [GetAddrArg() uses a statically-stored buffer.] + */ + DstLabel = xstrdup (GetAddrArg (D->Flags, Dst)); + /* Output the line */ - OneLine (D, "%s%s,%s%s,#$%02X", + OneLine (D, "%s%s,%s%s,$%04X", GetAbsOverride (D->Flags, Src), GetAddrArg (D->Flags, Src), - GetAbsOverride (D->Flags, Dst), GetAddrArg (D->Flags, Dst), + GetAbsOverride (D->Flags, Dst), DstLabel, GetCodeWord (PC+5)); + + xfree (DstLabel); } @@ -662,3 +683,14 @@ void OH_JmpAbsoluteIndirect (const OpcDesc* D) } SeparatorLine (); } + + + +void OH_JmpAbsoluteXIndirect (const OpcDesc* D) +{ + OH_AbsoluteXIndirect (D); + if (NewlineAfterJMP) { + LineFeed (); + } + SeparatorLine (); +} diff --git a/src/da65/handler.h b/src/da65/handler.h index 77da618c1..433ba2594 100644 --- a/src/da65/handler.h +++ b/src/da65/handler.h @@ -94,11 +94,12 @@ void OH_AccumulatorBit (const OpcDesc*); void OH_AccumulatorBitBranch (const OpcDesc*); void OH_JmpDirectIndirect (const OpcDesc* D); void OH_SpecialPage (const OpcDesc*); - + /* Handlers for special instructions */ void OH_Rts (const OpcDesc*); void OH_JmpAbsolute (const OpcDesc*); void OH_JmpAbsoluteIndirect (const OpcDesc* D); +void OH_JmpAbsoluteXIndirect (const OpcDesc* D); diff --git a/src/da65/opchuc6280.c b/src/da65/opchuc6280.c index df6ba587b..6c5b0b1ad 100644 --- a/src/da65/opchuc6280.c +++ b/src/da65/opchuc6280.c @@ -54,7 +54,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "tsb", 2, flUseLabel, OH_Direct }, /* $04 */ { "ora", 2, flUseLabel, OH_Direct }, /* $05 */ { "asl", 2, flUseLabel, OH_Direct }, /* $06 */ - { "rmb0", 1, flUseLabel, OH_Direct, }, /* $07 */ + { "rmb0", 2, flUseLabel, OH_Direct, }, /* $07 */ { "php", 1, flNone, OH_Implicit }, /* $08 */ { "ora", 2, flNone, OH_Immediate }, /* $09 */ { "asl", 1, flNone, OH_Accumulator }, /* $0a */ @@ -70,7 +70,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "trb", 2, flUseLabel, OH_Direct }, /* $14 */ { "ora", 2, flUseLabel, OH_DirectX }, /* $15 */ { "asl", 2, flUseLabel, OH_DirectX }, /* $16 */ - { "rmb1", 1, flUseLabel, OH_Direct, }, /* $17 */ + { "rmb1", 2, flUseLabel, OH_Direct, }, /* $17 */ { "clc", 1, flNone, OH_Implicit }, /* $18 */ { "ora", 3, flUseLabel, OH_AbsoluteY }, /* $19 */ { "inc", 1, flNone, OH_Accumulator }, /* $1a */ @@ -86,7 +86,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "bit", 2, flUseLabel, OH_Direct }, /* $24 */ { "and", 2, flUseLabel, OH_Direct }, /* $25 */ { "rol", 2, flUseLabel, OH_Direct }, /* $26 */ - { "rmb2", 1, flUseLabel, OH_Direct, }, /* $27 */ + { "rmb2", 2, flUseLabel, OH_Direct, }, /* $27 */ { "plp", 1, flNone, OH_Implicit }, /* $28 */ { "and", 2, flNone, OH_Immediate }, /* $29 */ { "rol", 1, flNone, OH_Accumulator }, /* $2a */ @@ -102,7 +102,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "bit", 2, flUseLabel, OH_DirectX }, /* $34 */ { "and", 2, flUseLabel, OH_DirectX }, /* $35 */ { "rol", 2, flUseLabel, OH_DirectX }, /* $36 */ - { "rmb3", 1, flUseLabel, OH_Direct, }, /* $37 */ + { "rmb3", 2, flUseLabel, OH_Direct, }, /* $37 */ { "sec", 1, flNone, OH_Implicit }, /* $38 */ { "and", 3, flUseLabel, OH_AbsoluteY }, /* $39 */ { "dec", 1, flNone, OH_Accumulator }, /* $3a */ @@ -114,11 +114,11 @@ const OpcDesc OpcTable_HuC6280[256] = { { "rti", 1, flNone, OH_Rts }, /* $40 */ { "eor", 2, flUseLabel, OH_DirectXIndirect }, /* $41 */ { "say", 1, flNone, OH_Implicit, }, /* $42 */ - { "tmai", 2, flNone, OH_Immediate, }, /* $43 */ + { "tma", 2, flNone, OH_Immediate, }, /* $43 */ { "bsr", 2, flLabel, OH_Relative, }, /* $44 */ { "eor", 2, flUseLabel, OH_Direct }, /* $45 */ { "lsr", 2, flUseLabel, OH_Direct }, /* $46 */ - { "rmb4", 1, flUseLabel, OH_Direct, }, /* $47 */ + { "rmb4", 2, flUseLabel, OH_Direct, }, /* $47 */ { "pha", 1, flNone, OH_Implicit }, /* $48 */ { "eor", 2, flNone, OH_Immediate }, /* $49 */ { "lsr", 1, flNone, OH_Accumulator }, /* $4a */ @@ -130,11 +130,11 @@ const OpcDesc OpcTable_HuC6280[256] = { { "bvc", 2, flLabel, OH_Relative }, /* $50 */ { "eor", 2, flUseLabel, OH_DirectIndirectY }, /* $51 */ { "eor", 2, flUseLabel, OH_DirectIndirect }, /* $52 */ - { "tami", 2, flNone, OH_Immediate, }, /* $53 */ + { "tam", 2, flNone, OH_Immediate, }, /* $53 */ { "csl", 1, flNone, OH_Implicit, }, /* $54 */ { "eor", 2, flUseLabel, OH_DirectX }, /* $55 */ { "lsr", 2, flUseLabel, OH_DirectX }, /* $56 */ - { "rmb5", 1, flUseLabel, OH_Direct, }, /* $57 */ + { "rmb5", 2, flUseLabel, OH_Direct, }, /* $57 */ { "cli", 1, flNone, OH_Implicit }, /* $58 */ { "eor", 3, flUseLabel, OH_AbsoluteY }, /* $59 */ { "phy", 1, flNone, OH_Implicit }, /* $5a */ @@ -150,7 +150,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "stz", 2, flUseLabel, OH_Direct }, /* $64 */ { "adc", 2, flUseLabel, OH_Direct }, /* $65 */ { "ror", 2, flUseLabel, OH_Direct }, /* $66 */ - { "rmb6", 1, flUseLabel, OH_Direct, }, /* $67 */ + { "rmb6", 2, flUseLabel, OH_Direct, }, /* $67 */ { "pla", 1, flNone, OH_Implicit }, /* $68 */ { "adc", 2, flNone, OH_Immediate }, /* $69 */ { "ror", 1, flNone, OH_Accumulator }, /* $6a */ @@ -166,12 +166,12 @@ const OpcDesc OpcTable_HuC6280[256] = { { "stz", 2, flUseLabel, OH_DirectX }, /* $74 */ { "adc", 2, flUseLabel, OH_DirectX }, /* $75 */ { "ror", 2, flUseLabel, OH_DirectX }, /* $76 */ - { "rmb7", 1, flUseLabel, OH_Direct, }, /* $77 */ + { "rmb7", 2, flUseLabel, OH_Direct, }, /* $77 */ { "sei", 1, flNone, OH_Implicit }, /* $78 */ { "adc", 3, flUseLabel, OH_AbsoluteY }, /* $79 */ { "ply", 1, flNone, OH_Implicit }, /* $7a */ { "", 1, flIllegal, OH_Illegal, }, /* $7b */ - { "jmp", 3, flLabel, OH_AbsoluteXIndirect }, /* $7c */ + { "jmp", 3, flLabel, OH_JmpAbsoluteXIndirect }, /* $7c */ { "adc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7d */ { "ror", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7e */ { "bbr7", 3, flUseLabel, OH_BitBranch }, /* $7f */ @@ -182,7 +182,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "sty", 2, flUseLabel, OH_Direct }, /* $84 */ { "sta", 2, flUseLabel, OH_Direct }, /* $85 */ { "stx", 2, flUseLabel, OH_Direct }, /* $86 */ - { "smb0", 1, flUseLabel, OH_Direct, }, /* $87 */ + { "smb0", 2, flUseLabel, OH_Direct, }, /* $87 */ { "dey", 1, flNone, OH_Implicit }, /* $88 */ { "bit", 2, flNone, OH_Immediate }, /* $89 */ { "txa", 1, flNone, OH_Implicit }, /* $8a */ @@ -198,7 +198,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "sty", 2, flUseLabel, OH_DirectX }, /* $94 */ { "sta", 2, flUseLabel, OH_DirectX }, /* $95 */ { "stx", 2, flUseLabel, OH_DirectY }, /* $96 */ - { "smb1", 1, flUseLabel, OH_Direct, }, /* $97 */ + { "smb1", 2, flUseLabel, OH_Direct, }, /* $97 */ { "tya", 1, flNone, OH_Implicit }, /* $98 */ { "sta", 3, flUseLabel, OH_AbsoluteY }, /* $99 */ { "txs", 1, flNone, OH_Implicit }, /* $9a */ @@ -214,7 +214,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "ldy", 2, flUseLabel, OH_Direct }, /* $a4 */ { "lda", 2, flUseLabel, OH_Direct }, /* $a5 */ { "ldx", 2, flUseLabel, OH_Direct }, /* $a6 */ - { "smb2", 1, flUseLabel, OH_Direct, }, /* $a7 */ + { "smb2", 2, flUseLabel, OH_Direct, }, /* $a7 */ { "tay", 1, flNone, OH_Implicit }, /* $a8 */ { "lda", 2, flNone, OH_Immediate }, /* $a9 */ { "tax", 1, flNone, OH_Implicit }, /* $aa */ @@ -230,7 +230,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "ldy", 2, flUseLabel, OH_DirectX }, /* $b4 */ { "lda", 2, flUseLabel, OH_DirectX }, /* $b5 */ { "ldx", 2, flUseLabel, OH_DirectY }, /* $b6 */ - { "smb3", 1, flUseLabel, OH_Direct, }, /* $b7 */ + { "smb3", 2, flUseLabel, OH_Direct, }, /* $b7 */ { "clv", 1, flNone, OH_Implicit }, /* $b8 */ { "lda", 3, flUseLabel, OH_AbsoluteY }, /* $b9 */ { "tsx", 1, flNone, OH_Implicit }, /* $ba */ @@ -246,7 +246,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "cpy", 2, flUseLabel, OH_Direct }, /* $c4 */ { "cmp", 2, flUseLabel, OH_Direct }, /* $c5 */ { "dec", 2, flUseLabel, OH_Direct }, /* $c6 */ - { "smb4", 1, flUseLabel, OH_Direct, }, /* $c7 */ + { "smb4", 2, flUseLabel, OH_Direct, }, /* $c7 */ { "iny", 1, flNone, OH_Implicit }, /* $c8 */ { "cmp", 2, flNone, OH_Immediate }, /* $c9 */ { "dex", 1, flNone, OH_Implicit }, /* $ca */ @@ -262,7 +262,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "csh", 1, flNone, OH_Implicit, }, /* $d4 */ { "cmp", 2, flUseLabel, OH_DirectX }, /* $d5 */ { "dec", 2, flUseLabel, OH_DirectX }, /* $d6 */ - { "smb5", 1, flUseLabel, OH_Direct, }, /* $d7 */ + { "smb5", 2, flUseLabel, OH_Direct, }, /* $d7 */ { "cld", 1, flNone, OH_Implicit }, /* $d8 */ { "cmp", 3, flUseLabel, OH_AbsoluteY }, /* $d9 */ { "phx", 1, flNone, OH_Implicit }, /* $da */ @@ -278,7 +278,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "cpx", 2, flUseLabel, OH_Direct }, /* $e4 */ { "sbc", 2, flUseLabel, OH_Direct }, /* $e5 */ { "inc", 2, flUseLabel, OH_Direct }, /* $e6 */ - { "smb6", 1, flUseLabel, OH_Direct, }, /* $e7 */ + { "smb6", 2, flUseLabel, OH_Direct, }, /* $e7 */ { "inx", 1, flNone, OH_Implicit }, /* $e8 */ { "sbc", 2, flNone, OH_Immediate }, /* $e9 */ { "nop", 1, flNone, OH_Implicit }, /* $ea */ @@ -294,7 +294,7 @@ const OpcDesc OpcTable_HuC6280[256] = { { "set", 1, flNone, OH_Implicit, }, /* $f4 */ { "sbc", 2, flUseLabel, OH_DirectX }, /* $f5 */ { "inc", 2, flUseLabel, OH_DirectX }, /* $f6 */ - { "smb7", 1, flUseLabel, OH_Direct, }, /* $f7 */ + { "smb7", 2, flUseLabel, OH_Direct, }, /* $f7 */ { "sed", 1, flNone, OH_Implicit }, /* $f8 */ { "sbc", 3, flUseLabel, OH_AbsoluteY }, /* $f9 */ { "plx", 1, flNone, OH_Implicit }, /* $fa */ From a982e434f2f5beb905ead70e2049c052984ece10 Mon Sep 17 00:00:00 2001 From: greg-king5 <gregdk@users.sf.net> Date: Fri, 2 Sep 2016 17:55:39 -0400 Subject: [PATCH 148/407] Added commented placeholder for future Mitsubishi 740 CPU in "cpu.mac". --- asminc/cpu.mac | 1 + 1 file changed, 1 insertion(+) diff --git a/asminc/cpu.mac b/asminc/cpu.mac index 93711427c..a67407a4a 100644 --- a/asminc/cpu.mac +++ b/asminc/cpu.mac @@ -7,6 +7,7 @@ CPU_ISET_65C02 = $0010 CPU_ISET_65816 = $0020 CPU_ISET_SWEET16 = $0040 CPU_ISET_HUC6280 = $0080 +;CPU_ISET_M740 = $0100 CPU_ISET_4510 = $0200 ; CPU capabilities From 89e2bf89cb44bff9f7969a1cb5dd87b4b3579081 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Sat, 3 Sep 2016 16:45:59 +0200 Subject: [PATCH 149/407] migrated opcodes tests for assembler from testcode to test for inclusion on automated testing --- test/Makefile | 2 + {testcode => test}/assembler/.gitignore | 2 +- .../assembler/4510-opcodes.ref | Bin .../assembler/4510-opcodes.s | 2 +- test/assembler/6502-opcodes.ref | Bin 0 -> 425 bytes test/assembler/6502-opcodes.s | 257 +++++++++++++++++ test/assembler/6502x-opcodes.ref | Bin 0 -> 544 bytes test/assembler/6502x-opcodes.s | 258 +++++++++++++++++ test/assembler/65c02-opcodes.ref | Bin 0 -> 501 bytes test/assembler/65c02-opcodes.s | 258 +++++++++++++++++ test/assembler/65sc02-opcodes.ref | Bin 0 -> 453 bytes test/assembler/65sc02-opcodes.s | 258 +++++++++++++++++ test/assembler/Makefile | 30 ++ test/assembler/huc6280-opcodes.ref | Bin 0 -> 547 bytes test/assembler/huc6280-opcodes.s | 258 +++++++++++++++++ test/assembler/m740-opcodes.s | 260 ++++++++++++++++++ testcode/assembler/Makefile | 32 --- testcode/assembler/all.s | 260 ------------------ testcode/assembler/illegal.ref | 1 - testcode/assembler/illegal.s | 135 --------- testcode/assembler/legal.ref | Bin 321 -> 0 bytes testcode/assembler/legal.s | 185 ------------- 22 files changed, 1583 insertions(+), 615 deletions(-) rename {testcode => test}/assembler/.gitignore (100%) rename testcode/assembler/4510all.ref => test/assembler/4510-opcodes.ref (100%) rename testcode/assembler/4510all.s => test/assembler/4510-opcodes.s (99%) create mode 100644 test/assembler/6502-opcodes.ref create mode 100644 test/assembler/6502-opcodes.s create mode 100644 test/assembler/6502x-opcodes.ref create mode 100644 test/assembler/6502x-opcodes.s create mode 100644 test/assembler/65c02-opcodes.ref create mode 100644 test/assembler/65c02-opcodes.s create mode 100644 test/assembler/65sc02-opcodes.ref create mode 100644 test/assembler/65sc02-opcodes.s create mode 100644 test/assembler/Makefile create mode 100644 test/assembler/huc6280-opcodes.ref create mode 100644 test/assembler/huc6280-opcodes.s create mode 100644 test/assembler/m740-opcodes.s delete mode 100644 testcode/assembler/Makefile delete mode 100644 testcode/assembler/all.s delete mode 100644 testcode/assembler/illegal.ref delete mode 100644 testcode/assembler/illegal.s delete mode 100644 testcode/assembler/legal.ref delete mode 100644 testcode/assembler/legal.s diff --git a/test/Makefile b/test/Makefile index ffdf72aa0..2fd252d2a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -40,12 +40,14 @@ $(WORKDIR)/bdiff$(EXE): bdiff.c | $(WORKDIR) dotests: mostlyclean continue continue: $(WORKDIR)/bdiff$(EXE) + @$(MAKE) -C assembler all @$(MAKE) -C val all @$(MAKE) -C ref all @$(MAKE) -C err all @$(MAKE) -C misc all mostlyclean: + @$(MAKE) -C assembler clean @$(MAKE) -C val clean @$(MAKE) -C ref clean @$(MAKE) -C err clean diff --git a/testcode/assembler/.gitignore b/test/assembler/.gitignore similarity index 100% rename from testcode/assembler/.gitignore rename to test/assembler/.gitignore index 0f7f86d78..c0c74a35e 100644 --- a/testcode/assembler/.gitignore +++ b/test/assembler/.gitignore @@ -1,3 +1,3 @@ -*.bin *.o +*.bin *.lst diff --git a/testcode/assembler/4510all.ref b/test/assembler/4510-opcodes.ref similarity index 100% rename from testcode/assembler/4510all.ref rename to test/assembler/4510-opcodes.ref diff --git a/testcode/assembler/4510all.s b/test/assembler/4510-opcodes.s similarity index 99% rename from testcode/assembler/4510all.s rename to test/assembler/4510-opcodes.s index 997ddd05d..3d6805674 100644 --- a/testcode/assembler/4510all.s +++ b/test/assembler/4510-opcodes.s @@ -1,4 +1,4 @@ - .setcpu "4510" +.setcpu "4510" brk ora ($05,x) diff --git a/test/assembler/6502-opcodes.ref b/test/assembler/6502-opcodes.ref new file mode 100644 index 0000000000000000000000000000000000000000..c12fa8fd6a4498eef33b1db5a12634d146ce5888 GIT binary patch literal 425 zcmV~$2UrMT00dCU$mWb}C9^{6?A@Sj;-qZK-r=`58QIx;MyZrh8KLYbQuZkO%if#! za#$dzWv<-FgS=MxkiS5|LSkXDNKsP^C|;r@O2N8x8L@1+@)g92VkH~V7M1O)pem}N zdX1W}cW@MIiM7Q#PNpuLU04tG(V$@?v2l~8&BW$ni<Yh6>gMi&)@bADg|_Y5iyg#{ zVyDig3%YuD>kgrZPfyX;uUBuekJz_ge+(En$R7b1JY*<_4Id$n6i11p$C$AgH$HFz zCSsDAEKZp^ZMrx^oH=VY=FFXk`B;F3L5mhISt<sL%f#g?%u1|Uy#^szi*@Tah#NO; z-Xd<@wjDdL6T5a}5B6eT=zbgs3l|TH5n^PNIfUq#!#IMYI2Icx#veZ+o)k}s38!%e zXA_ff4(D;<;w4<Zk}O^ouZbzC<~nYq-AqRYZr#2k-o1DKf%s5-^cb1Qdh!&{@Ek8* kzC!kE@s0RaeD~gbz{gLYzu+sreg7f;{Pp{f_*eY*ACHHi+W-In literal 0 HcmV?d00001 diff --git a/test/assembler/6502-opcodes.s b/test/assembler/6502-opcodes.s new file mode 100644 index 000000000..5cb94c29f --- /dev/null +++ b/test/assembler/6502-opcodes.s @@ -0,0 +1,257 @@ +.setcpu "6502" + + brk + ora ($12,x) + .byte $02 + .byte $03 + .byte $04 + ora $12 + asl $12 + .byte $07 + php + ora #$12 + asl a + .byte $0B + .byte $0C + ora $3456 + asl $3456 + .byte $0F + bpl *+122 + ora ($12),y + .byte $12 + .byte $13 + .byte $14 + ora $12,x + asl $12,x + .byte $17 + clc + ora $3456,y + .byte $1A + .byte $1B + .byte $1C + ora $3456,x + asl $3456,x + .byte $1F + jsr $3456 + and ($12,x) + .byte $22 + .byte $23 + bit $12 + and $12 + rol $12 + .byte $27 + plp + and #$12 + rol a + .byte $2B + bit $3456 + and $3456 + rol $3456 + .byte $2F + bmi *+122 + and ($12),y + .byte $32 + .byte $33 + .byte $34 + and $12,x + rol $12,x + .byte $37 + sec + and $3456,y + .byte $3A + .byte $3B + .byte $3C + and $3456,x + rol $3456,x + .byte $3F + rti + eor ($12,x) + .byte $42 + .byte $43 + .byte $44 + eor $12 + lsr $12 + .byte $47 + pha + eor #$12 + lsr a + .byte $4B + jmp $3456 + eor $3456 + lsr $3456 + .byte $4F + bvc *+122 + eor ($12),y + .byte $52 + .byte $53 + .byte $54 + eor $12,x + lsr $12,x + .byte $57 + cli + eor $3456,y + .byte $5A + .byte $5B + .byte $5C + eor $3456,x + lsr $3456,x + .byte $5F + rts + adc ($12,x) + .byte $62 + .byte $63 + .byte $64 + adc $12 + ror $12 + .byte $67 + pla + adc #$12 + ror a + .byte $6B + jmp ($3456) + adc $3456 + ror $3456 + .byte $6F + bvs *+122 + adc ($12),y + .byte $72 + .byte $73 + .byte $74 + adc $12,x + ror $12,x + .byte $77 + sei + adc $3456,y + .byte $7A + .byte $7B + .byte $7C + adc $3456,x + ror $3456,x + .byte $7F + .byte $80 + sta ($12,x) + .byte $82 + .byte $83 + sty $12 + sta $12 + stx $12 + .byte $87 + dey + .byte $89 + txa + .byte $8B + sty $3456 + sta $3456 + stx $3456 + .byte $8F + bcc *+122 + sta ($12),y + .byte $92 + .byte $93 + sty $12,x + sta $12,x + stx $12,y + .byte $97 + tya + sta $3456,y + txs + .byte $9B + .byte $9C + sta $3456,x + .byte $9E + .byte $9F + ldy #$12 + lda ($12,x) + ldx #$12 + .byte $A3 + ldy $12 + lda $12 + ldx $12 + .byte $A7 + tay + lda #$12 + tax + .byte $AB + ldy $3456 + lda $3456 + ldx $3456 + .byte $AF + bcs *+122 + lda ($12),y + .byte $B2 + .byte $B3 + ldy $12,x + lda $12,x + ldx $12,y + .byte $B7 + clv + lda $3456,y + tsx + .byte $BB + ldy $3456,x + lda $3456,x + ldx $3456,y + .byte $BF + cpy #$12 + cmp ($12,x) + .byte $C2 + .byte $C3 + cpy $12 + cmp $12 + dec $12 + .byte $C7 + iny + cmp #$12 + dex + .byte $CB + cpy $3456 + cmp $3456 + dec $3456 + .byte $CF + bne *+122 + cmp ($12),y + .byte $D2 + .byte $D3 + .byte $D4 + cmp $12,x + dec $12,x + .byte $D7 + cld + cmp $3456,y + .byte $DA + .byte $DB + .byte $DC + cmp $3456,x + dec $3456,x + .byte $DF + cpx #$12 + sbc ($12,x) + .byte $E2 + .byte $E3 + cpx $12 + sbc $12 + inc $12 + .byte $E7 + inx + sbc #$12 + .byte $EB + cpx $3456 + sbc $3456 + inc $3456 + .byte $EF + beq *+122 + sbc ($12),y + .byte $F2 + .byte $F3 + .byte $F4 + sbc $12,x + inc $12,x + .byte $F7 + sed + sbc $3456,y + .byte $FA + .byte $FB + .byte $FC + sbc $3456,x + inc $3456,x + .byte $FF diff --git a/test/assembler/6502x-opcodes.ref b/test/assembler/6502x-opcodes.ref new file mode 100644 index 0000000000000000000000000000000000000000..f942bec76706f0b917f7c9ac38eecd9088e60707 GIT binary patch literal 544 zcmW;G0~e470EOXfzS+hyZuYW$!%ntcUv`UIwz<`^mu=g&ZJg8d3!V@m2^E?!ge4r| zi4c)Uk%?kOwW3+ktr$T}h(&DT5SMtwPhcfXWF@weSV^s9R&px^DN~V}G^8aR>3<_b z#!OabD~pxY$`)iNM@~d8a+8O=`K<f}tb$e{tFTqXDq4)+i&KJ<l%h0c%2KX86|9O@ zC9ASkC8$cZ>eQenrWUp9SatvS)u?CHw;EUt8_~E4O=(7RTF|l;t=rJnYG<{#I#?Zp zPIT@<SGv)i9t1tDUcIe8R$r^1)!!PxKn5|GAq-_0e=>XoBS$gX8e{!s{cVj6#xZ^Z z6Pd(hrZ9DyHGPIP)0$<?w&qxKna6w<u#iP8W(oiN%hF~1XDzo@SSzhn!D`m5WgY9; zz(zK0w*KE@ZMC*p+pQhePIj@IJ?v#4`#HeDLmWQBQR|p>+&W>M3{G+S3}-pVc`k7A zl6Cotb=A6NUAJynH@U@a?r@iT+~)xgAMyCfQ|p=a+<IZX3|{g24R3kJdp_{-llA$F N_0{@jeYbvCKLPd8w)X%4 literal 0 HcmV?d00001 diff --git a/test/assembler/6502x-opcodes.s b/test/assembler/6502x-opcodes.s new file mode 100644 index 000000000..5f21aeb9f --- /dev/null +++ b/test/assembler/6502x-opcodes.s @@ -0,0 +1,258 @@ +.setcpu "6502X" + + brk + ora ($12,x) + jam + slo ($12,x) + nop $12 + ora $12 + asl $12 + slo $12 + php + ora #$12 + asl a + anc #$12 + nop $3456 + ora $3456 + asl $3456 + slo $3456 + bpl *+122 + ora ($12),y + .byte $12 ; jam + slo ($12),y + nop $12,x + ora $12,x + asl $12,x + slo $12,x + clc + ora $3456,y + .byte $1a ; nop + slo $3456,y + nop $3456,x + ora $3456,x + asl $3456,x + slo $3456,x + jsr $3456 + and ($12,x) + .byte $22 ; jam + rla ($12,x) + bit $12 + and $12 + rol $12 + rla $12 + plp + and #$12 + rol a + .byte $2b ; anc #$12 + bit $3456 + and $3456 + rol $3456 + rla $3456 + bmi *+122 + and ($12),y + .byte $32 ; jam + rla ($12),y + .byte $34,$12 ; nop $12,x + and $12,x + rol $12,x + rla $12,x + sec + and $3456,y + .byte $3a ; nop + rla $3456,y + .byte $3c,$56,$34 ; nop $3456,x + and $3456,x + rol $3456,x + rla $3456,x + rti + eor ($12,x) + .byte $42 ; jam + sre ($12,x) + .byte $44,$12 ; nop $12 + eor $12 + lsr $12 + sre $12 + pha + eor #$12 + lsr a + alr #$12 + jmp $3456 + eor $3456 + lsr $3456 + sre $3456 + bvc *+122 + eor ($12),y + .byte $52 ; jam + sre ($12),y + .byte $54,$12 ; nop $12,x + eor $12,x + lsr $12,x + sre $12,x + cli + eor $3456,y + .byte $5a ; nop + sre $3456,y + nop $3456,x + eor $3456,x + lsr $3456,x + sre $3456,x + rts + adc ($12,x) + .byte $62 ; jam + rra ($12,x) + .byte $64,$12 ; nop $12 + adc $12 + ror $12 + rra $12 + pla + adc #$12 + ror a + arr #$12 + jmp ($3456) + adc $3456 + ror $3456 + rra $3456 + bvs *+122 + adc ($12),y + .byte $72 ; jam + rra ($12),y + .byte $74,$12 ; nop $12,x + adc $12,x + ror $12,x + rra $12,x + sei + adc $3456,y + .byte $7a ; nop + rra $3456,y + .byte $7c,$56,$34 ; nop $3456,x + adc $3456,x + ror $3456,x + rra $3456,x + nop #$12 + sta ($12,x) + .byte $82,$12 ; nop #$12 + sax ($12,x) + sty $12 + sta $12 + stx $12 + sax $12 + dey + .byte $89,$12 ; nop #$12 + txa + .byte $8b,$12 ; xaa #$12 + sty $3456 + sta $3456 + stx $3456 + sax $3456 + bcc *+122 + sta ($12),y + .byte $92 ; jam + .byte $93,$12 ; ahx ($12),y + sty $12,x + sta $12,x + stx $12,y + sax $12,y + tya + sta $3456,y + txs + tas $3456,y + shy $3456,x + sta $3456,x + shx $3456,y + .byte $9f,$56,$34 ; ahx $3456,y + ldy #$12 + lda ($12,x) + ldx #$12 + lax ($12,x) + ldy $12 + lda $12 + ldx $12 + lax $12 + tay + lda #$12 + tax + lax #$12 + ldy $3456 + lda $3456 + ldx $3456 + lax $3456 + bcs *+122 + lda ($12),y + .byte $b2 ; jam + lax ($12),y + ldy $12,x + lda $12,x + ldx $12,y + lax $12,y + clv + lda $3456,y + tsx + las $3456,y + ldy $3456,x + lda $3456,x + ldx $3456,y + lax $3456,y + cpy #$12 + cmp ($12,x) + .byte $c2,$12 ; nop #$12 + dcp ($12,x) + cpy $12 + cmp $12 + dec $12 + dcp $12 + iny + cmp #$12 + dex + axs #$12 + cpy $3456 + cmp $3456 + dec $3456 + dcp $3456 + bne *+122 + cmp ($12),y + .byte $d2 ; jam + dcp ($12),y + .byte $d4,$12 ; nop $12,x + cmp $12,x + dec $12,x + dcp $12,x + cld + cmp $3456,y + .byte $da ; nop + dcp $3456,y + .byte $dc,$56,$34 ; nop $3456,x + cmp $3456,x + dec $3456,x + dcp $3456,x + cpx #$12 + sbc ($12,x) + .byte $e2,$12 ; nop #$12 + isc ($12,x) + cpx $12 + sbc $12 + inc $12 + isc $12 + inx + sbc #$12 + nop + .byte $eb ; nop + cpx $3456 + sbc $3456 + inc $3456 + isc $3456 + beq *+122 + sbc ($12),y + .byte $f2 ; jam + isc ($12),y + .byte $f4,$12 ; nop $12,x + sbc $12,x + inc $12,x + isc $12,x + sed + sbc $3456,y + .byte $fa ; nop + isc $3456,y + .byte $fc,$56,$34 ; nop $3456,x + sbc $3456,x + inc $3456,x + isc $3456,x diff --git a/test/assembler/65c02-opcodes.ref b/test/assembler/65c02-opcodes.ref new file mode 100644 index 0000000000000000000000000000000000000000..2d44045cb59f10594d71353ad54bea406796f1be GIT binary patch literal 501 zcmV~$2LOmw0EN+vtjy2K%--8o_TGfhwPnwy`9G^jQT8lkS7yrIWbeHbWn}NYb<P_x zh#4z3ZxV;N#EVaYw-Q>3ti)ClLeeN1kURw`NkwYjPGhA_m)^=?WwhQQWU?}oC2Kaa zlY^Y(%1xfU`K<g_0jnUPP*j*A6cxpIm-i@M!YWy+v{l9`Yn3CEuRz60m8(#dYE-X5 z&04js_pLfsT|&L+1M1VD;fI(;G;U%wZPvVn)zbQi(5f|U+P0%T9q34>&UESevGs}d zsr4D*^XLn@(Y*&f=|yj%VD;(S&+2atu)ZXG6%Az2*Ms?nZyCbS@A!V$aBGA$(i%k= z9gSfu<Hj?AiTuEildQ>8ezK-o)2!))8O&rBvw!9neq|1G=P`f5LhCnck@Y*_k7zMV zSh|emtY9UpR$FV<uCvx#8?23lKiS0QEnC^fc6P9H7rXcDwf0&2tpkLE(IF0V<mfSu zbApqntiMkGea1R#{X_VdbDY0$k^i{FWv*Q1+VvaOP3x9*n{X$(%RTNtc*r9j^W>@Z N?D>nA)+_5Z;eP^Hutfj> literal 0 HcmV?d00001 diff --git a/test/assembler/65c02-opcodes.s b/test/assembler/65c02-opcodes.s new file mode 100644 index 000000000..09c3f04f2 --- /dev/null +++ b/test/assembler/65c02-opcodes.s @@ -0,0 +1,258 @@ +.setcpu "65C02" + + brk + ora ($12,x) + .byte $02 + .byte $03 + tsb $12 + ora $12 + asl $12 + rmb0 $12 + php + ora #$12 + asl a + .byte $0B + tsb $3456 + ora $3456 + asl $3456 + bbr0 $12,*+122 + bpl *+122 + ora ($12),y + ora ($12) + .byte $13 + trb $12 + ora $12,x + asl $12,x + rmb1 $12 + clc + ora $3456,y + inc a + .byte $1B + trb $3456 + ora $3456,x + asl $3456,x + bbr1 $12,*+122 + jsr $3456 + and ($12,x) + .byte $22 + .byte $23 + bit $12 + and $12 + rol $12 + rmb2 $12 + plp + and #$12 + rol a + .byte $2B + bit $3456 + and $3456 + rol $3456 + bbr2 $12,*+122 + bmi *+122 + and ($12),y + and ($12) + .byte $33 + bit $12,x + and $12,x + rol $12,x + rmb3 $12 + sec + and $3456,y + dec a + .byte $3B + bit $3456,x + and $3456,x + rol $3456,x + bbr3 $12,*+122 + rti + eor ($12,x) + .byte $42 + .byte $43 + .byte $44 + eor $12 + lsr $12 + rmb4 $12 + pha + eor #$12 + lsr a + .byte $4B + jmp $3456 + eor $3456 + lsr $3456 + bbr4 $12,*+122 + bvc *+122 + eor ($12),y + eor ($12) + .byte $53 + .byte $54 + eor $12,x + lsr $12,x + rmb5 $12 + cli + eor $3456,y + phy + .byte $5B + .byte $5C + eor $3456,x + lsr $3456,x + bbr5 $12,*+122 + rts + adc ($12,x) + .byte $62 + .byte $63 + stz $12 + adc $12 + ror $12 + rmb6 $12 + pla + adc #$12 + ror a + .byte $6B + jmp ($3456) + adc $3456 + ror $3456 + bbr6 $12,*+122 + bvs *+122 + adc ($12),y + adc ($12) + .byte $73 + stz $12,x + adc $12,x + ror $12,x + rmb7 $12 + sei + adc $3456,y + ply + .byte $7B + jmp ($3456,x) + adc $3456,x + ror $3456,x + bbr7 $12,*+122 + bra *+122 + sta ($12,x) + .byte $82 + .byte $83 + sty $12 + sta $12 + stx $12 + smb0 $12 + dey + bit #$12 + txa + .byte $8B + sty $3456 + sta $3456 + stx $3456 + bbs0 $12,*+122 + bcc *+122 + sta ($12),y + sta ($12) + .byte $93 + sty $12,x + sta $12,x + stx $12,y + smb1 $12 + tya + sta $3456,y + txs + .byte $9B + stz $3456 + sta $3456,x + stz $3456,x + bbs1 $12,*+122 + ldy #$12 + lda ($12,x) + ldx #$12 + .byte $A3 + ldy $12 + lda $12 + ldx $12 + smb2 $12 + tay + lda #$12 + tax + .byte $AB + ldy $3456 + lda $3456 + ldx $3456 + bbs2 $12,*+122 + bcs *+122 + lda ($12),y + lda ($12) + .byte $B3 + ldy $12,x + lda $12,x + ldx $12,y + smb3 $12 + clv + lda $3456,y + tsx + .byte $BB + ldy $3456,x + lda $3456,x + ldx $3456,y + bbs3 $12,*+122 + cpy #$12 + cmp ($12,x) + .byte $C2 + .byte $C3 + cpy $12 + cmp $12 + dec $12 + smb4 $12 + iny + cmp #$12 + dex + .byte $CB + cpy $3456 + cmp $3456 + dec $3456 + bbs4 $12,*+122 + bne *+122 + cmp ($12),y + cmp ($12) + .byte $D3 + .byte $D4 + cmp $12,x + dec $12,x + smb5 $12 + cld + cmp $3456,y + phx + .byte $DB + .byte $DC + cmp $3456,x + dec $3456,x + bbs5 $12,*+122 + cpx #$12 + sbc ($12,x) + .byte $E2 + .byte $E3 + cpx $12 + sbc $12 + inc $12 + smb6 $12 + inx + sbc #$12 + nop + .byte $EB + cpx $3456 + sbc $3456 + inc $3456 + bbs6 $12,*+122 + beq *+122 + sbc ($12),y + sbc ($12) + .byte $F3 + .byte $F4 + sbc $12,x + inc $12,x + smb7 $12 + sed + sbc $3456,y + plx + .byte $FB + .byte $FC + sbc $3456,x + inc $3456,x + bbs7 $12,*+122 diff --git a/test/assembler/65sc02-opcodes.ref b/test/assembler/65sc02-opcodes.ref new file mode 100644 index 0000000000000000000000000000000000000000..d22fe668821f69e5f2301bbf394cedf3c7fe3e9b GIT binary patch literal 453 zcmV~$0{~D507cPk-fUwTFMHX3Vc9l*_TrXpZnf-X+qP|6=Y$AJsL){uOE|(uh)AT! zQLLy|G%I?HASMtiHgSkcy!Z*MgozScNvxz+vgB3@Ql?5x8q$(3{cmK*n90g)WwEkm z3$l}goFW&w$&)vqmA^nitB_ULDpIr<zZWl2l2Vi|Q<ie&D_9k+N>=46K~<_zy+%z; zt=e_0x_{KGZ#A$QHfl_hrp;(h3tF~nO`EputoBw1t7E62GhOJ~jqdcIXVA;)-KVeB z&+2at7#Iv<@Q|Sl<4=Z<7|E#7W30cdzpb(3g7HjX;v^<Bg{jk~TQg?PvSwRzthw`; z&jJ=MVlhkj=ij9)`)|3m!dhvqS{<xmE$h~^fsJh1{J*tj>o#k<wZq!Ei{0$myN~@G z;NYRd965T-I&Ph?PM!)*bB43$&U1l_mo8gZu3o!t-LP)n;x>2g-s3(Gc=+fsPo6%r go?9=hm#>1?yy5M;_k7^vr_a`xuiw5~Kdhg>0HfKabpQYW literal 0 HcmV?d00001 diff --git a/test/assembler/65sc02-opcodes.s b/test/assembler/65sc02-opcodes.s new file mode 100644 index 000000000..aa539913a --- /dev/null +++ b/test/assembler/65sc02-opcodes.s @@ -0,0 +1,258 @@ +.setcpu "65SC02" + + brk + ora ($12,x) + .byte $02 + .byte $03 + tsb $12 + ora $12 + asl $12 + .byte $07 + php + ora #$12 + asl a + .byte $0B + tsb $3456 + ora $3456 + asl $3456 + .byte $0F + bpl *+122 + ora ($12),y + ora ($12) + .byte $13 + trb $12 + ora $12,x + asl $12,x + .byte $17 + clc + ora $3456,y + inc a + .byte $1B + trb $3456 + ora $3456,x + asl $3456,x + .byte $1F + jsr $3456 + and ($12,x) + .byte $22 + .byte $23 + bit $12 + and $12 + rol $12 + .byte $27 + plp + and #$12 + rol a + .byte $2B + bit $3456 + and $3456 + rol $3456 + .byte $2F + bmi *+122 + and ($12),y + and ($12) + .byte $33 + bit $12,x + and $12,x + rol $12,x + .byte $37 + sec + and $3456,y + dec a + .byte $3B + bit $3456,x + and $3456,x + rol $3456,x + .byte $3F + rti + eor ($12,x) + .byte $42 + .byte $43 + .byte $44 + eor $12 + lsr $12 + .byte $47 + pha + eor #$12 + lsr a + .byte $4B + jmp $3456 + eor $3456 + lsr $3456 + .byte $4F + bvc *+122 + eor ($12),y + eor ($12) + .byte $53 + .byte $54 + eor $12,x + lsr $12,x + .byte $57 + cli + eor $3456,y + phy + .byte $5B + .byte $5C + eor $3456,x + lsr $3456,x + .byte $5F + rts + adc ($12,x) + .byte $62 + .byte $63 + stz $12 + adc $12 + ror $12 + .byte $67 + pla + adc #$12 + ror a + .byte $6B + jmp ($3456) + adc $3456 + ror $3456 + .byte $6F + bvs *+122 + adc ($12),y + adc ($12) + .byte $73 + stz $12,x + adc $12,x + ror $12,x + .byte $77 + sei + adc $3456,y + ply + .byte $7B + jmp ($3456,x) + adc $3456,x + ror $3456,x + .byte $7F + bra *+122 + sta ($12,x) + .byte $82 + .byte $83 + sty $12 + sta $12 + stx $12 + .byte $87 + dey + bit #$12 + txa + .byte $8B + sty $3456 + sta $3456 + stx $3456 + .byte $8F + bcc *+122 + sta ($12),y + sta ($12) + .byte $93 + sty $12,x + sta $12,x + stx $12,y + .byte $97 + tya + sta $3456,y + txs + .byte $9B + stz $3456 + sta $3456,x + stz $3456,x + .byte $9F + ldy #$12 + lda ($12,x) + ldx #$12 + .byte $A3 + ldy $12 + lda $12 + ldx $12 + .byte $A7 + tay + lda #$12 + tax + .byte $AB + ldy $3456 + lda $3456 + ldx $3456 + .byte $AF + bcs *+122 + lda ($12),y + lda ($12) + .byte $B3 + ldy $12,x + lda $12,x + ldx $12,y + .byte $B7 + clv + lda $3456,y + tsx + .byte $BB + ldy $3456,x + lda $3456,x + ldx $3456,y + .byte $BF + cpy #$12 + cmp ($12,x) + .byte $C2 + .byte $C3 + cpy $12 + cmp $12 + dec $12 + .byte $C7 + iny + cmp #$12 + dex + .byte $CB + cpy $3456 + cmp $3456 + dec $3456 + .byte $CF + bne *+122 + cmp ($12),y + cmp ($12) + .byte $D3 + .byte $D4 + cmp $12,x + dec $12,x + .byte $D7 + cld + cmp $3456,y + phx + .byte $DB + .byte $DC + cmp $3456,x + dec $3456,x + .byte $DF + cpx #$12 + sbc ($12,x) + .byte $E2 + .byte $E3 + cpx $12 + sbc $12 + inc $12 + .byte $E7 + inx + sbc #$12 + nop + .byte $EB + cpx $3456 + sbc $3456 + inc $3456 + .byte $EF + beq *+122 + sbc ($12),y + sbc ($12) + .byte $F3 + .byte $F4 + sbc $12,x + inc $12,x + .byte $F7 + sed + sbc $3456,y + plx + .byte $FB + .byte $FC + sbc $3456,x + inc $3456,x + .byte $FF diff --git a/test/assembler/Makefile b/test/assembler/Makefile new file mode 100644 index 000000000..5e4d580b5 --- /dev/null +++ b/test/assembler/Makefile @@ -0,0 +1,30 @@ + +# makefile for the assembler regression tests + +BINDIR = ../../bin +#WORKDIR := ../../testwrk +WORKDIR := . + +TARGETS = 6502 6502x 65sc02 65c02 +#TARGETS += 65816 +TARGETS += 4510 +TARGETS += huc6280 +#TARGETS += m740 + +all: $(addprefix $(WORKDIR)/, $(addsuffix -opcodes.bin, $(TARGETS))) + @# + +.PHONY: $(addprefix $(WORKDIR)/, $(addsuffix -opcodes.bin, $(TARGETS))) + +clean: + rm -f *.o *.bin *.lst + +define build +$$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s + @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$< + @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1) + @echo ca65 --cpu $(1) ok +endef + +$(foreach target,$(TARGETS),$(eval $(call build,$(target)))) + diff --git a/test/assembler/huc6280-opcodes.ref b/test/assembler/huc6280-opcodes.ref new file mode 100644 index 0000000000000000000000000000000000000000..33f5b297f1c8e04365f3c6f613a7c30b373b11bf GIT binary patch literal 547 zcmWN}g`-b*9LHfU({)~(?w&Dq-ln^|KhsR-#5K-Wch{!7ZF+2S`kL;mYq&Q2n7X<> zf4~zXCSkFN%@@QWF7e`%AYmd?Vp9@RQe3jY1HR-dl9Pgzq)Kf{lQx|xy(xn!BQBFE zGg-2djqKzgCtv5{o7{O!-<tB8^5OCa1t^Fw3h^C<DN@u_tau4iNmD6PX<V7Ilq(-r zA*e_tDpRE@)vDJp)il*I)yCBc>QayTG-!zNJ&hWhnlx?J+|<I<64&YnTDNISJKEEM zj-BY-rK_o%=|@v{T#uk9y$JXH@Nm!T%}?~9FM%`l>p#FW&@{+27&jys%CO;tMlh05 zjAqPO#*Lp~nrND2nv9zg{LC**B@~**bY?J<S+h-Z=FT(CH!UzN#4TbmOIS*18OvG0 zul%->Rjb#S)|%Ft*5iH;Hn5RDJ}-Z=iOp<b>o(K&zjl~*ns%9X<MyzZeG$GN5#f3J z`I`eA<j`S`96e?_ZaQH)i8~dX<_wX(9~tR+XU}n-3tYTpx_ss8HPdy|Ke!v*<W`jL zM@4zwZT{sy?r`@Wq5BU^|C=6~9^oDbPk2hS??*>_-m~Yt;3cnKo8G*A_ullu^bz+7 DEAPQE literal 0 HcmV?d00001 diff --git a/test/assembler/huc6280-opcodes.s b/test/assembler/huc6280-opcodes.s new file mode 100644 index 000000000..bd3ad5c79 --- /dev/null +++ b/test/assembler/huc6280-opcodes.s @@ -0,0 +1,258 @@ +.setcpu "huc6280" + + brk + ora ($12,x) + sxy + st0 #$12 + tsb $12 + ora $12 + asl $12 + rmb0 $12 + php + ora #$12 + asl a + .byte $0B + tsb $3456 + ora $3456 + asl $3456 + bbr0 $12,*+122 + bpl *+122 + ora ($12),y + ora ($12) + st1 #$12 + trb $12 + ora $12,x + asl $12,x + rmb1 $12 + clc + ora $3456,y + inc a + .byte $1B + trb $3456 + ora $3456,x + asl $3456,x + bbr1 $12,*+122 + jsr $3456 + and ($12,x) + sax + st2 #$12 + bit $12 + and $12 + rol $12 + rmb2 $12 + plp + and #$12 + rol a + .byte $2B + bit $3456 + and $3456 + rol $3456 + bbr2 $12,*+122 + bmi *+122 + and ($12),y + and ($12) + .byte $33 + bit $12,x + and $12,x + rol $12,x + rmb3 $12 + sec + and $3456,y + dec a + .byte $3B + bit $3456,x + and $3456,x + rol $3456,x + bbr3 $12,*+122 + rti + eor ($12,x) + say + tma #$02 + bsr *+122 + eor $12 + lsr $12 + rmb4 $12 + pha + eor #$12 + lsr a + .byte $4B + jmp $3456 + eor $3456 + lsr $3456 + bbr4 $12,*+122 + bvc *+122 + eor ($12),y + eor ($12) + tam #$12 + csl + eor $12,x + lsr $12,x + rmb5 $12 + cli + eor $3456,y + phy + .byte $5B + .byte $5C + eor $3456,x + lsr $3456,x + bbr5 $12,*+122 + rts + adc ($12,x) + cla + .byte $63 + stz $12 + adc $12 + ror $12 + rmb6 $12 + pla + adc #$12 + ror a + .byte $6B + jmp ($3456) + adc $3456 + ror $3456 + bbr6 $12,*+122 + bvs *+122 + adc ($12),y + adc ($12) + tii $3333,$7373,$1111 + stz $12,x + adc $12,x + ror $12,x + rmb7 $12 + sei + adc $3456,y + ply + .byte $7B + jmp ($3456,x) + adc $3456,x + ror $3456,x + bbr7 $12,*+122 + bra *+122 + sta ($12,x) + clx + tst #$12,$EA + sty $12 + sta $12 + stx $12 + smb0 $12 + dey + bit #$12 + txa + .byte $8B + sty $3456 + sta $3456 + stx $3456 + bbs0 $12,*+122 + bcc *+122 + sta ($12),y + sta ($12) + tst #$12,$EAEA + sty $12,x + sta $12,x + stx $12,y + smb1 $12 + tya + sta $3456,y + txs + .byte $9B + stz $3456 + sta $3456,x + stz $3456,x + bbs1 $12,*+122 + ldy #$12 + lda ($12,x) + ldx #$12 + tst #$12,$EA,x + ldy $12 + lda $12 + ldx $12 + smb2 $12 + tay + lda #$12 + tax + .byte $AB + ldy $3456 + lda $3456 + ldx $3456 + bbs2 $12,*+122 + bcs *+122 + lda ($12),y + lda ($12) + tst #$12,$EAEA,x + ldy $12,x + lda $12,x + ldx $12,y + smb3 $12 + clv + lda $3456,y + tsx + .byte $BB + ldy $3456,x + lda $3456,x + ldx $3456,y + bbs3 $12,*+122 + cpy #$12 + cmp ($12,x) + cly + tdd $3333,$C3C3,$1111 + cpy $12 + cmp $12 + dec $12 + smb4 $12 + iny + cmp #$12 + dex + .byte $CB + cpy $3456 + cmp $3456 + dec $3456 + bbs4 $12,*+122 + bne *+122 + cmp ($12),y + cmp ($12) + tin $3333,$D3D3,$1111 + .byte $D4 + cmp $12,x + dec $12,x + smb5 $12 + cld + cmp $3456,y + phx + .byte $DB + .byte $DC + cmp $3456,x + dec $3456,x + bbs5 $12,*+122 + cpx #$12 + sbc ($12,x) + .byte $E2 + tia $3333,$E3E3,$1111 + cpx $12 + sbc $12 + inc $12 + smb6 $12 + inx + sbc #$12 + nop + .byte $EB + cpx $3456 + sbc $3456 + inc $3456 + bbs6 $12,*+122 + beq *+122 + sbc ($12),y + sbc ($12) + tai $3333,$F3F3,$1111 + .byte $F4 + sbc $12,x + inc $12,x + smb7 $12 + sed + sbc $3456,y + plx + .byte $FB + .byte $FC + sbc $3456,x + inc $3456,x + bbs7 $12,*+122 diff --git a/test/assembler/m740-opcodes.s b/test/assembler/m740-opcodes.s new file mode 100644 index 000000000..df6d71488 --- /dev/null +++ b/test/assembler/m740-opcodes.s @@ -0,0 +1,260 @@ +.setcpu "65C02" +; copy of 65c02, comments note changes to the m740 according to +; http://documentation.renesas.com/doc/products/mpumcu/rej09b0322_740sm.pdf + + brk + ora ($12,x) + .byte $02,$00,$00 ; jsr zp,ind + .byte $03,$00,$00 ; bbs 0,a + tsb $12 ; .byte $04 + ora $12 + asl $12 + rmb0 $12 ; bbs 0,zp + php + ora #$12 + asl a + .byte $0B,$00,$00 ; seb 0,a + tsb $3456 ; .byte $0c + ora $3456 + asl $3456 + bbr0 $12,*+122 ; seb 0,zp + bpl *+122 + ora ($12),y + ora ($12) ; clt + .byte $13,$00,$00 ; bbc 0,a + trb $12 ; .byte $14 + ora $12,x + asl $12,x + rmb1 $12 ; bbc 0,zp + clc + ora $3456,y + inc a + .byte $1B,$00,$00 ; clb 0,a + trb $3456 ; .byte $1c + ora $3456,x + asl $3456,x + bbr1 $12,*+122 ; clb 0,zp + jsr $3456 + and ($12,x) + .byte $22,$00,$00 ; jsr sp + .byte $23,$00,$00 ; bbs 1,a + bit $12 + and $12 + rol $12 + rmb2 $12 ; bbs 1,zp + plp + and #$12 + rol a + .byte $2B,$00,$00 ; seb 1,a + bit $3456 + and $3456 + rol $3456 + bbr2 $12,*+122 ; seb 1,zp + bmi *+122 + and ($12),y + and ($12) ; set + .byte $33,$00,$00 ; bbc 1,a + bit $12,x ; .byte $34 + and $12,x + rol $12,x + rmb3 $12 ; bbc 1,zp + sec + and $3456,y + dec a + .byte $3B,$00,$00 ; clb 1,a + bit $3456,x ; ldm zp + and $3456,x + rol $3456,x + bbr3 $12,*+122 ; clb 1,zp + rti + eor ($12,x) + .byte $42,$00,$00 ; stp + .byte $43,$00,$00 ; bbs 2,a + .byte $44,$00,$00 ; com zp + eor $12 + lsr $12 + rmb4 $12 ; bbs 2,zp + pha + eor #$12 + lsr a + .byte $4B,$00,$00 ; seb 2,a + jmp $3456 + eor $3456 + lsr $3456 + bbr4 $12,*+122 ; seb 2,zp + bvc *+122 + eor ($12),y + eor ($12) ; .byte $52 + .byte $53,$00,$00 ; bbc 2,a + .byte $54,$00,$00 + eor $12,x + lsr $12,x + rmb5 $12 ; bbc 2,zp + cli + eor $3456,y + phy + .byte $5B,$00,$00 ; clb 2,a + .byte $5C,$00,$00 + eor $3456,x + lsr $3456,x + bbr5 $12,*+122 ; clb 2,zp + rts + adc ($12,x) + .byte $62,$00,$00 ; mul zp,x + .byte $63,$00,$00 ; bbs 3,a + stz $12 ; tst zp + adc $12 + ror $12 + rmb6 $12 ; bbs 3,zp + pla + adc #$12 + ror a + .byte $6B,$00,$00 ; seb 3,a + jmp ($3456) + adc $3456 + ror $3456 + bbr6 $12,*+122 ; seb 3,zp + bvs *+122 + adc ($12),y + adc ($12) ; .byte $72 + .byte $73,$00,$00 ; bbc 3,a + stz $12,x ; .byte $74 + adc $12,x + ror $12,x + rmb7 $12 ; bbc 3,zp + sei + adc $3456,y + ply + .byte $7B,$00,$00 ; clb 3,a + jmp ($3456,x) ; .byte $7c + adc $3456,x + ror $3456,x + bbr7 $12,*+122 ; clb 3,zp + bra *+122 + sta ($12,x) + .byte $82,$00,$00 ; rrf zp + .byte $83,$00,$00 ; bbs 4,a + sty $12 + sta $12 + stx $12 + smb0 $12 ; bbs 4,zp + dey + bit #$12 + txa + .byte $8B,$00,$00 ; seb 4,a + sty $3456 + sta $3456 + stx $3456 + bbs0 $12,*+122 ; seb 4,zp + bcc *+122 + sta ($12),y + sta ($12) ; .byte $92 + .byte $93,$00,$00 ; bbc 4,a + sty $12,x + sta $12,x + stx $12,y + smb1 $12 ; bbc 4,zp + tya + sta $3456,y + txs + .byte $9B,$00,$00 ; clb 4,a + stz $3456 ; .byte $9c + sta $3456,x + stz $3456,x ; .byte $9e + bbs1 $12,*+122 ; clb 4,zp + ldy #$12 + lda ($12,x) + ldx #$12 + .byte $A3,$00,$00 ; bbs 5,a + ldy $12 + lda $12 + ldx $12 + smb2 $12 ; bbs 5,zp + tay + lda #$12 + tax + .byte $AB,$00,$00 ; seb 5,a + ldy $3456 + lda $3456 + ldx $3456 + bbs2 $12,*+122 ; seb 5,zp + bcs *+122 + lda ($12),y + lda ($12) ; .byte $b2 + .byte $B3,$00,$00 ; bbc 5,a + ldy $12,x + lda $12,x + ldx $12,y + smb3 $12 ; bbc 5,zp + clv + lda $3456,y + tsx + .byte $BB,$00,$00 ; clb 5,a + ldy $3456,x + lda $3456,x + ldx $3456,y + bbs3 $12,*+122 ; clb 5,zp + cpy #$12 + cmp ($12,x) + .byte $C2,$00,$00 ; wit + .byte $C3,$00,$00 ; bbs 6,a + cpy $12 + cmp $12 + dec $12 + smb4 $12 ; bbs 6,zp + iny + cmp #$12 + dex + .byte $CB,$00,$00 ; seb 6,a + cpy $3456 + cmp $3456 + dec $3456 + bbs4 $12,*+122 ; seb 6,zp + bne *+122 + cmp ($12),y + cmp ($12) ; .byte $d2 + .byte $D3,$00,$00 ; bbc 6,a + .byte $D4,$00,$00 + cmp $12,x + dec $12,x + smb5 $12 ; bbc 6,zp + cld + cmp $3456,y + phx + .byte $DB,$00,$00 ; clb 6,a + .byte $DC,$00,$00 + cmp $3456,x + dec $3456,x + bbs5 $12,*+122 ; clb 6,zp + cpx #$12 + sbc ($12,x) + .byte $E2,$00,$00 ; div zp,x + .byte $E3,$00,$00 ; bbs 7,a + cpx $12 + sbc $12 + inc $12 + smb6 $12 ; bbs 7,zp + inx + sbc #$12 + nop + .byte $EB,$00,$00 ; seb 7,a + cpx $3456 + sbc $3456 + inc $3456 + bbs6 $12,*+122 ; seb 7,zp + beq *+122 + sbc ($12),y + sbc ($12) ; .byte $f2 + .byte $F3,$00,$00 ; bbc 7,a + .byte $F4,$00,$00 + sbc $12,x + inc $12,x + smb7 $12 ; bbc 7,zp + sed + sbc $3456,y + plx + .byte $FB,$00,$00 ; clb 7,a + .byte $FC,$00,$00 + sbc $3456,x + inc $3456,x + bbs7 $12,*+122 ; clb 7,zp diff --git a/testcode/assembler/Makefile b/testcode/assembler/Makefile deleted file mode 100644 index 35c34235a..000000000 --- a/testcode/assembler/Makefile +++ /dev/null @@ -1,32 +0,0 @@ - -all: chklegal.bin chkillegal.bin chkall.bin chk4510.bin - @# - -.PHONY: chklegal.bin chkillegal.bin chkall.bin chk4510.bin - -chk4510.bin: 4510all.s - $(MAKE) -C ../../src all - ../../bin/cl65 --target none --cpu 4510 --listing 4510all.lst -o $@ $< - diff -q 4510all.ref $@ || cat 4510all.lst - -chklegal.bin: legal.s - ../../bin/cl65 --target none --cpu 6502X -o chklegal.bin legal.s - diff -q legal.ref chklegal.bin || hex chklegal.bin - -chkillegal.bin: illegal.s - ../../bin/cl65 --target none --cpu 6502X -o chkillegal.bin illegal.s - diff -q illegal.ref chkillegal.bin || hex chkillegal.bin - -chkall.bin: all.s - ../../bin/cl65 --target none --cpu 6502X -o chkall.bin all.s - -ref: legal.s illegal.s - ../../bin/cl65 --target none --cpu 6502X -o legal.ref legal.s - ../../bin/cl65 --target none --cpu 6502X -o illegal.ref illegal.s - -clean: - rm -f legal.o chklegal.bin - rm -f illegal.o chkillegal.bin - rm -f all.o chkall.bin - rm -f 4510all.o chk4510.bin 4510all.lst - diff --git a/testcode/assembler/all.s b/testcode/assembler/all.s deleted file mode 100644 index 2e8f55ec7..000000000 --- a/testcode/assembler/all.s +++ /dev/null @@ -1,260 +0,0 @@ - .setcpu "6502X" - -; all legal and illegal opcodes as they would be disassembled by da65 -; note that this would not assemble into the exact same binary - - brk ; 00 - ora ($12,x) ; 01 12 - jam ; 02 - slo ($12,x) ; 03 12 - nop $12 ; 04 12 - ora $12 ; 05 12 - asl $12 ; 06 12 - slo $12 ; 07 12 - php ; 08 - ora #$12 ; 09 12 - asl a ; 0a - anc #$12 ; 0b 12 - nop $1234 ; 0c 34 12 - ora $1234 ; 0d 34 12 - asl $1234 ; 0e 34 12 - slo $1234 ; 0f 34 12 - bpl *+$14 ; 10 12 - ora ($12),y ; 11 12 - jam ; 12 - slo ($12),y ; 13 12 - nop $12,x ; 14 12 - ora $12,x ; 15 12 - asl $12,x ; 16 12 - slo $12,x ; 17 12 - clc ; 18 - ora $1234,y ; 19 34 12 - nop ; 1a - slo $1234,y ; 1b 34 12 - nop $1234,x ; 1c 34 12 - ora $1234,x ; 1d 34 12 - asl $1234,x ; 1e 34 12 - slo $1234,x ; 1f 34 12 - jsr $1234 ; 20 34 12 - and ($12,x) ; 21 12 - jam ; 22 - rla ($12,x) ; 23 12 - bit $12 ; 24 12 - and $12 ; 25 12 - rol $12 ; 26 12 - rla $12 ; 27 12 - plp ; 28 - and #$12 ; 29 12 - rol a ; 2a - anc #$12 ; 2b 12 - bit $1234 ; 2c 34 12 - and $1234 ; 2d 34 12 - rol $1234 ; 2e 34 12 - rla $1234 ; 2f 34 12 - bmi *+$14 ; 30 12 - and ($12),y ; 31 12 - jam ; 32 - rla ($12),y ; 33 12 - nop $12,x ; 34 12 - and $12,x ; 35 12 - rol $12,x ; 36 12 - rla $12,x ; 37 12 - sec ; 38 - and $1234,y ; 39 34 12 - nop ; 3a - rla $1234,y ; 3b 34 12 - nop $1234,x ; 3c 34 12 - and $1234,x ; 3d 34 12 - rol $1234,x ; 3e 34 12 - rla $1234,x ; 3f 34 12 - rti ; 40 - eor ($12,x) ; 41 12 - jam ; 42 - sre ($12,x) ; 43 12 - nop $12 ; 44 12 - eor $12 ; 45 12 - lsr $12 ; 46 12 - sre $12 ; 47 12 - pha ; 48 - eor #$12 ; 49 12 - lsr a ; 4a - alr #$12 ; 4b 12 - jmp $1234 ; 4c 34 12 - eor $1234 ; 4d 34 12 - lsr $1234 ; 4e 34 12 - sre $1234 ; 4f 34 12 - bvc *+$14 ; 50 12 - eor ($12),y ; 51 12 - jam ; 52 - sre ($12),y ; 53 12 - nop $12,x ; 54 12 - eor $12,x ; 55 12 - lsr $12,x ; 56 12 - sre $12,x ; 57 12 - cli ; 58 - eor $1234,y ; 59 34 12 - nop ; 5a - sre $1234,y ; 5b 34 12 - nop $1234,x ; 5c 34 12 - eor $1234,x ; 5d 34 12 - lsr $1234,x ; 5e 34 12 - sre $1234,x ; 5f 34 12 - rts ; 60 - adc ($12,x) ; 61 12 - jam ; 62 - rra ($12,x) ; 63 12 - nop $12 ; 64 12 - adc $12 ; 65 12 - ror $12 ; 66 12 - rra $12 ; 67 12 - pla ; 68 - adc #$12 ; 69 12 - ror a ; 6a - arr #$12 ; 6b 12 - jmp ($1234) ; 6c 34 12 - adc $1234 ; 6d 34 12 - ror $1234 ; 6e 34 12 - rra $1234 ; 6f 34 12 - bvs *+$14 ; 70 12 - adc ($12),y ; 71 12 - jam ; 72 - rra ($12),y ; 73 12 - nop $12,x ; 74 12 - adc $12,x ; 75 12 - ror $12,x ; 76 12 - rra $12,x ; 77 12 - sei ; 78 - adc $1234,y ; 79 34 12 - nop ; 7a - rra $1234,y ; 7b 34 12 - nop $1234,x ; 7c 34 12 - adc $1234,x ; 7d 34 12 - ror $1234,x ; 7e 34 12 - rra $1234,x ; 7f 34 12 - nop #$12 ; 80 12 - sta ($12,x) ; 81 12 - nop #$12 ; 82 12 - sax ($12,x) ; 83 12 - sty $12 ; 84 12 - sta $12 ; 85 12 - stx $12 ; 86 12 - sax $12 ; 87 12 - dey ; 88 - nop #$12 ; 89 12 - txa ; 8a - ane #$12 ; 8b 12 - sty $1234 ; 8c 34 12 - sta $1234 ; 8d 34 12 - stx $1234 ; 8e 34 12 - sax $1234 ; 8f 34 12 - bcc *+$14 ; 90 12 - sta ($12),y ; 91 12 - jam ; 92 - sha ($12),y ; 93 12 - sty $12,x ; 94 12 - sta $12,x ; 95 12 - stx $12,y ; 96 12 - sax $12,y ; 97 12 - tya ; 98 - sta $1234,y ; 99 34 12 - txs ; 9a - tas $1234,y ; 9b 34 12 - shy $1234,x ; 9c 34 12 - sta $1234,x ; 9d 34 12 - shx $1234,y ; 9e 34 12 - sha $1234,y ; 9f 34 12 - ldy #$12 ; a0 12 - lda ($12,x) ; a1 12 - ldx #$12 ; a2 12 - lax ($12,x) ; a3 12 - ldy $12 ; a4 12 - lda $12 ; a5 12 - ldx $12 ; a6 12 - lax $12 ; a7 12 - tay ; a8 - lda #$12 ; a9 12 - tax ; aa - lax #$12 ; ab 12 - ldy $1234 ; ac 34 12 - lda $1234 ; ad 34 12 - ldx $1234 ; ae 34 12 - lax $1234 ; af 34 12 - bcs *+$14 ; b0 12 - lda ($12),y ; b1 12 - jam ; b2 - lax ($12),y ; b3 12 - ldy $12,x ; b4 12 - lda $12,x ; b5 12 - ldx $12,y ; b6 12 - lax $12,y ; b7 12 - clv ; b8 - lda $1234,y ; b9 34 12 - tsx ; ba - las $1234,y ; bb 34 12 - ldy $1234,x ; bc 34 12 - lda $1234,x ; bd 34 12 - ldx $1234,y ; be 34 12 - lax $1234,y ; bf 34 12 - cpy #$12 ; c0 12 - cmp ($12,x) ; c1 12 - nop #$12 ; c2 12 - dcp ($12,x) ; c3 12 - cpy $12 ; c4 12 - cmp $12 ; c5 12 - dec $12 ; c6 12 - dcp $12 ; c7 12 - iny ; c8 - cmp #$12 ; c9 12 - dex ; ca - axs #$12 ; cb 12 - cpy $1234 ; cc 34 12 - cmp $1234 ; cd 34 12 - dec $1234 ; ce 34 12 - dcp $1234 ; cf 34 12 - bne *+$14 ; d0 12 - cmp ($12),y ; d1 12 - jam ; d2 - dcp ($12),y ; d3 12 - nop $12,x ; d4 12 - cmp $12,x ; d5 12 - dec $12,x ; d6 12 - dcp $12,x ; d7 12 - cld ; d8 - cmp $1234,y ; d9 34 12 - nop ; da - dcp $1234,y ; db 34 12 - nop $1234,x ; dc 34 12 - cmp $1234,x ; dd 34 12 - dec $1234,x ; de 34 12 - dcp $1234,x ; df 34 12 - cpx #$12 ; e0 12 - sbc ($12,x) ; e1 12 - nop #$12 ; e2 12 - isc ($12,x) ; e3 12 - cpx $12 ; e4 12 - sbc $12 ; e5 12 - inc $12 ; e6 12 - isc $12 ; e7 12 - inx ; e8 - sbc #$12 ; e9 12 - nop ; ea - sbc #$12 ; eb 12 - cpx $1234 ; ec 34 12 - sbc $1234 ; ed 34 12 - inc $1234 ; ee 34 12 - isc $1234 ; ef 34 12 - beq *+$14 ; f0 12 - sbc ($12),y ; f1 12 - jam ; f2 - isc ($12),y ; f3 12 - nop $12,x ; f4 12 - sbc $12,x ; f5 12 - inc $12,x ; f6 12 - isc $12,x ; f7 12 - sed ; f8 - sbc $1234,y ; f9 34 12 - isc $1234,y ; fb 34 12 - nop $1234,x ; fc 34 12 - sbc $1234,x ; fd 34 12 - inc $1234,x ; fe 34 12 - isc $1234,x ; ff 34 12 diff --git a/testcode/assembler/illegal.ref b/testcode/assembler/illegal.ref deleted file mode 100644 index c8dc208b4..000000000 --- a/testcode/assembler/illegal.ref +++ /dev/null @@ -1 +0,0 @@ -444'/4?4;4#73O4_4[4GCWSo44{4gcwsÏ4ß4Û4ÇÃ×Óï4ÿ4û4çã÷ó4‡ƒ—¯4¿4§£³· kKË 44€“Ÿ4ž4œ4›4»4«‹ \ No newline at end of file diff --git a/testcode/assembler/illegal.s b/testcode/assembler/illegal.s deleted file mode 100644 index b49b88761..000000000 --- a/testcode/assembler/illegal.s +++ /dev/null @@ -1,135 +0,0 @@ - - .setcpu "6502X" - -; all so called "illegal" opcodes. duplicated (functionally identical) ones -; are commented out - -; first all totally stable undocs: - - slo $12 ; 07 12 - slo $1234 ; 0f 34 12 - slo $1234,x ; 1f 34 12 - slo $1234,y ; 1b 34 12 - slo ($12,x) ; 03 12 - slo $12,x ; 17 12 - slo ($12),y ; 13 12 - - rla $12 ; 27 12 - rla $1234 ; 2f 34 12 - rla $1234,x ; 3f 34 12 - rla $1234,y ; 3b 34 12 - rla ($12,x) ; 23 12 - rla $12,x ; 37 12 - rla ($12),y ; 33 12 - - sre $1234 ; 4f 34 12 - sre $1234,x ; 5f 34 12 - sre $1234,y ; 5b 34 12 - sre $12 ; 47 12 - sre ($12,x) ; 43 12 - sre $12,x ; 57 12 - sre ($12),y ; 53 12 - - rra $1234 ; 6f 34 12 - rra $1234,x ; 7f 34 12 - rra $1234,y ; 7b 34 12 - rra $12 ; 67 12 - rra ($12,x) ; 63 12 - rra $12,x ; 77 12 - rra ($12),y ; 73 12 - - dcp $1234 ; cf 34 12 - dcp $1234,x ; df 34 12 - dcp $1234,y ; db 34 12 - dcp $12 ; c7 12 - dcp ($12,x) ; c3 12 - dcp $12,x ; d7 12 - dcp ($12),y ; d3 12 - - isc $1234 ; ef 34 12 - isc $1234,x ; ff 34 12 - isc $1234,y ; fb 34 12 - isc $12 ; e7 12 - isc ($12,x) ; e3 12 - isc $12,x ; f7 12 - isc ($12),y ; f3 12 - - sax $1234 ; 8f 34 12 - sax $12 ; 87 12 - sax ($12,x) ; 83 12 - sax $12,y ; 97 12 - - lax $1234 ; af 34 12 - lax $1234,y ; bf 34 12 - lax $12 ; a7 12 - lax ($12,x) ; a3 12 - lax ($12),y ; b3 12 - lax $12,y ; b7 12 - - anc #$12 ; 0b 12 - ;anc #$12 ; 2b 12 - - arr #$12 ; 6b 12 - - alr #$12 ; 4b 12 - - axs #$12 ; cb 12 - - nop $1234 ; 0c 34 12 - nop $1234,x ; 1c 34 12 - nop $12 ; 04 12 - nop $12,x ; 14 12 - nop #$12 ; 80 12 - ;nop $1234,x ; 3c 34 12 - ;nop $1234,x ; 5c 34 12 - ;nop $1234,x ; 7c 34 12 - ;nop $1234,x ; dc 34 12 - ;nop $1234,x ; fc 34 12 - ;nop $12 ; 44 12 - ;nop $12 ; 64 12 - ;nop #$12 ; 82 12 - ;nop #$12 ; 89 12 - ;nop #$12 ; c2 12 - ;nop #$12 ; e2 12 - ;nop $12,x ; 34 12 - ;nop $12,x ; 54 12 - ;nop $12,x ; 74 12 - ;nop $12,x ; d4 12 - ;nop $12,x ; f4 12 - ;nop ; 1a - ;nop ; 3a - ;nop ; 5a - ;nop ; 7a - ;nop ; da - - jam ; 02 - ;jam ; 12 - ;jam ; 22 - ;jam ; 32 - ;jam ; 42 - ;jam ; 52 - ;jam ; 62 - ;jam ; 72 - ;jam ; 92 - ;jam ; b2 - ;jam ; d2 - ;jam ; f2 - - ;sbc #$12 ; eb 12 - -; the so-called "unstable" ones: - - sha ($12),y ; 93 12 - sha $1234,y ; 9f 34 12 - - shx $1234,y ; 9e 34 12 - shy $1234,x ; 9c 34 12 - - tas $1234,y ; 9b 34 12 - las $1234,y ; bb 34 12 - -; the two so-called "highly unstable" ones: - - lax #$12 ; ab 12 - - ane #$12 ; 8b 12 diff --git a/testcode/assembler/legal.ref b/testcode/assembler/legal.ref deleted file mode 100644 index c38f2901465090f656f005ccd12e091ee55c3911..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 321 zcmV~$L1+j700q!F5XzcYmK|tn7DCjwI1mS#W#TY#u;wr!WQU0ZrI2K6D-$b)SR<3w z2#qMyCS(WVuw`W$Ar8cW_TIiY5{IMSZaXw;FxPyGVr8s|IhI*!lERoB#iq8n?S~~^ zE3(M}Wfn%k%y(Pwy^NuFAAJTq@y4L9@xezg;<2Y*#c(|H*7H-<u|2lMTI;P*W3%t^ zKR)?wtbar7jne3fhjBlyx$d$%y4{LLaYcu_Zbolha#fFwQ5)-QQT1h_DW=7&D2WMX zn67g2u6gAa$Ev8XV1FEqoetWwy6#*2i@!1Ivk|}iwEWMZrnndv;)G+`v}%r%&N&mu Mopq!0!Rhw%<3WF3zyJUM diff --git a/testcode/assembler/legal.s b/testcode/assembler/legal.s deleted file mode 100644 index 1de43b98b..000000000 --- a/testcode/assembler/legal.s +++ /dev/null @@ -1,185 +0,0 @@ - - .setcpu "6502" - - adc $1234 ; 6d 34 12 - adc $1234,x ; 7d 34 12 - adc $1234,y ; 79 34 12 - adc $12 ; 65 12 - adc #$12 ; 69 12 - adc ($12,x) ; 61 12 - adc $12,x ; 75 12 - adc ($12),y ; 71 12 - - and $12 ; 25 12 - and #$12 ; 29 12 - and $1234 ; 2d 34 12 - and $1234,x ; 3d 34 12 - and $1234,y ; 39 34 12 - and ($12,x) ; 21 12 - and $12,x ; 35 12 - and ($12),y ; 31 12 - - asl $12 ; 06 12 - asl $1234 ; 0e 34 12 - asl $1234,x ; 1e 34 12 - asl $12,x ; 16 12 - asl a ; 0a - - bcc *+$14 ; 90 12 - bcs *+$14 ; b0 12 - beq *+$14 ; f0 12 - bmi *+$14 ; 30 12 - bne *+$14 ; d0 12 - bpl *+$14 ; 10 12 - bvc *+$14 ; 50 12 - bvs *+$14 ; 70 12 - - bit $12 ; 24 12 - bit $1234 ; 2c 34 12 - - brk ; 00 - - clc ; 18 - cld ; d8 - cli ; 58 - clv ; b8 - - cmp $1234 ; cd 34 12 - cmp $1234,x ; dd 34 12 - cmp $1234,y ; d9 34 12 - cmp $12 ; c5 12 - cmp #$12 ; c9 12 - cmp ($12,x) ; c1 12 - cmp $12,x ; d5 12 - cmp ($12),y ; d1 12 - - cpx $1234 ; ec 34 12 - cpx #$12 ; e0 12 - cpx $12 ; e4 12 - - cpy $1234 ; cc 34 12 - cpy #$12 ; c0 12 - cpy $12 ; c4 12 - - dec $1234 ; ce 34 12 - dec $1234,x ; de 34 12 - dec $12 ; c6 12 - dec $12,x ; d6 12 - - dex ; ca - dey ; 88 - - eor $1234 ; 4d 34 12 - eor $1234,x ; 5d 34 12 - eor $1234,y ; 59 34 12 - eor $12 ; 45 12 - eor #$12 ; 49 12 - eor ($12,x) ; 41 12 - eor $12,x ; 55 12 - eor ($12),y ; 51 12 - - inc $1234 ; ee 34 12 - inc $1234,x ; fe 34 12 - inc $12 ; e6 12 - inc $12,x ; f6 12 - - inx ; e8 - iny ; c8 - - jmp $1234 ; 4c 34 12 - jmp ($1234) ; 6c 34 12 - - jsr $1234 ; 20 34 12 - - lda $1234 ; ad 34 12 - lda $1234,x ; bd 34 12 - lda $1234,y ; b9 34 12 - lda $12 ; a5 12 - lda #$12 ; a9 12 - lda ($12,x) ; a1 12 - lda $12,x ; b5 12 - lda ($12),y ; b1 12 - - ldx $1234 ; ae 34 12 - ldx $1234,y ; be 34 12 - ldx #$12 ; a2 12 - ldx $12 ; a6 12 - ldx $12,y ; b6 12 - - ldy $1234 ; ac 34 12 - ldy $1234,x ; bc 34 12 - ldy #$12 ; a0 12 - ldy $12 ; a4 12 - ldy $12,x ; b4 12 - - lsr $1234 ; 4e 34 12 - lsr $1234,x ; 5e 34 12 - lsr $12 ; 46 12 - lsr $12,x ; 56 12 - lsr a ; 4a - - nop ; ea - - ora $12 ; 05 12 - ora #$12 ; 09 12 - ora $1234 ; 0d 34 12 - ora $1234,x ; 1d 34 12 - ora $1234,y ; 19 34 12 - ora ($12,x) ; 01 12 - ora $12,x ; 15 12 - ora ($12),y ; 11 12 - - pha ; 48 - php ; 08 - pla ; 68 - plp ; 28 - - rol $12 ; 26 12 - rol $1234 ; 2e 34 12 - rol $1234,x ; 3e 34 12 - rol $12,x ; 36 12 - rol a ; 2a - ror $1234 ; 6e 34 12 - ror $1234,x ; 7e 34 12 - ror $12 ; 66 12 - ror $12,x ; 76 12 - ror a ; 6a - - rti ; 40 - rts ; 60 - - sbc $1234 ; ed 34 12 - sbc $1234,x ; fd 34 12 - sbc $1234,y ; f9 34 12 - sbc $12 ; e5 12 - sbc #$12 ; e9 12 - sbc ($12,x) ; e1 12 - sbc $12,x ; f5 12 - sbc ($12),y ; f1 12 - - sec ; 38 - sed ; f8 - sei ; 78 - - sta $1234 ; 8d 34 12 - sta $1234,x ; 9d 34 12 - sta $1234,y ; 99 34 12 - sta $12 ; 85 12 - sta ($12,x) ; 81 12 - sta $12,x ; 95 12 - sta ($12),y ; 91 12 - - stx $1234 ; 8e 34 12 - stx $12 ; 86 12 - stx $12,y ; 96 12 - - sty $1234 ; 8c 34 12 - sty $12 ; 84 12 - sty $12,x ; 94 12 - - tax ; aa - tay ; a8 - tsx ; ba - txa ; 8a - txs ; 9a - tya ; 98 From 896b7c1116e90e8f1bb7a8ec92fd556b7144dfdf Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 4 Sep 2016 12:22:11 +0200 Subject: [PATCH 150/407] Added comment about commented-out value. --- asminc/cpu.mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asminc/cpu.mac b/asminc/cpu.mac index a67407a4a..6b9cb9947 100644 --- a/asminc/cpu.mac +++ b/asminc/cpu.mac @@ -7,7 +7,7 @@ CPU_ISET_65C02 = $0010 CPU_ISET_65816 = $0020 CPU_ISET_SWEET16 = $0040 CPU_ISET_HUC6280 = $0080 -;CPU_ISET_M740 = $0100 +;CPU_ISET_M740 = $0100 not actually implemented CPU_ISET_4510 = $0200 ; CPU capabilities From f007fc13d581c0056695e7854d8f9e580f4c2b7c Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Tue, 6 Sep 2016 14:54:21 +0200 Subject: [PATCH 151/407] added README for test/assembler --- test/assembler/Makefile | 2 +- test/assembler/README | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/assembler/README diff --git a/test/assembler/Makefile b/test/assembler/Makefile index 5e4d580b5..47f403469 100644 --- a/test/assembler/Makefile +++ b/test/assembler/Makefile @@ -14,7 +14,7 @@ TARGETS += huc6280 all: $(addprefix $(WORKDIR)/, $(addsuffix -opcodes.bin, $(TARGETS))) @# -.PHONY: $(addprefix $(WORKDIR)/, $(addsuffix -opcodes.bin, $(TARGETS))) +.PHONY: all clean $(addprefix $(WORKDIR)/, $(addsuffix -opcodes.bin, $(TARGETS))) clean: rm -f *.o *.bin *.lst diff --git a/test/assembler/README b/test/assembler/README new file mode 100644 index 000000000..697c24449 --- /dev/null +++ b/test/assembler/README @@ -0,0 +1,29 @@ + +Assembler Testcases +=================== + +These testcases are inspired by the ones now removed from test/assembler. +The main purpose is to have each possible opcode generated at least once, +either by an assembly instruction or a ".byte"-placeholder. Typically +generated by disassembling a binary dump that contains data in the form +of the pattern that each opcode is stated once in order followed by easy +to recognise: + +00 00 EA 00 +01 00 EA 00 +02 00 EA 00 +[...] +fe 00 EA 00 +ff 00 EA 00 + +The disassembly is then put in a better readable form by replacing the +leftover dummy opcode parameters with something more recognizable. + +The testcases for 6502, 6502x, 65sc02, 65c02, 4510, and huc6280 have been +put together by Sven Oliver ("SvOlli") Moll, as well as a template for the +m740 instructions set. + +Still to do is to find a way to implement a testcase for the 65816 +processor, since it's capable of executing instructions with an 8-bit and +a 16-bit operator alike, only distinguished by one processor flag. + From 3531bcbf3e3aac04b8967949bcc77e8e13395418 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 6 Sep 2016 15:13:44 +0200 Subject: [PATCH 152/407] Fix some typos. --- doc/atari.sgml | 2 +- src/ca65/scanner.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/atari.sgml b/doc/atari.sgml index 54f3aab78..a0dbe2f47 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -337,7 +337,7 @@ A word of caution: Since the <tt/0x00/ character has to be mapped in an incompatible way to the C-standard, the usage of string functions in conjunction with internal character mapped strings delivers unexpected results regarding the string length. The end of strings are detected where -you may not expect them (to early or (much) to late). Internal mapped +you may not expect them (too early or (much) too late). Internal mapped strings typically support the "<tt/mem...()/" functions. <em>For assembler sources the macro "<tt/scrcode/" from the "<tt/atari.mac/" diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index f33ed5def..994f95fba 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -408,7 +408,7 @@ static void IFNextChar (CharSource* S) /* If we come here, we have a new input line. To avoid problems ** with strange line terminators, remove all whitespace from the - ** end of the line, the add a single newline. + ** end of the line, then add a single newline. */ Len = SB_GetLen (&S->V.File.Line); while (Len > 0 && IsSpace (SB_AtUnchecked (&S->V.File.Line, Len-1))) { From ae3f9bbd778ac8525c586d77a201c0ad36db2ba5 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Wed, 7 Sep 2016 19:21:24 +0200 Subject: [PATCH 153/407] Added assembler pseudo commands .P4510 and .IFP4510 together with docs and testcase --- doc/ca65.sgml | 37 ++++++++++++++++---- src/ca65/condasm.c | 11 ++++++ src/ca65/pseudo.c | 10 ++++++ src/ca65/scanner.c | 2 ++ src/ca65/token.h | 2 ++ test/assembler/4510-cpudetect.ref | Bin 0 -> 60 bytes test/assembler/6502-cpudetect.ref | Bin 0 -> 16 bytes test/assembler/6502x-cpudetect.ref | Bin 0 -> 29 bytes test/assembler/65816-cpudetect.ref | Bin 0 -> 61 bytes test/assembler/65c02-cpudetect.ref | Bin 0 -> 47 bytes test/assembler/65sc02-cpudetect.ref | Bin 0 -> 33 bytes test/assembler/Makefile | 49 ++++++++++++++++++--------- test/assembler/README | 21 +++++++++++- test/assembler/huc6280-cpudetect.ref | Bin 0 -> 62 bytes 14 files changed, 109 insertions(+), 23 deletions(-) create mode 100644 test/assembler/4510-cpudetect.ref create mode 100644 test/assembler/6502-cpudetect.ref create mode 100644 test/assembler/6502x-cpudetect.ref create mode 100644 test/assembler/65816-cpudetect.ref create mode 100644 test/assembler/65c02-cpudetect.ref create mode 100644 test/assembler/65sc02-cpudetect.ref create mode 100644 test/assembler/huc6280-cpudetect.ref diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 6ce5ecef6..baabffa7c 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -424,8 +424,10 @@ The assembler accepts <tt><ref id=".PSC02" name=".PSC02"></tt> command was given). <item>all valid 65C02 mnemonics when in 65C02 mode (after the <tt><ref id=".PC02" name=".PC02"></tt> command was given). -<item>all valid 65618 mnemonics when in 65816 mode (after the +<item>all valid 65816 mnemonics when in 65816 mode (after the <tt><ref id=".P816" name=".P816"></tt> command was given). +<item>all valid 4510 mnemonics when in 4510 mode (after the + <tt><ref id=".P4510" name=".P4510"></tt> command was given). </itemize> @@ -3103,6 +3105,12 @@ Here's a list of all control commands and a description, what they do: (see <tt><ref id=".P02" name=".P02"></tt> command). +<sect1><tt>.IFP4510</tt><label id=".IFP4510"><p> + + Conditional assembly: Check if the assembler is currently in 4510 mode + (see <tt><ref id=".P4510" name=".P4510"></tt> command). + + <sect1><tt>.IFP816</tt><label id=".IFP816"><p> Conditional assembly: Check if the assembler is currently in 65816 mode @@ -3494,7 +3502,18 @@ Here's a list of all control commands and a description, what they do: <tt><ref id="option--cpu" name="--cpu"></tt> command line option. See: <tt><ref id=".PC02" name=".PC02"></tt>, <tt><ref id=".PSC02" - name=".PSC02"></tt> and <tt><ref id=".P816" name=".P816"></tt> + name=".PSC02"></tt>, <tt><ref id=".P816" name=".P816"></tt> and + <tt><ref id=".P4510" name=".P4510"></tt> + + +<sect1><tt>.P4510</tt><label id=".P4510"><p> + + Enable the 4510 instruction set. This is a superset of the 65C02 and + 6502 instruction sets. + + See: <tt><ref id=".P02" name=".P02"></tt>, <tt><ref id=".PSC02" + name=".PSC02"></tt>, <tt><ref id=".PC02" name=".PC02"></tt> and + <tt><ref id=".P816" name=".P816"></tt> <sect1><tt>.P816</tt><label id=".P816"><p> @@ -3503,7 +3522,8 @@ Here's a list of all control commands and a description, what they do: 6502 instruction sets. See: <tt><ref id=".P02" name=".P02"></tt>, <tt><ref id=".PSC02" - name=".PSC02"></tt> and <tt><ref id=".PC02" name=".PC02"></tt> + name=".PSC02"></tt>, <tt><ref id=".PC02" name=".PC02"></tt> and + <tt><ref id=".P4510" name=".P4510"></tt> <sect1><tt>.PAGELEN, .PAGELENGTH</tt><label id=".PAGELENGTH"><p> @@ -3531,7 +3551,8 @@ Here's a list of all control commands and a description, what they do: 6502 and 65SC02 instructions. See: <tt><ref id=".P02" name=".P02"></tt>, <tt><ref id=".PSC02" - name=".PSC02"></tt> and <tt><ref id=".P816" name=".P816"></tt> + name=".PSC02"></tt>, <tt><ref id=".P816" name=".P816"></tt> and + <ref id=".P4510" name=".P4510">4510</tt> <sect1><tt>.POPCPU</tt><label id=".POPCPU"><p> @@ -3604,7 +3625,8 @@ Here's a list of all control commands and a description, what they do: 6502 instructions. See: <tt><ref id=".P02" name=".P02"></tt>, <tt><ref id=".PC02" - name=".PC02"></tt> and <tt><ref id=".P816" name=".P816"></tt> + name=".PC02"></tt>, <tt><ref id=".P816" name=".P816"></tt> and + <tt><ref id=".P4510" name=".P4510"></tt> <sect1><tt>.PUSHCPU</tt><label id=".PUSHCPU"><p> @@ -3796,7 +3818,7 @@ Here's a list of all control commands and a description, what they do: Switch the CPU instruction set. The command is followed by a string that specifies the CPU. Possible values are those that can also be supplied to the <tt><ref id="option--cpu" name="--cpu"></tt> command line option, - namely: 6502, 6502X, 65SC02, 65C02, 65816 and HuC6280. + namely: 6502, 6502X, 65SC02, 65C02, 65816, 4510 and HuC6280. See: <tt><ref id=".CPU" name=".CPU"></tt>, <tt><ref id=".IFP02" name=".IFP02"></tt>, @@ -3805,6 +3827,7 @@ Here's a list of all control commands and a description, what they do: <tt><ref id=".IFPSC02" name=".IFPSC02"></tt>, <tt><ref id=".P02" name=".P02"></tt>, <tt><ref id=".P816" name=".P816"></tt>, + <tt><ref id=".P4510" name=".P4510"></tt> <tt><ref id=".PC02" name=".PC02"></tt>, <tt><ref id=".PSC02" name=".PSC02"></tt> @@ -4501,6 +4524,7 @@ each supported CPU a constant similar to CPU_65816 CPU_SWEET16 CPU_HUC6280 + CPU_4510 </verb></tscreen> is defined. These constants may be used to determine the exact type of the @@ -4514,6 +4538,7 @@ another constant is defined: CPU_ISET_65816 CPU_ISET_SWEET16 CPU_ISET_HUC6280 + CPU_ISET_4510 </verb></tscreen> The value read from the <tt/<ref id=".CPU" name=".CPU">/ pseudo variable may diff --git a/src/ca65/condasm.c b/src/ca65/condasm.c index 24cbae696..b8bda4c7d 100644 --- a/src/ca65/condasm.c +++ b/src/ca65/condasm.c @@ -386,6 +386,16 @@ void DoConditionals (void) CalcOverallIfCond (); break; + case TOK_IFP4510: + D = AllocIf (".IFP4510", 1); + NextTok (); + if (IfCond) { + SetIfCond (D, GetCPU() == CPU_4510); + } + ExpectSep (); + CalcOverallIfCond (); + break; + case TOK_IFP816: D = AllocIf (".IFP816", 1); NextTok (); @@ -457,6 +467,7 @@ int CheckConditionals (void) case TOK_IFNDEF: case TOK_IFNREF: case TOK_IFP02: + case TOK_IFP4510: case TOK_IFP816: case TOK_IFPC02: case TOK_IFPSC02: diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index 250ceecc9..b44c28dd8 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -1530,6 +1530,14 @@ static void DoP816 (void) +static void DoP4510 (void) +/* Switch to 4510 CPU */ +{ + SetCPU (CPU_4510); +} + + + static void DoPageLength (void) /* Set the page length for the listing */ { @@ -2033,6 +2041,7 @@ static CtrlDesc CtrlCmdTab [] = { { ccKeepToken, DoConditionals }, /* .IFNDEF */ { ccKeepToken, DoConditionals }, /* .IFNREF */ { ccKeepToken, DoConditionals }, /* .IFP02 */ + { ccKeepToken, DoConditionals }, /* .IFP4510 */ { ccKeepToken, DoConditionals }, /* .IFP816 */ { ccKeepToken, DoConditionals }, /* .IFPC02 */ { ccKeepToken, DoConditionals }, /* .IFPSC02 */ @@ -2063,6 +2072,7 @@ static CtrlDesc CtrlCmdTab [] = { { ccNone, DoOrg }, { ccNone, DoOut }, { ccNone, DoP02 }, + { ccNone, DoP4510 }, { ccNone, DoP816 }, { ccNone, DoPageLength }, { ccNone, DoUnexpected }, /* .PARAMCOUNT */ diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 994f95fba..e186b19a7 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -216,6 +216,7 @@ struct DotKeyword { { ".IFNDEF", TOK_IFNDEF }, { ".IFNREF", TOK_IFNREF }, { ".IFP02", TOK_IFP02 }, + { ".IFP4510", TOK_IFP4510 }, { ".IFP816", TOK_IFP816 }, { ".IFPC02", TOK_IFPC02 }, { ".IFPSC02", TOK_IFPSC02 }, @@ -251,6 +252,7 @@ struct DotKeyword { { ".ORG", TOK_ORG }, { ".OUT", TOK_OUT }, { ".P02", TOK_P02 }, + { ".P4510", TOK_P4510 }, { ".P816", TOK_P816 }, { ".PAGELEN", TOK_PAGELENGTH }, { ".PAGELENGTH", TOK_PAGELENGTH }, diff --git a/src/ca65/token.h b/src/ca65/token.h index 93dfaa092..8998cc162 100644 --- a/src/ca65/token.h +++ b/src/ca65/token.h @@ -193,6 +193,7 @@ typedef enum token_t { TOK_IFNDEF, TOK_IFNREF, TOK_IFP02, + TOK_IFP4510, TOK_IFP816, TOK_IFPC02, TOK_IFPSC02, @@ -223,6 +224,7 @@ typedef enum token_t { TOK_ORG, TOK_OUT, TOK_P02, + TOK_P4510, TOK_P816, TOK_PAGELENGTH, TOK_PARAMCOUNT, diff --git a/test/assembler/4510-cpudetect.ref b/test/assembler/4510-cpudetect.ref new file mode 100644 index 0000000000000000000000000000000000000000..515557c854d36f3bc8310b6c2a9cc0b2b0a98ade GIT binary patch literal 60 hcmeZfa1IEK_Y8Ioi8nJfFhb@9JEQVZxF)8C1_0up55fQd literal 0 HcmV?d00001 diff --git a/test/assembler/6502-cpudetect.ref b/test/assembler/6502-cpudetect.ref new file mode 100644 index 0000000000000000000000000000000000000000..9b0aeb1f0915c5f4d81e08d02a8e223b4f6464d6 GIT binary patch literal 16 XcmZ4aiorP`G~P4VH6-55)W8S;Gr|Qt literal 0 HcmV?d00001 diff --git a/test/assembler/6502x-cpudetect.ref b/test/assembler/6502x-cpudetect.ref new file mode 100644 index 0000000000000000000000000000000000000000..3434ecbea7fb1e119879fae346989933fd09bacd GIT binary patch literal 29 ZcmZQ@4hW6+40a8PH#0RbVnE?V0042#2dMx6 literal 0 HcmV?d00001 diff --git a/test/assembler/65816-cpudetect.ref b/test/assembler/65816-cpudetect.ref new file mode 100644 index 0000000000000000000000000000000000000000..4f6e767b0b9e0d16b239976a71a01268186788b3 GIT binary patch literal 61 gcmaFO;2aPd?-}eG5^rW|V1&#Ic1Go+aV-qZ02t>Gq5uE@ literal 0 HcmV?d00001 diff --git a/test/assembler/65c02-cpudetect.ref b/test/assembler/65c02-cpudetect.ref new file mode 100644 index 0000000000000000000000000000000000000000..9f790d5ffe95736f46383b1c132407d7f96bf2b0 GIT binary patch literal 47 ecmZP<VsH)!jrR<84T(21H84Wv1v{hifm{F-u?y<} literal 0 HcmV?d00001 diff --git a/test/assembler/65sc02-cpudetect.ref b/test/assembler/65sc02-cpudetect.ref new file mode 100644 index 0000000000000000000000000000000000000000..4e11bd708c8c298112aabc639c2fe6ba710cc69c GIT binary patch literal 33 ecmb<15n^x-2#xm)b`6O)Gc_<m<^?+&7y$s1#0aSX literal 0 HcmV?d00001 diff --git a/test/assembler/Makefile b/test/assembler/Makefile index 47f403469..faefddf7a 100644 --- a/test/assembler/Makefile +++ b/test/assembler/Makefile @@ -5,26 +5,43 @@ BINDIR = ../../bin #WORKDIR := ../../testwrk WORKDIR := . -TARGETS = 6502 6502x 65sc02 65c02 -#TARGETS += 65816 -TARGETS += 4510 -TARGETS += huc6280 -#TARGETS += m740 +BASE_TARGETS = 6502 6502x 65sc02 65c02 +BASE_TARGETS += 4510 huc6280 -all: $(addprefix $(WORKDIR)/, $(addsuffix -opcodes.bin, $(TARGETS))) +OPCODE_TARGETS = $(BASE_TARGETS) +CPUDETECT_TARGETS = $(BASE_TARGETS) + +CPUDETECT_TARGETS += 65816 + +# default target defined later +all: + +# generate opcode targets and expand target list +define opcode +OPCODE_TARGETLIST += $(1)-opcodes.bin +$$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s + @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$< + @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1) + @echo ca65 --cpu $(1) opcodes ok +endef +$(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target)))) + +# generate cpudetect targets and expand target list +define cpudetect +CPUDETECT_TARGETLIST += $(1)-cpudetect.bin +$$(WORKDIR)/$(1)-cpudetect.bin: cpudetect.s + @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-cpudetect.lst --obj-path $$(WORKDIR) -o $$@ $$< + @diff -q $(1)-cpudetect.ref $$@ || (cat $$(WORKDIR)/$(1)-cpudetect.lst ; exit 1) + @echo ca65 --cpu $(1) cpudetect ok +endef +$(foreach target,$(CPUDETECT_TARGETS),$(eval $(call cpudetect,$(target)))) + +# now that all targets have been generated, get to the manual ones +all: $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST) @# -.PHONY: all clean $(addprefix $(WORKDIR)/, $(addsuffix -opcodes.bin, $(TARGETS))) - clean: rm -f *.o *.bin *.lst -define build -$$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s - @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$< - @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1) - @echo ca65 --cpu $(1) ok -endef - -$(foreach target,$(TARGETS),$(eval $(call build,$(target)))) +.PHONY: all clean $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST) diff --git a/test/assembler/README b/test/assembler/README index 697c24449..a2b1e9a41 100644 --- a/test/assembler/README +++ b/test/assembler/README @@ -2,6 +2,9 @@ Assembler Testcases =================== +Opcode Tests: +------------- + These testcases are inspired by the ones now removed from test/assembler. The main purpose is to have each possible opcode generated at least once, either by an assembly instruction or a ".byte"-placeholder. Typically @@ -23,7 +26,23 @@ The testcases for 6502, 6502x, 65sc02, 65c02, 4510, and huc6280 have been put together by Sven Oliver ("SvOlli") Moll, as well as a template for the m740 instructions set. -Still to do is to find a way to implement a testcase for the 65816 +Still to do is to find a way to implement an opcode testcase for the 65816 processor, since it's capable of executing instructions with an 8-bit and a 16-bit operator alike, only distinguished by one processor flag. + +CPU detect Tests +---------------- + +These tests all assemble the same file "cpudetect.s" which contains several +conditionals for several CPUs, only using every option known to the "--cpu" +commandline switch of ca65/cl65. + + +Reference (".ref") Files +------------------------ + +A hint on creating these files: when running the test, it will fail due to +the missing ".ref" file. Review the output of the ".lst" very pedantic, then +copy the ".bin" to the ".ref" file. + diff --git a/test/assembler/huc6280-cpudetect.ref b/test/assembler/huc6280-cpudetect.ref new file mode 100644 index 0000000000000000000000000000000000000000..646e0f48cfcaf4a1a191b0fe3a508d02423bf0b6 GIT binary patch literal 62 kcmZQ@4hW6+40a8PH#0RbVnE^rJEQVZxE`U-W=0kU00MFlT>t<8 literal 0 HcmV?d00001 From 7a9a7c3188bf36b278922439f957af7dab4617c2 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Wed, 7 Sep 2016 19:41:37 +0200 Subject: [PATCH 154/407] test/assembler: removed WORKDIR variable, as remote assembling does only work partly --- test/assembler/Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/assembler/Makefile b/test/assembler/Makefile index faefddf7a..a085bc390 100644 --- a/test/assembler/Makefile +++ b/test/assembler/Makefile @@ -2,8 +2,6 @@ # makefile for the assembler regression tests BINDIR = ../../bin -#WORKDIR := ../../testwrk -WORKDIR := . BASE_TARGETS = 6502 6502x 65sc02 65c02 BASE_TARGETS += 4510 huc6280 @@ -19,9 +17,9 @@ all: # generate opcode targets and expand target list define opcode OPCODE_TARGETLIST += $(1)-opcodes.bin -$$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s - @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$< - @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1) +$(1)-opcodes.bin: $(1)-opcodes.s + @$$(BINDIR)/cl65 --cpu $(1) -t none -l $(1)-opcodes.lst -o $$@ $$< + @diff -q $(1)-opcodes.ref $$@ || (cat $(1)-opcodes.lst ; exit 1) @echo ca65 --cpu $(1) opcodes ok endef $(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target)))) @@ -29,9 +27,9 @@ $(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target)))) # generate cpudetect targets and expand target list define cpudetect CPUDETECT_TARGETLIST += $(1)-cpudetect.bin -$$(WORKDIR)/$(1)-cpudetect.bin: cpudetect.s - @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-cpudetect.lst --obj-path $$(WORKDIR) -o $$@ $$< - @diff -q $(1)-cpudetect.ref $$@ || (cat $$(WORKDIR)/$(1)-cpudetect.lst ; exit 1) +$(1)-cpudetect.bin: cpudetect.s + @$$(BINDIR)/cl65 --cpu $(1) -t none -l $(1)-cpudetect.lst -o $$@ $$< + @diff -q $(1)-cpudetect.ref $$@ || (cat $(1)-cpudetect.lst ; exit 1) @echo ca65 --cpu $(1) cpudetect ok endef $(foreach target,$(CPUDETECT_TARGETS),$(eval $(call cpudetect,$(target)))) From c0d2643952b36a593777ca673238f69a8f1d7135 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Wed, 7 Sep 2016 19:44:11 +0200 Subject: [PATCH 155/407] added 4510 cpu detection to getcpu.s --- include/6502.h | 1 + libsrc/common/getcpu.s | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/6502.h b/include/6502.h index 6c104c83a..31398e5c1 100644 --- a/include/6502.h +++ b/include/6502.h @@ -50,6 +50,7 @@ typedef unsigned size_t; #define CPU_6502 0 #define CPU_65C02 1 #define CPU_65816 2 +#define CPU_4510 3 unsigned char getcpu (void); /* Detect the CPU the program is running on */ diff --git a/libsrc/common/getcpu.s b/libsrc/common/getcpu.s index b7954f52f..1e60a5d39 100644 --- a/libsrc/common/getcpu.s +++ b/libsrc/common/getcpu.s @@ -12,6 +12,7 @@ ; - carry clear and 0 in A for a NMOS 6502 CPU ; - carry set and 1 in A for some CMOS 6502 CPU ; - carry set and 2 in A for a 65816 +; - carry set and 3 in A for a 4510 ; ; This function uses a $1A opcode which is a INA on the 816 and ignored ; (interpreted as a NOP) on a NMOS 6502. There are several CMOS versions @@ -22,16 +23,24 @@ _getcpu: lda #0 - inc a ; .byte $1A + inc a ; .byte $1A ; nop on nmos, inc on every cmos cmp #1 bcc @L9 -; This is at least a 65C02, check for a 65816 +; This is at least a 65C02, check for a 4510 + + .byte $42,$ea ; neg on 4510, nop #$ea on 65c02, wdm $ea on 65816 + cmp #1 + bne @L8 + +; check for 65816; after 4510, because $eb there is row (rotate word) xba ; .byte $eb, put $01 in B accu dec a ; .byte $3a, A=$00 if 65C02 xba ; .byte $eb, get $01 back if 65816 inc a ; .byte $1a, make $01/$02 + .byte $2c ; bit instruction to skip next command +@L8: lda #3 ; CPU_4510 constant @L9: ldx #0 ; Load high byte of word rts From a5772f7dc33b10a5551e49127277ae0012392261 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Wed, 7 Sep 2016 19:49:21 +0200 Subject: [PATCH 156/407] added forgotten testcase for testing cpu based conditional assembling --- test/assembler/cpudetect.s | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 test/assembler/cpudetect.s diff --git a/test/assembler/cpudetect.s b/test/assembler/cpudetect.s new file mode 100644 index 000000000..adad7c1dc --- /dev/null +++ b/test/assembler/cpudetect.s @@ -0,0 +1,66 @@ + +.macpack cpu + +; step 1: try to assemble an instruction that's exclusive to this set +; (when possible) + +.ifp02 + lda #$ea +.endif + +.ifpsc02 + jmp ($1234,x) +.endif + +.ifpc02 + rmb0 $12 +.endif + +.ifp816 + xba +.endif + +.ifp4510 + taz +.endif + + +; step 2: check for bitwise compatibility of instructions sets +; (made verbose for better reading with hexdump/hd(1)) + +.if (.cpu .bitand CPU_ISET_NONE) + .byte 0,"CPU_ISET_NONE" +.endif + +.if (.cpu .bitand CPU_ISET_6502) + .byte 0,"CPU_ISET_6502" +.endif + +.if (.cpu .bitand CPU_ISET_6502X) + .byte 0,"CPU_ISET_6502X" +.endif + +.if (.cpu .bitand CPU_ISET_65SC02) + .byte 0,"CPU_ISET_65SC02" +.endif + +.if (.cpu .bitand CPU_ISET_65C02) + .byte 0,"CPU_ISET_65C02" +.endif + +.if (.cpu .bitand CPU_ISET_65816) + .byte 0,"CPU_ISET_65816" +.endif + +.if (.cpu .bitand CPU_ISET_SWEET16) + .byte 0,"CPU_ISET_SWEET16" +.endif + +.if (.cpu .bitand CPU_ISET_HUC6280) + .byte 0,"CPU_ISET_HUC6280" +.endif + +.if (.cpu .bitand CPU_ISET_4510) + .byte 0,"CPU_ISET_4510" +.endif + From ef7e9db1165b6c46ddc3eb9c4f7caf0b4c0ead28 Mon Sep 17 00:00:00 2001 From: Alex Thissen <alexthissen@hotmail.com> Date: Sun, 11 Sep 2016 22:26:52 +0200 Subject: [PATCH 157/407] Changed __BLOCKSIZE__ to __BANK0BLOCKSIZE__. Added __BANK1BLOCKSIZE__ which defaults to 0. --- cfg/lynx-bll.cfg | 3 ++- cfg/lynx-coll.cfg | 3 ++- cfg/lynx-uploader.cfg | 3 ++- cfg/lynx.cfg | 5 +++-- libsrc/lynx/bootldr.s | 4 ++-- libsrc/lynx/defdir.s | 8 ++++---- libsrc/lynx/exehdr.s | 7 ++++--- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/cfg/lynx-bll.cfg b/cfg/lynx-bll.cfg index a1687b423..fbf64e8e9 100644 --- a/cfg/lynx-bll.cfg +++ b/cfg/lynx-bll.cfg @@ -1,7 +1,8 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader - __BLOCKSIZE__: type = weak, value = $0400; # cart block size + __BANK0BLOCKSIZE__: type = weak, value = 1024; # bank 0 cart block size + __BANK1BLOCKSIZE__: type = weak, value = 0; # bank 1 block size __BLLHDR__: type = import; } MEMORY { diff --git a/cfg/lynx-coll.cfg b/cfg/lynx-coll.cfg index 9467c3c92..2be172196 100644 --- a/cfg/lynx-coll.cfg +++ b/cfg/lynx-coll.cfg @@ -1,7 +1,8 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader - __BLOCKSIZE__: type = weak, value = $0400; # cart block size + __BANK0BLOCKSIZE__: type = weak, value = 1024; # bank 0 cart block size + __BANK1BLOCKSIZE__: type = weak, value = 0; # bank 1 block size __EXEHDR__: type = import; __BOOTLDR__: type = import; __DEFDIR__: type = import; diff --git a/cfg/lynx-uploader.cfg b/cfg/lynx-uploader.cfg index c32e3583f..ba3c13dcf 100644 --- a/cfg/lynx-uploader.cfg +++ b/cfg/lynx-uploader.cfg @@ -1,7 +1,8 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader - __BLOCKSIZE__: type = weak, value = $0400; # cart block size + __BANK0BLOCKSIZE__: type = weak, value = 1024; # bank 0 cart block size + __BANK1BLOCKSIZE__: type = weak, value = 0; # bank 1 block size __EXEHDR__: type = import; __BOOTLDR__: type = import; __DEFDIR__: type = import; diff --git a/cfg/lynx.cfg b/cfg/lynx.cfg index 5140b342f..adcf67a98 100644 --- a/cfg/lynx.cfg +++ b/cfg/lynx.cfg @@ -1,7 +1,8 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader - __BLOCKSIZE__: type = weak, value = 1024; # cart block size + __BANK0BLOCKSIZE__: type = weak, value = 512; # bank 0 cart block size + __BANK1BLOCKSIZE__: type = weak, value = 0; # bank 1 block size __EXEHDR__: type = import; __BOOTLDR__: type = import; __DEFDIR__: type = import; @@ -42,4 +43,4 @@ FEATURES { count = __INTERRUPTOR_COUNT__, segment = RODATA, import = __CALLIRQ__; -} +} \ No newline at end of file diff --git a/libsrc/lynx/bootldr.s b/libsrc/lynx/bootldr.s index a62d6155c..64569e6ee 100644 --- a/libsrc/lynx/bootldr.s +++ b/libsrc/lynx/bootldr.s @@ -5,7 +5,7 @@ ; .include "lynx.inc" .include "extzp.inc" - .import __BLOCKSIZE__ + .import __BANK0BLOCKSIZE__ .export __BOOTLDR__: absolute = 1 @@ -167,7 +167,7 @@ seclynxblock: lda __iodat sta IODAT stz _FileBlockByte - lda #<($100-(>__BLOCKSIZE__)) + lda #<($100-(>__BANK0BLOCKSIZE__)) sta _FileBlockByte+1 ply plx diff --git a/libsrc/lynx/defdir.s b/libsrc/lynx/defdir.s index 2930edf4b..c0fe19f4d 100644 --- a/libsrc/lynx/defdir.s +++ b/libsrc/lynx/defdir.s @@ -8,7 +8,7 @@ .import __MAIN_START__ .import __CODE_SIZE__, __DATA_SIZE__, __RODATA_SIZE__ .import __STARTUP_SIZE__, __ONCE_SIZE__, __LOWCODE_SIZE__ - .import __BLOCKSIZE__ + .import __BANK0BLOCKSIZE__ .export __DEFDIR__: absolute = 1 @@ -18,12 +18,12 @@ __DIRECTORY_START__: off0 = __STARTOFDIRECTORY__ + (__DIRECTORY_END__ - __DIRECTORY_START__) -blocka = off0 / __BLOCKSIZE__ +blocka = off0 / __BANK0BLOCKSIZE__ ; Entry 0 - first executable -block0 = off0 / __BLOCKSIZE__ +block0 = off0 / __BANK0BLOCKSIZE__ len0 = __STARTUP_SIZE__ + __ONCE_SIZE__ + __CODE_SIZE__ + __DATA_SIZE__ + __RODATA_SIZE__ + __LOWCODE_SIZE__ .byte <block0 - .word off0 & (__BLOCKSIZE__ - 1) + .word off0 & (__BANK0BLOCKSIZE__ - 1) .byte $88 .word __MAIN_START__ .word len0 diff --git a/libsrc/lynx/exehdr.s b/libsrc/lynx/exehdr.s index 3be926bb3..d63c0524d 100644 --- a/libsrc/lynx/exehdr.s +++ b/libsrc/lynx/exehdr.s @@ -3,7 +3,8 @@ ; ; This header contains data for emulators like Handy and Mednafen ; - .import __BLOCKSIZE__ + .import __BANK0BLOCKSIZE__ + .import __BANK1BLOCKSIZE__ .export __EXEHDR__: absolute = 1 @@ -11,8 +12,8 @@ ; EXE header .segment "EXEHDR" .byte 'L','Y','N','X' ; magic - .word __BLOCKSIZE__ ; bank 0 page size - .word 0 ; bank 1 page size + .word __BANK0BLOCKSIZE__ ; bank 0 page size + .word __BANK1BLOCKSIZE__ ; bank 1 page size .word 1 ; version number .asciiz "Cart name " ; 32 bytes cart name .asciiz "Manufacturer " ; 16 bytes manufacturer From 0949b2e104395954ecc93efd39ffede205491669 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Mon, 12 Sep 2016 18:38:10 +0200 Subject: [PATCH 158/407] added missing ',' in documentation. --- doc/ca65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index baabffa7c..3e1b11df3 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -3827,7 +3827,7 @@ Here's a list of all control commands and a description, what they do: <tt><ref id=".IFPSC02" name=".IFPSC02"></tt>, <tt><ref id=".P02" name=".P02"></tt>, <tt><ref id=".P816" name=".P816"></tt>, - <tt><ref id=".P4510" name=".P4510"></tt> + <tt><ref id=".P4510" name=".P4510"></tt>, <tt><ref id=".PC02" name=".PC02"></tt>, <tt><ref id=".PSC02" name=".PSC02"></tt> From 6198e10f6779f08c97faf5ebef6c8bb8d0bd8b90 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 12 Sep 2016 23:34:10 +0200 Subject: [PATCH 159/407] Atari: fix lookup of default device on XDOS. Stefan Dorndorf, author of XDOS, pointed out that retrieving the default device by looking at an undocumented memory location won't work in future XDOS versions. He also showed a way to get the default device in a compatible manner. This change implements his method and adds a version check (XDOS versions below 2.4 don't support this -- for them the behaviour will be the same as, for example, AtariDOS: no notion of a default drive). --- asminc/atari.inc | 9 ++++++++- libsrc/atari/getdefdev.s | 24 ++++++++++++++++++++---- libsrc/atari/shadow_ram_handlers.s | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/asminc/atari.inc b/asminc/atari.inc index 453c370f4..1b995e380 100644 --- a/asminc/atari.inc +++ b/asminc/atari.inc @@ -1024,9 +1024,16 @@ XFILE = $087D ; XDOS filename buffer XLINE = $0880 ; XDOS DUP input line XGLIN = $0871 ; get line XSKIP = $0874 ; skip parameter +.ifdef __ATARIXL__ +.ifndef SHRAM_HANDLERS +.import XMOVE_handler +.endif +.define XMOVE XMOVE_handler +XMOVE_org = $0877 ; move filename +.else XMOVE = $0877 ; move filename +.endif XGNUM = $087A ; get number -XDEFDEV = $0816 ; current drive * undocumented * ;------------------------------------------------------------------------- ; End of atari.inc diff --git a/libsrc/atari/getdefdev.s b/libsrc/atari/getdefdev.s index a1c950dc5..480639b4a 100644 --- a/libsrc/atari/getdefdev.s +++ b/libsrc/atari/getdefdev.s @@ -77,16 +77,33 @@ finish: lda #<__defdev ldx #>__defdev rts -; XDOS version +; XDOS default device retrieval -xdos: lda XDEFDEV +xdos: + +; check XDOS version (we need >= 2.4) + + lda XGLIN + cmp #$4C ; there needs to be a 'JMP' opcode here + bne finish ; older version, use DEFAULT_DEVICE or D1: + lda XVER ; get BCD encoded version ($24 for 2.4) + cmp #$24 + bcc finish ; too old, below 2.4 + +; good XDOS version, get default drive + + lda #ATEOL + sta XLINE ; simulate empty command line + ldy #0 + jsr XMOVE ; create an FMS filename (which in this case only contains the drive) + lda XFILE+1 bne done .data crvec: jmp $FFFF ; target address will be set to crunch vector -; Default device +; Default device string __defdev: .ifdef DEFAULT_DEVICE @@ -94,4 +111,3 @@ __defdev: .else .byte "D1:", 0 .endif - diff --git a/libsrc/atari/shadow_ram_handlers.s b/libsrc/atari/shadow_ram_handlers.s index d65e6bd68..a8ba611b6 100644 --- a/libsrc/atari/shadow_ram_handlers.s +++ b/libsrc/atari/shadow_ram_handlers.s @@ -22,6 +22,7 @@ SHRAM_HANDLERS = 1 .export CIO_handler .export SIO_handler .export SETVBV_handler + .export XMOVE_handler BUFSZ = 128 ; bounce buffer size BUFSZ_SIO = 256 @@ -1085,6 +1086,24 @@ SETVBV_handler: plp rts +;--------------------------------------------------------- + +XMOVE_handler: + + pha + lda PORTB + sta cur_XMOVE_PORTB + enable_rom + pla + jsr XMOVE_org + php + pha + disable_rom_val cur_XMOVE_PORTB + pla + plp + rts + + CIO_a: .res 1 CIO_x: .res 1 CIO_y: .res 1 @@ -1093,6 +1112,7 @@ cur_CIOV_PORTB: .res 1 cur_SIOV_PORTB: .res 1 cur_KEYBDV_PORTB: .res 1 cur_SETVBV_PORTB: .res 1 +cur_XMOVE_PORTB: .res 1 orig_ptr: .res 2 orig_len: .res 2 req_len: .res 2 From aaa26c7d57c3f94ef02f6fa0fd2a596b40a111c2 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Tue, 13 Sep 2016 11:21:25 +0200 Subject: [PATCH 160/407] Revert "test/assembler: removed WORKDIR variable, as remote assembling does only work partly" This reverts commit 7a9a7c3188bf36b278922439f957af7dab4617c2. --- test/assembler/Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/assembler/Makefile b/test/assembler/Makefile index a085bc390..faefddf7a 100644 --- a/test/assembler/Makefile +++ b/test/assembler/Makefile @@ -2,6 +2,8 @@ # makefile for the assembler regression tests BINDIR = ../../bin +#WORKDIR := ../../testwrk +WORKDIR := . BASE_TARGETS = 6502 6502x 65sc02 65c02 BASE_TARGETS += 4510 huc6280 @@ -17,9 +19,9 @@ all: # generate opcode targets and expand target list define opcode OPCODE_TARGETLIST += $(1)-opcodes.bin -$(1)-opcodes.bin: $(1)-opcodes.s - @$$(BINDIR)/cl65 --cpu $(1) -t none -l $(1)-opcodes.lst -o $$@ $$< - @diff -q $(1)-opcodes.ref $$@ || (cat $(1)-opcodes.lst ; exit 1) +$$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s + @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$< + @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1) @echo ca65 --cpu $(1) opcodes ok endef $(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target)))) @@ -27,9 +29,9 @@ $(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target)))) # generate cpudetect targets and expand target list define cpudetect CPUDETECT_TARGETLIST += $(1)-cpudetect.bin -$(1)-cpudetect.bin: cpudetect.s - @$$(BINDIR)/cl65 --cpu $(1) -t none -l $(1)-cpudetect.lst -o $$@ $$< - @diff -q $(1)-cpudetect.ref $$@ || (cat $(1)-cpudetect.lst ; exit 1) +$$(WORKDIR)/$(1)-cpudetect.bin: cpudetect.s + @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-cpudetect.lst --obj-path $$(WORKDIR) -o $$@ $$< + @diff -q $(1)-cpudetect.ref $$@ || (cat $$(WORKDIR)/$(1)-cpudetect.lst ; exit 1) @echo ca65 --cpu $(1) cpudetect ok endef $(foreach target,$(CPUDETECT_TARGETS),$(eval $(call cpudetect,$(target)))) From 95a2f4b9ddaec624dcc9c9e1b533992cdd2fd51f Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Tue, 13 Sep 2016 11:28:11 +0200 Subject: [PATCH 161/407] re-adding WORKDIR to Makefile - added workaround to remove *.o files after assembling - also removed now obsolete clean target --- test/assembler/Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/assembler/Makefile b/test/assembler/Makefile index faefddf7a..5d38847f5 100644 --- a/test/assembler/Makefile +++ b/test/assembler/Makefile @@ -2,8 +2,7 @@ # makefile for the assembler regression tests BINDIR = ../../bin -#WORKDIR := ../../testwrk -WORKDIR := . +WORKDIR := ../../testwrk BASE_TARGETS = 6502 6502x 65sc02 65c02 BASE_TARGETS += 4510 huc6280 @@ -18,21 +17,23 @@ all: # generate opcode targets and expand target list define opcode -OPCODE_TARGETLIST += $(1)-opcodes.bin +OPCODE_TARGETLIST += $$(WORKDIR)/$(1)-opcodes.bin $$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$< @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1) @echo ca65 --cpu $(1) opcodes ok + @rm -f $(1)-opcodes.o #workaround for #168 endef $(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target)))) # generate cpudetect targets and expand target list define cpudetect -CPUDETECT_TARGETLIST += $(1)-cpudetect.bin +CPUDETECT_TARGETLIST += $$(WORKDIR)/$(1)-cpudetect.bin $$(WORKDIR)/$(1)-cpudetect.bin: cpudetect.s @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-cpudetect.lst --obj-path $$(WORKDIR) -o $$@ $$< @diff -q $(1)-cpudetect.ref $$@ || (cat $$(WORKDIR)/$(1)-cpudetect.lst ; exit 1) @echo ca65 --cpu $(1) cpudetect ok + @rm -f cpudetect.o #workaround for #168 endef $(foreach target,$(CPUDETECT_TARGETS),$(eval $(call cpudetect,$(target)))) @@ -40,8 +41,5 @@ $(foreach target,$(CPUDETECT_TARGETS),$(eval $(call cpudetect,$(target)))) all: $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST) @# -clean: - rm -f *.o *.bin *.lst - -.PHONY: all clean $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST) +.PHONY: all $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST) From bcdd1900209c811b495403055280b54f4fbc3227 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Tue, 13 Sep 2016 11:54:56 +0200 Subject: [PATCH 162/407] removed 'make clean' invoked from test/Makefile for test/assembler/Makefile, as all artifacts are now created in testwrk and will be cleaned up out of directory --- test/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 2fd252d2a..7f95e4379 100644 --- a/test/Makefile +++ b/test/Makefile @@ -47,7 +47,6 @@ continue: $(WORKDIR)/bdiff$(EXE) @$(MAKE) -C misc all mostlyclean: - @$(MAKE) -C assembler clean @$(MAKE) -C val clean @$(MAKE) -C ref clean @$(MAKE) -C err clean From 601c6102e8a073be3572e41fc5ca06db4151ede6 Mon Sep 17 00:00:00 2001 From: Alex Thissen <alexthissen@hotmail.com> Date: Tue, 13 Sep 2016 22:02:37 +0200 Subject: [PATCH 163/407] Fixed last linefeed and notation convention errors. --- cfg/lynx-bll.cfg | 4 ++-- cfg/lynx-coll.cfg | 4 ++-- cfg/lynx-uploader.cfg | 4 ++-- cfg/lynx.cfg | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cfg/lynx-bll.cfg b/cfg/lynx-bll.cfg index fbf64e8e9..adf1e7ab6 100644 --- a/cfg/lynx-bll.cfg +++ b/cfg/lynx-bll.cfg @@ -1,8 +1,8 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader - __BANK0BLOCKSIZE__: type = weak, value = 1024; # bank 0 cart block size - __BANK1BLOCKSIZE__: type = weak, value = 0; # bank 1 block size + __BANK0BLOCKSIZE__: type = weak, value = $0400; # bank 0 cart block size + __BANK1BLOCKSIZE__: type = weak, value = $0000; # bank 1 block size __BLLHDR__: type = import; } MEMORY { diff --git a/cfg/lynx-coll.cfg b/cfg/lynx-coll.cfg index 2be172196..7c71993f8 100644 --- a/cfg/lynx-coll.cfg +++ b/cfg/lynx-coll.cfg @@ -1,8 +1,8 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader - __BANK0BLOCKSIZE__: type = weak, value = 1024; # bank 0 cart block size - __BANK1BLOCKSIZE__: type = weak, value = 0; # bank 1 block size + __BANK0BLOCKSIZE__: type = weak, value = $0400; # bank 0 cart block size + __BANK1BLOCKSIZE__: type = weak, value = $0000; # bank 1 block size __EXEHDR__: type = import; __BOOTLDR__: type = import; __DEFDIR__: type = import; diff --git a/cfg/lynx-uploader.cfg b/cfg/lynx-uploader.cfg index ba3c13dcf..476b3c5de 100644 --- a/cfg/lynx-uploader.cfg +++ b/cfg/lynx-uploader.cfg @@ -1,8 +1,8 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader - __BANK0BLOCKSIZE__: type = weak, value = 1024; # bank 0 cart block size - __BANK1BLOCKSIZE__: type = weak, value = 0; # bank 1 block size + __BANK0BLOCKSIZE__: type = weak, value = $0400; # bank 0 cart block size + __BANK1BLOCKSIZE__: type = weak, value = $0000; # bank 1 block size __EXEHDR__: type = import; __BOOTLDR__: type = import; __DEFDIR__: type = import; diff --git a/cfg/lynx.cfg b/cfg/lynx.cfg index adcf67a98..5c42654d7 100644 --- a/cfg/lynx.cfg +++ b/cfg/lynx.cfg @@ -1,8 +1,8 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader - __BANK0BLOCKSIZE__: type = weak, value = 512; # bank 0 cart block size - __BANK1BLOCKSIZE__: type = weak, value = 0; # bank 1 block size + __BANK0BLOCKSIZE__: type = weak, value = $0400; # bank 0 cart block size + __BANK1BLOCKSIZE__: type = weak, value = $0000; # bank 1 block size __EXEHDR__: type = import; __BOOTLDR__: type = import; __DEFDIR__: type = import; @@ -43,4 +43,4 @@ FEATURES { count = __INTERRUPTOR_COUNT__, segment = RODATA, import = __CALLIRQ__; -} \ No newline at end of file +} From d0ed84c2d0130fa7945cfca5ecb0ddbd77c3053f Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Tue, 20 Sep 2016 17:37:10 +0200 Subject: [PATCH 164/407] da65: adding support for 4510 cpu of c65 --- doc/da65.sgml | 9 +- src/da65/handler.c | 55 +++++- src/da65/handler.h | 4 + src/da65/opc4510.c | 306 ++++++++++++++++++++++++++++++++ src/da65/opc4510.h | 58 ++++++ src/da65/opctable.c | 2 + test/Makefile | 1 + test/disassembler/4510-disass.s | 298 +++++++++++++++++++++++++++++++ test/disassembler/Makefile | 41 +++++ 9 files changed, 772 insertions(+), 2 deletions(-) create mode 100644 src/da65/opc4510.c create mode 100644 src/da65/opc4510.h create mode 100644 test/disassembler/4510-disass.s create mode 100644 test/disassembler/Makefile diff --git a/doc/da65.sgml b/doc/da65.sgml index df8cd7772..6d962e9d6 100644 --- a/doc/da65.sgml +++ b/doc/da65.sgml @@ -114,10 +114,12 @@ Here is a description of all the command line options: <item>65sc02 <item>65c02 <item>huc6280 + <item>4510 </itemize> 6502x is for the NMOS 6502 with unofficial opcodes. huc6280 is the CPU of - the PC engine. Support for the 65816 currently is not available. + the PC engine. 4510 is the CPU of the Commodore C65. Support for the 65816 + currently is not available. <label id="option--formfeeds"> @@ -239,6 +241,11 @@ disassembler may be told to recognize either the 65SC02 or 65C02 CPUs. The latter understands the same opcodes as the former, plus 16 additional bit manipulation and bit test-and-branch commands. +When disassembling 4510 code, due to handling of 16-bit wide branches, da65 +can produce output that can not be re-assembled, when one or more of those +branches point outside of the disassmbled memory. This can happen when text +or binary data is processed. + While there is some code for the 65816 in the sources, it is currently unsupported. diff --git a/src/da65/handler.c b/src/da65/handler.c index c034aed14..6ba8a7eef 100644 --- a/src/da65/handler.c +++ b/src/da65/handler.c @@ -227,6 +227,13 @@ void OH_Immediate (const OpcDesc* D) +void OH_ImmediateWord (const OpcDesc* D) +{ + OneLine (D, "#$%04X", GetCodeWord (PC+1)); +} + + + void OH_Direct (const OpcDesc* D) { /* Get the operand */ @@ -349,6 +356,23 @@ void OH_RelativeLong (const OpcDesc* D attribute ((unused))) +void OH_RelativeLong4510 (const OpcDesc* D attribute ((unused))) +{ + /* Get the operand */ + signed short Offs = GetCodeWord (PC+1); + + /* Calculate the target address */ + unsigned Addr = (((int) PC+2) + Offs) & 0xFFFF; + + /* Generate a label in pass 1 */ + GenerateLabel (D->Flags, Addr); + + /* Output the line */ + OneLine (D, "%s", GetAddrArg (D->Flags, Addr)); +} + + + void OH_DirectIndirect (const OpcDesc* D) { /* Get the operand */ @@ -377,6 +401,20 @@ void OH_DirectIndirectY (const OpcDesc* D) +void OH_DirectIndirectZ (const OpcDesc* D) +{ + /* Get the operand */ + unsigned Addr = GetCodeByte (PC+1); + + /* Generate a label in pass 1 */ + GenerateLabel (D->Flags, Addr); + + /* Output the line */ + OneLine (D, "(%s),z", GetAddrArg (D->Flags, Addr)); +} + + + void OH_DirectXIndirect (const OpcDesc* D) { /* Get the operand */ @@ -508,9 +546,24 @@ void OH_DirectIndirectLongX (const OpcDesc* D attribute ((unused))) +static void impl_StackRelativeIndirectY (const char *sp, const OpcDesc* D attribute ((unused))) +{ + /* Output the line */ + OneLine (D, "($%02X,%s),y", GetCodeByte (PC+1), sp); +} + + + void OH_StackRelativeIndirectY (const OpcDesc* D attribute ((unused))) { - Error ("Not implemented"); + impl_StackRelativeIndirectY( "s", D ); +} + + + +void OH_StackRelativeIndirectY4510 (const OpcDesc* D attribute ((unused))) +{ + impl_StackRelativeIndirectY( "sp", D ); } diff --git a/src/da65/handler.h b/src/da65/handler.h index 433ba2594..c0fa68e56 100644 --- a/src/da65/handler.h +++ b/src/da65/handler.h @@ -57,6 +57,7 @@ void OH_Illegal (const OpcDesc* D attribute ((unused))); void OH_Accumulator (const OpcDesc*); void OH_Implicit (const OpcDesc*); void OH_Immediate (const OpcDesc*); +void OH_ImmediateWord (const OpcDesc*); void OH_Direct (const OpcDesc*); void OH_DirectX (const OpcDesc*); void OH_DirectY (const OpcDesc*); @@ -67,8 +68,10 @@ void OH_AbsoluteLong (const OpcDesc*); void OH_AbsoluteLongX (const OpcDesc*); void OH_Relative (const OpcDesc*); void OH_RelativeLong (const OpcDesc*); +void OH_RelativeLong4510 (const OpcDesc*); void OH_DirectIndirect (const OpcDesc*); void OH_DirectIndirectY (const OpcDesc*); +void OH_DirectIndirectZ (const OpcDesc*); void OH_DirectXIndirect (const OpcDesc*); void OH_AbsoluteIndirect (const OpcDesc*); @@ -82,6 +85,7 @@ void OH_ImmediateAbsoluteX (const OpcDesc*); void OH_StackRelative (const OpcDesc*); void OH_DirectIndirectLongX (const OpcDesc*); void OH_StackRelativeIndirectY (const OpcDesc*); +void OH_StackRelativeIndirectY4510 (const OpcDesc*); void OH_DirectIndirectLong (const OpcDesc*); void OH_DirectIndirectLongY (const OpcDesc*); void OH_BlockMove (const OpcDesc*); diff --git a/src/da65/opc4510.c b/src/da65/opc4510.c new file mode 100644 index 000000000..c663b7a59 --- /dev/null +++ b/src/da65/opc4510.c @@ -0,0 +1,306 @@ +/*****************************************************************************/ +/* */ +/* opc4510.c */ +/* */ +/* 4510 opcode description table */ +/* */ +/* */ +/* */ +/* (C) 2003-2011, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +/* da65 */ +#include "handler.h" +#include "opc4510.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +/* Descriptions for all opcodes */ +const OpcDesc OpcTable_4510[256] = { + { "brk", 1, flNone, OH_Implicit }, /* $00 */ + { "ora", 2, flUseLabel, OH_DirectXIndirect }, /* $01 */ + { "cle", 1, flNone, OH_Implicit }, /* $02 */ + { "see", 1, flNone, OH_Implicit }, /* $03 */ + { "tsb", 2, flUseLabel, OH_Direct }, /* $04 */ + { "ora", 2, flUseLabel, OH_Direct }, /* $05 */ + { "asl", 2, flUseLabel, OH_Direct }, /* $06 */ + { "rmb0", 2, flUseLabel, OH_Direct }, /* $07 */ + { "php", 1, flNone, OH_Implicit }, /* $08 */ + { "ora", 2, flNone, OH_Immediate }, /* $09 */ + { "asl", 1, flNone, OH_Accumulator }, /* $0a */ + { "tsy", 1, flNone, OH_Implicit }, /* $0b */ + { "tsb", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0c */ + { "ora", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0d */ + { "asl", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0e */ + { "bbr0", 3, flUseLabel, OH_BitBranch }, /* $0f */ + { "bpl", 2, flLabel, OH_Relative }, /* $10 */ + { "ora", 2, flUseLabel, OH_DirectIndirectY }, /* $11 */ + { "ora", 2, flUseLabel, OH_DirectIndirectZ }, /* $12 */ + { "lbpl", 3, flLabel, OH_RelativeLong4510 }, /* $13 */ + { "trb", 2, flUseLabel, OH_Direct }, /* $14 */ + { "ora", 2, flUseLabel, OH_DirectX }, /* $15 */ + { "asl", 2, flUseLabel, OH_DirectX }, /* $16 */ + { "rmb1", 2, flUseLabel, OH_Direct }, /* $17 */ + { "clc", 1, flNone, OH_Implicit }, /* $18 */ + { "ora", 3, flUseLabel, OH_AbsoluteY }, /* $19 */ + { "inc", 1, flNone, OH_Accumulator }, /* $1a */ + { "inz", 1, flNone, OH_Implicit }, /* $1b */ + { "trb", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $1c */ + { "ora", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $1d */ + { "asl", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $1e */ + { "bbr1", 3, flUseLabel, OH_BitBranch }, /* $1f */ + { "jsr", 3, flLabel, OH_Absolute }, /* $20 */ + { "and", 2, flUseLabel, OH_DirectXIndirect }, /* $21 */ + { "jsr", 3, flLabel, OH_JmpAbsoluteIndirect }, /* $22 */ + { "jsr", 3, flLabel, OH_JmpAbsoluteXIndirect }, /* $23 */ + { "bit", 2, flUseLabel, OH_Direct }, /* $24 */ + { "and", 2, flUseLabel, OH_Direct }, /* $25 */ + { "rol", 2, flUseLabel, OH_Direct }, /* $26 */ + { "rmb2", 2, flUseLabel, OH_Direct }, /* $27 */ + { "plp", 1, flNone, OH_Implicit }, /* $28 */ + { "and", 2, flNone, OH_Immediate }, /* $29 */ + { "rol", 1, flNone, OH_Accumulator }, /* $2a */ + { "tys", 1, flNone, OH_Implicit }, /* $2b */ + { "bit", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2c */ + { "and", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2d */ + { "rol", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2e */ + { "bbr2", 3, flUseLabel, OH_BitBranch }, /* $2f */ + { "bmi", 2, flLabel, OH_Relative }, /* $30 */ + { "and", 2, flUseLabel, OH_DirectIndirectY }, /* $31 */ + { "and", 2, flUseLabel, OH_DirectIndirectZ }, /* $32 */ + { "lbmi", 3, flLabel, OH_RelativeLong4510 }, /* $33 */ + { "bit", 2, flUseLabel, OH_DirectX }, /* $34 */ + { "and", 2, flUseLabel, OH_DirectX }, /* $35 */ + { "rol", 2, flUseLabel, OH_DirectX }, /* $36 */ + { "rmb3", 2, flUseLabel, OH_Direct }, /* $37 */ + { "sec", 1, flNone, OH_Implicit }, /* $38 */ + { "and", 3, flUseLabel, OH_AbsoluteY }, /* $39 */ + { "dec", 1, flNone, OH_Accumulator }, /* $3a */ + { "dez", 1, flNone, OH_Implicit }, /* $3b */ + { "bit", 3, flUseLabel, OH_AbsoluteX }, /* $3c */ + { "and", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $3d */ + { "rol", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $3e */ + { "bbr3", 3, flUseLabel, OH_BitBranch }, /* $3f */ + { "rti", 1, flNone, OH_Rts }, /* $40 */ + { "eor", 2, flUseLabel, OH_DirectXIndirect }, /* $41 */ + { "neg", 1, flNone, OH_Implicit }, /* $42 */ + { "asr", 1, flNone, OH_Accumulator }, /* $43 */ + { "asr", 2, flUseLabel, OH_Direct }, /* $44 */ + { "eor", 2, flUseLabel, OH_Direct }, /* $45 */ + { "lsr", 2, flUseLabel, OH_Direct }, /* $46 */ + { "rmb4", 2, flUseLabel, OH_Direct }, /* $47 */ + { "pha", 1, flNone, OH_Implicit }, /* $48 */ + { "eor", 2, flNone, OH_Immediate }, /* $49 */ + { "lsr", 1, flNone, OH_Accumulator }, /* $4a */ + { "taz", 1, flNone, OH_Implicit }, /* $4b */ + { "jmp", 3, flLabel, OH_JmpAbsolute }, /* $4c */ + { "eor", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $4d */ + { "lsr", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $4e */ + { "bbr4", 3, flUseLabel, OH_BitBranch }, /* $4f */ + { "bvc", 2, flLabel, OH_Relative }, /* $50 */ + { "eor", 2, flUseLabel, OH_DirectIndirectY }, /* $51 */ + { "eor", 2, flUseLabel, OH_DirectIndirectZ }, /* $52 */ + { "lbvc", 3, flLabel, OH_RelativeLong4510 }, /* $53 */ + { "asr", 2, flUseLabel, OH_DirectX }, /* $54 */ + { "eor", 2, flUseLabel, OH_DirectX }, /* $55 */ + { "lsr", 2, flUseLabel, OH_DirectX }, /* $56 */ + { "rmb5", 2, flUseLabel, OH_Direct }, /* $57 */ + { "cli", 1, flNone, OH_Implicit }, /* $58 */ + { "eor", 3, flUseLabel, OH_AbsoluteY }, /* $59 */ + { "phy", 1, flNone, OH_Implicit }, /* $5a */ + { "tab", 1, flNone, OH_Implicit }, /* $5b */ + { "map", 1, flNone, OH_Implicit }, /* $5c */ + { "eor", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $5d */ + { "lsr", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $5e */ + { "bbr5", 3, flUseLabel, OH_BitBranch }, /* $5f */ + { "rts", 1, flNone, OH_Rts }, /* $60 */ + { "adc", 2, flUseLabel, OH_DirectXIndirect }, /* $61 */ + { "rtn", 2, flNone, OH_Immediate }, /* $62 */ + { "bsr", 3, flLabel, OH_RelativeLong4510 }, /* $63 */ + { "stz", 2, flUseLabel, OH_Direct }, /* $64 */ + { "adc", 2, flUseLabel, OH_Direct }, /* $65 */ + { "ror", 2, flUseLabel, OH_Direct }, /* $66 */ + { "rmb6", 2, flUseLabel, OH_Direct, }, /* $67 */ + { "pla", 1, flNone, OH_Implicit }, /* $68 */ + { "adc", 2, flNone, OH_Immediate }, /* $69 */ + { "ror", 1, flNone, OH_Accumulator }, /* $6a */ + { "tza", 1, flNone, OH_Implicit }, /* $6b */ + { "jmp", 3, flLabel, OH_JmpAbsoluteIndirect }, /* $6c */ + { "adc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $6d */ + { "ror", 3, flUseLabel, OH_Absolute }, /* $6e */ + { "bbr6", 3, flUseLabel, OH_BitBranch }, /* $6f */ + { "bvs", 2, flLabel, OH_Relative }, /* $70 */ + { "adc", 2, flUseLabel, OH_DirectIndirectY }, /* $71 */ + { "adc", 2, flUseLabel, OH_DirectIndirectZ }, /* $72 */ + { "lbvs", 3, flLabel, OH_RelativeLong4510 }, /* $73 */ + { "stz", 2, flUseLabel, OH_DirectX }, /* $74 */ + { "adc", 2, flUseLabel, OH_DirectX }, /* $75 */ + { "ror", 2, flUseLabel, OH_DirectX }, /* $76 */ + { "rmb7", 2, flUseLabel, OH_Direct }, /* $77 */ + { "sei", 1, flNone, OH_Implicit }, /* $78 */ + { "adc", 3, flUseLabel, OH_AbsoluteY }, /* $79 */ + { "ply", 1, flNone, OH_Implicit }, /* $7a */ + { "tba", 1, flNone, OH_Implicit }, /* $7b */ + { "jmp", 3, flLabel, OH_AbsoluteXIndirect }, /* $7c */ + { "adc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7d */ + { "ror", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7e */ + { "bbr7", 3, flUseLabel, OH_BitBranch }, /* $7f */ + { "bra", 2, flLabel, OH_Relative }, /* $80 */ + { "sta", 2, flUseLabel, OH_DirectXIndirect }, /* $81 */ + { "sta", 2, flNone, OH_StackRelativeIndirectY4510}, /* $82 */ + { "lbra", 3, flLabel, OH_RelativeLong4510 }, /* $83 */ + { "sty", 2, flUseLabel, OH_Direct }, /* $84 */ + { "sta", 2, flUseLabel, OH_Direct }, /* $85 */ + { "stx", 2, flUseLabel, OH_Direct }, /* $86 */ + { "smb0", 2, flUseLabel, OH_Direct }, /* $87 */ + { "dey", 1, flNone, OH_Implicit }, /* $88 */ + { "bit", 2, flNone, OH_Immediate }, /* $89 */ + { "txa", 1, flNone, OH_Implicit }, /* $8a */ + { "sty", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $8b */ + { "sty", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8c */ + { "sta", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8d */ + { "stx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8e */ + { "bbs0", 3, flUseLabel, OH_BitBranch }, /* $8f */ + { "bcc", 2, flLabel, OH_Relative }, /* $90 */ + { "sta", 2, flUseLabel, OH_DirectIndirectY }, /* $91 */ + { "sta", 2, flUseLabel, OH_DirectIndirectZ }, /* $92 */ + { "lbcc", 3, flLabel, OH_RelativeLong4510 }, /* $93 */ + { "sty", 2, flUseLabel, OH_DirectX }, /* $94 */ + { "sta", 2, flUseLabel, OH_DirectX }, /* $95 */ + { "stx", 2, flUseLabel, OH_DirectY }, /* $96 */ + { "smb1", 2, flUseLabel, OH_Direct }, /* $97 */ + { "tya", 1, flNone, OH_Implicit }, /* $98 */ + { "sta", 3, flUseLabel, OH_AbsoluteY }, /* $99 */ + { "txs", 1, flNone, OH_Implicit }, /* $9a */ + { "stx", 3, flUseLabel|flAbsOverride, OH_AbsoluteY }, /* $9b */ + { "stz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $9c */ + { "sta", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $9d */ + { "stz", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $9e */ + { "bbs1", 3, flUseLabel, OH_BitBranch }, /* $9f */ + { "ldy", 2, flNone, OH_Immediate }, /* $a0 */ + { "lda", 2, flUseLabel, OH_DirectXIndirect }, /* $a1 */ + { "ldx", 2, flNone, OH_Immediate }, /* $a2 */ + { "ldz", 2, flNone, OH_Immediate }, /* $a3 */ + { "ldy", 2, flUseLabel, OH_Direct }, /* $a4 */ + { "lda", 2, flUseLabel, OH_Direct }, /* $a5 */ + { "ldx", 2, flUseLabel, OH_Direct }, /* $a6 */ + { "smb2", 2, flUseLabel, OH_Direct }, /* $a7 */ + { "tay", 1, flNone, OH_Implicit }, /* $a8 */ + { "lda", 2, flNone, OH_Immediate }, /* $a9 */ + { "tax", 1, flNone, OH_Implicit }, /* $aa */ + { "ldz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ab */ + { "ldy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ac */ + { "lda", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ad */ + { "ldx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ae */ + { "bbs2", 3, flUseLabel, OH_BitBranch }, /* $af */ + { "bcs", 2, flLabel, OH_Relative }, /* $b0 */ + { "lda", 2, flUseLabel, OH_DirectIndirectY }, /* $b1 */ + { "lda", 2, flUseLabel, OH_DirectIndirectZ }, /* $b2 */ + { "lbcs", 3, flLabel, OH_RelativeLong4510 }, /* $b3 */ + { "ldy", 2, flUseLabel, OH_DirectX }, /* $b4 */ + { "lda", 2, flUseLabel, OH_DirectX }, /* $b5 */ + { "ldx", 2, flUseLabel, OH_DirectY }, /* $b6 */ + { "smb3", 2, flUseLabel, OH_Direct }, /* $b7 */ + { "clv", 1, flNone, OH_Implicit }, /* $b8 */ + { "lda", 3, flUseLabel, OH_AbsoluteY }, /* $b9 */ + { "tsx", 1, flNone, OH_Implicit }, /* $ba */ + { "ldz", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bb */ + { "ldy", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bc */ + { "lda", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bd */ + { "ldx", 3, flUseLabel|flAbsOverride, OH_AbsoluteY }, /* $be */ + { "bbs3", 3, flUseLabel, OH_BitBranch }, /* $bf */ + { "cpy", 2, flNone, OH_Immediate }, /* $c0 */ + { "cmp", 2, flUseLabel, OH_DirectXIndirect }, /* $c1 */ + { "cpz", 2, flNone, OH_Immediate }, /* $c2 */ + { "dew", 2, flUseLabel, OH_Direct }, /* $c3 */ + { "cpy", 2, flUseLabel, OH_Direct }, /* $c4 */ + { "cmp", 2, flUseLabel, OH_Direct }, /* $c5 */ + { "dec", 2, flUseLabel, OH_Direct }, /* $c6 */ + { "smb4", 2, flUseLabel, OH_Direct }, /* $c7 */ + { "iny", 1, flNone, OH_Implicit }, /* $c8 */ + { "cmp", 2, flNone, OH_Immediate }, /* $c9 */ + { "dex", 1, flNone, OH_Implicit }, /* $ca */ + { "asw", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cb */ + { "cpy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cc */ + { "cmp", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cd */ + { "dec", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ce */ + { "bbs4", 3, flUseLabel, OH_BitBranch }, /* $cf */ + { "bne", 2, flLabel, OH_Relative }, /* $d0 */ + { "cmp", 2, flUseLabel, OH_DirectIndirectY }, /* $d1 */ + { "cmp", 2, flUseLabel, OH_DirectIndirectZ }, /* $d2 */ + { "lbne", 3, flLabel, OH_RelativeLong4510 }, /* $d3 */ + { "cpz", 2, flUseLabel, OH_Direct }, /* $d4 */ + { "cmp", 2, flUseLabel, OH_DirectX }, /* $d5 */ + { "dec", 2, flUseLabel, OH_DirectX }, /* $d6 */ + { "smb5", 2, flUseLabel, OH_Direct }, /* $d7 */ + { "cld", 1, flNone, OH_Implicit }, /* $d8 */ + { "cmp", 3, flUseLabel, OH_AbsoluteY }, /* $d9 */ + { "phx", 1, flNone, OH_Implicit }, /* $da */ + { "phz", 1, flNone, OH_Implicit }, /* $db */ + { "cpz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $dc */ + { "cmp", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $dd */ + { "dec", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $de */ + { "bbs5", 3, flUseLabel, OH_BitBranch }, /* $df */ + { "cpx", 2, flNone, OH_Immediate }, /* $e0 */ + { "sbc", 2, flUseLabel, OH_DirectXIndirect }, /* $e1 */ + { "lda", 2, flNone, OH_StackRelativeIndirectY4510}, /* $e2 */ + { "inw", 2, flUseLabel, OH_Direct }, /* $e3 */ + { "cpx", 2, flUseLabel, OH_Direct }, /* $e4 */ + { "sbc", 2, flUseLabel, OH_Direct }, /* $e5 */ + { "inc", 2, flUseLabel, OH_Direct }, /* $e6 */ + { "smb6", 2, flUseLabel, OH_Direct }, /* $e7 */ + { "inx", 1, flNone, OH_Implicit }, /* $e8 */ + { "sbc", 2, flNone, OH_Immediate }, /* $e9 */ + { "eom", 1, flNone, OH_Implicit }, /* $ea */ + { "row", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $eb */ + { "cpx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ec */ + { "sbc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ed */ + { "inc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ee */ + { "bbs6", 3, flUseLabel, OH_BitBranch }, /* $ef */ + { "beq", 2, flLabel, OH_Relative }, /* $f0 */ + { "sbc", 2, flUseLabel, OH_DirectIndirectY }, /* $f1 */ + { "sbc", 2, flUseLabel, OH_DirectIndirectZ }, /* $f2 */ + { "lbeq", 3, flLabel, OH_RelativeLong4510 }, /* $f3 */ + { "phw", 3, flNone, OH_ImmediateWord }, /* $f4 */ + { "sbc", 2, flUseLabel, OH_DirectX }, /* $f5 */ + { "inc", 2, flUseLabel, OH_DirectX }, /* $f6 */ + { "smb7", 2, flUseLabel, OH_Direct }, /* $f7 */ + { "sed", 1, flNone, OH_Implicit }, /* $f8 */ + { "sbc", 3, flUseLabel, OH_AbsoluteY }, /* $f9 */ + { "plx", 1, flNone, OH_Implicit }, /* $fa */ + { "plz", 1, flNone, OH_Implicit }, /* $fb */ + { "phw", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $fc */ + { "sbc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $fd */ + { "inc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $fe */ + { "bbs7", 3, flUseLabel, OH_BitBranch }, /* $ff */ +}; diff --git a/src/da65/opc4510.h b/src/da65/opc4510.h new file mode 100644 index 000000000..10735952c --- /dev/null +++ b/src/da65/opc4510.h @@ -0,0 +1,58 @@ +/*****************************************************************************/ +/* */ +/* opc4510.h */ +/* */ +/* 4510 opcode description table */ +/* */ +/* */ +/* */ +/* (C) 2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef OPC4510_H +#define OPC4510_H + + + +#include "opcdesc.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +/* Descriptions for all opcodes */ +extern const OpcDesc OpcTable_4510[256]; + + + +/* End of opc4510.h */ + +#endif diff --git a/src/da65/opctable.c b/src/da65/opctable.c index c85805faf..031b1239b 100644 --- a/src/da65/opctable.c +++ b/src/da65/opctable.c @@ -35,6 +35,7 @@ /* da65 */ #include "error.h" +#include "opc4510.h" #include "opc6502.h" #include "opc6502x.h" #include "opc65816.h" @@ -73,6 +74,7 @@ void SetOpcTable (cpu_t CPU) case CPU_65C02: OpcTable = OpcTable_65C02; break; case CPU_HUC6280: OpcTable = OpcTable_HuC6280; break; case CPU_M740: OpcTable = OpcTable_M740; break; + case CPU_4510: OpcTable = OpcTable_4510; break; default: Error ("Unsupported CPU"); } } diff --git a/test/Makefile b/test/Makefile index 7f95e4379..f0d63f689 100644 --- a/test/Makefile +++ b/test/Makefile @@ -41,6 +41,7 @@ dotests: mostlyclean continue continue: $(WORKDIR)/bdiff$(EXE) @$(MAKE) -C assembler all + @$(MAKE) -C disassembler all @$(MAKE) -C val all @$(MAKE) -C ref all @$(MAKE) -C err all diff --git a/test/disassembler/4510-disass.s b/test/disassembler/4510-disass.s new file mode 100644 index 000000000..96ed6419d --- /dev/null +++ b/test/disassembler/4510-disass.s @@ -0,0 +1,298 @@ +.setcpu "4510" + +ZP = $12 +ABS = $2345 + +start: + brk + ora (ZP,x) + cle + see + tsb ZP + ora ZP + asl ZP + rmb0 ZP + php + ora #$01 + asl + tsy + tsb ABS + ora ABS + asl ABS + bbr0 ZP,label1 + +label1: + bpl label2 + ora (ZP),y + ora (ZP),z + lbpl start ; bpl start + trb ZP + ora ZP,x + asl ZP,x + rmb1 ZP + clc + ora ABS,y + inc + inz + trb ABS + ora ABS,x + asl ABS,x + bbr1 ZP,label2 + +label2: + jsr ABS + and (ZP,x) + jsr ($2345) + jsr ($2456,x) + bit ZP + and ZP + rol ZP + rmb2 ZP + plp + and #$01 + rol + tys + bit ABS + and ABS + rol ABS + bbr2 ZP,label3 + +label3: + bmi label4 + and (ZP),y + and (ZP),z + lbmi start ; bmi start + bit ZP,x + and ZP,x + rol ZP,x + rmb3 ZP + sec + and ABS,y + dec + dez + bit ABS,x + and ABS,x + rol ABS,x + bbr3 ZP,label4 + +label4: + rti + eor (ZP,x) + neg + asr + asr ZP + eor ZP + lsr ZP + rmb4 ZP + pha + eor #$01 + lsr + taz + jmp ABS + eor ABS + lsr ABS + bbr4 ZP,label5 + +label5: + bvc label6 + eor (ZP),y + eor (ZP),z + lbvc start ; bvc start + asr ZP,x + eor ZP,x + lsr ZP,x + rmb5 ZP + cli + eor ABS,y + phy + tab + map + eor ABS,x + lsr ABS,x + bbr5 ZP,label6 + +label6: + rts + adc (ZP,x) + rtn #$09 + bsr start + stz ZP + adc ZP + ror ZP + rmb6 ZP + pla + adc #$01 + ror + tza + jmp ($2345) + adc ABS + ror ABS + bbr6 ZP,label7 + +label7: + bvs label8 + adc (ZP),y + adc (ZP),z + lbvs start ; bvs start + stz ZP,x + adc ZP,x + ror ZP,x + rmb7 ZP + sei + adc ABS,y + ply + tba + jmp ($2456,x) + adc ABS,x + ror ABS,x + bbr7 ZP,label8 + +label8: + bra label9 + sta (ZP,x) + sta ($0f,sp),y + lbra start ; bra start + sty ZP + sta ZP + stx ZP + smb0 ZP + dey + bit #$01 + txa + sty ABS,x + sty ABS + sta ABS + stx ABS + bbs0 ZP,label9 + +label9: + bcc labelA + sta (ZP),y + sta (ZP),z + lbcc start ; bcc start + sty ZP,x + sta ZP,x + stx ZP,y + smb1 ZP + tya + sta ABS,y + txs + stx ABS,y + stz ABS + sta ABS,x + stz ABS,x + bbs1 ZP,labelA + +labelA: + ldy #$01 + lda (ZP,x) + ldx #$01 + ldz #$01 + ldy ZP + lda ZP + ldx ZP + smb2 ZP + tay + lda #$01 + tax + ldz ABS + ldy ABS + lda ABS + ldx ABS + bbs2 ZP,labelB + +labelB: + bcs labelC + lda (ZP),y + lda (ZP),z + lbcs start ; bcs start + ldy ZP,x + lda ZP,x + ldx ZP,y + smb3 ZP + clv + lda ABS,y + tsx + ldz ABS,x + ldy ABS,x + lda ABS,x + ldx ABS,y + bbs3 ZP,labelC + +labelC: + cpy #$01 + cmp (ZP,x) + cpz #$01 + dew ZP + cpy ZP + cmp ZP + dec ZP + smb4 ZP + iny + cmp #$01 + dex + asw ABS + cpy ABS + cmp ABS + dec ABS + bbs4 ZP,labelD + +labelD: + bne labelE + cmp (ZP),y + cmp (ZP),z + lbne start ; bne start + cpz ZP + cmp ZP,x + dec ZP,x + smb5 ZP + cld + cmp ABS,y + phx + phz + cpz ABS + cmp ABS,x + dec ABS,x + bbs5 ZP,labelE + +labelE: + cpx #$01 + sbc (ZP,x) + lda ($0f,sp),y + inw ZP + cpx ZP + sbc ZP + inc ZP + smb6 ZP + inx + sbc #$01 + eom + nop + row ABS + cpx ABS + sbc ABS + inc ABS + bbs6 ZP,labelF + +labelF: + beq labelG + sbc (ZP),y + sbc (ZP),z + lbeq start ; beq start + phw #$089a + sbc ZP,x + inc ZP,x + smb7 ZP + sed + sbc ABS,y + plx + plz + phd ABS + phw ABS + sbc ABS,x + inc ABS,x + bbs7 ZP,labelG + +labelG: + brk + diff --git a/test/disassembler/Makefile b/test/disassembler/Makefile new file mode 100644 index 000000000..d60b82d19 --- /dev/null +++ b/test/disassembler/Makefile @@ -0,0 +1,41 @@ + +# makefile for the disassembler regression tests + +BINDIR = ../../bin +WORKDIR := ../../testwrk + +#BASE_TARGETS = 6502 6502x 65sc02 65c02 +#BASE_TARGETS += 4510 huc6280 +BASE_TARGETS = 4510 + +START = --start-addr 0x8000 + +DISASS_TARGETS = $(BASE_TARGETS) + +# default target defined later +all: + +# generate opcode targets and expand target list +define disass +DISASS_TARGETLIST += $$(WORKDIR)/$(1)-reass.bin $$(WORKDIR)/$(1)-reass.s $$(WORKDIR)/$(1)-disass.bin + +$$(WORKDIR)/$(1)-disass.bin: $(1)-disass.s + @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$< + @rm -f $(1)-disass.o #workaround for #168 + +$$(WORKDIR)/$(1)-reass.s: $$(WORKDIR)/$(1)-disass.bin + @$$(BINDIR)/da65 --cpu $(1) $(START) -o $$@ $$< + +$$(WORKDIR)/$(1)-reass.bin: $$(WORKDIR)/$(1)-reass.s + @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$< + @cmp $$@ $$(WORKDIR)/$(1)-disass.bin + @echo da65 --cpu $(1) ok +endef +$(foreach target,$(DISASS_TARGETS),$(eval $(call disass,$(target)))) + +# now that all targets have been generated, get to the manual ones +all: $(DISASS_TARGETLIST) + @# + +.PHONY: all $(DISASS_TARGETLIST) + From 86fc0240a9deef0a1a0d140807e9793762bf5f3f Mon Sep 17 00:00:00 2001 From: Jakob Haufe <sur5r@sur5r.net> Date: Fri, 23 Sep 2016 10:39:47 +0200 Subject: [PATCH 165/407] Add missing tag and remove duplicate text --- doc/ca65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 3e1b11df3..78be90d15 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -3552,7 +3552,7 @@ Here's a list of all control commands and a description, what they do: See: <tt><ref id=".P02" name=".P02"></tt>, <tt><ref id=".PSC02" name=".PSC02"></tt>, <tt><ref id=".P816" name=".P816"></tt> and - <ref id=".P4510" name=".P4510">4510</tt> + <tt><ref id=".P4510" name=".P4510"></tt> <sect1><tt>.POPCPU</tt><label id=".POPCPU"><p> From 2d76d0a657f886afcb60528a47be7781ddaff362 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Fri, 23 Sep 2016 13:10:38 +0200 Subject: [PATCH 166/407] da65: 4510 support - cleaned up unnecessary static function - adjusted table formatting --- src/da65/handler.c | 14 +- src/da65/opc4510.c | 508 ++++++++++++++++++++++----------------------- 2 files changed, 258 insertions(+), 264 deletions(-) diff --git a/src/da65/handler.c b/src/da65/handler.c index 6ba8a7eef..624952363 100644 --- a/src/da65/handler.c +++ b/src/da65/handler.c @@ -546,24 +546,18 @@ void OH_DirectIndirectLongX (const OpcDesc* D attribute ((unused))) -static void impl_StackRelativeIndirectY (const char *sp, const OpcDesc* D attribute ((unused))) -{ - /* Output the line */ - OneLine (D, "($%02X,%s),y", GetCodeByte (PC+1), sp); -} - - - void OH_StackRelativeIndirectY (const OpcDesc* D attribute ((unused))) { - impl_StackRelativeIndirectY( "s", D ); + /* Output the line */ + OneLine (D, "($%02X,s),y", GetCodeByte (PC+1)); } void OH_StackRelativeIndirectY4510 (const OpcDesc* D attribute ((unused))) { - impl_StackRelativeIndirectY( "sp", D ); + /* Output the line */ + OneLine (D, "($%02X,sp),y", GetCodeByte (PC+1)); } diff --git a/src/da65/opc4510.c b/src/da65/opc4510.c index c663b7a59..0356499e8 100644 --- a/src/da65/opc4510.c +++ b/src/da65/opc4510.c @@ -47,260 +47,260 @@ /* Descriptions for all opcodes */ const OpcDesc OpcTable_4510[256] = { - { "brk", 1, flNone, OH_Implicit }, /* $00 */ - { "ora", 2, flUseLabel, OH_DirectXIndirect }, /* $01 */ - { "cle", 1, flNone, OH_Implicit }, /* $02 */ - { "see", 1, flNone, OH_Implicit }, /* $03 */ - { "tsb", 2, flUseLabel, OH_Direct }, /* $04 */ - { "ora", 2, flUseLabel, OH_Direct }, /* $05 */ - { "asl", 2, flUseLabel, OH_Direct }, /* $06 */ - { "rmb0", 2, flUseLabel, OH_Direct }, /* $07 */ - { "php", 1, flNone, OH_Implicit }, /* $08 */ - { "ora", 2, flNone, OH_Immediate }, /* $09 */ - { "asl", 1, flNone, OH_Accumulator }, /* $0a */ - { "tsy", 1, flNone, OH_Implicit }, /* $0b */ - { "tsb", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0c */ - { "ora", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0d */ - { "asl", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0e */ - { "bbr0", 3, flUseLabel, OH_BitBranch }, /* $0f */ - { "bpl", 2, flLabel, OH_Relative }, /* $10 */ - { "ora", 2, flUseLabel, OH_DirectIndirectY }, /* $11 */ - { "ora", 2, flUseLabel, OH_DirectIndirectZ }, /* $12 */ - { "lbpl", 3, flLabel, OH_RelativeLong4510 }, /* $13 */ - { "trb", 2, flUseLabel, OH_Direct }, /* $14 */ - { "ora", 2, flUseLabel, OH_DirectX }, /* $15 */ - { "asl", 2, flUseLabel, OH_DirectX }, /* $16 */ - { "rmb1", 2, flUseLabel, OH_Direct }, /* $17 */ - { "clc", 1, flNone, OH_Implicit }, /* $18 */ - { "ora", 3, flUseLabel, OH_AbsoluteY }, /* $19 */ - { "inc", 1, flNone, OH_Accumulator }, /* $1a */ - { "inz", 1, flNone, OH_Implicit }, /* $1b */ - { "trb", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $1c */ - { "ora", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $1d */ - { "asl", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $1e */ - { "bbr1", 3, flUseLabel, OH_BitBranch }, /* $1f */ - { "jsr", 3, flLabel, OH_Absolute }, /* $20 */ - { "and", 2, flUseLabel, OH_DirectXIndirect }, /* $21 */ - { "jsr", 3, flLabel, OH_JmpAbsoluteIndirect }, /* $22 */ - { "jsr", 3, flLabel, OH_JmpAbsoluteXIndirect }, /* $23 */ - { "bit", 2, flUseLabel, OH_Direct }, /* $24 */ - { "and", 2, flUseLabel, OH_Direct }, /* $25 */ - { "rol", 2, flUseLabel, OH_Direct }, /* $26 */ - { "rmb2", 2, flUseLabel, OH_Direct }, /* $27 */ - { "plp", 1, flNone, OH_Implicit }, /* $28 */ - { "and", 2, flNone, OH_Immediate }, /* $29 */ - { "rol", 1, flNone, OH_Accumulator }, /* $2a */ - { "tys", 1, flNone, OH_Implicit }, /* $2b */ - { "bit", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2c */ - { "and", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2d */ - { "rol", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2e */ - { "bbr2", 3, flUseLabel, OH_BitBranch }, /* $2f */ - { "bmi", 2, flLabel, OH_Relative }, /* $30 */ - { "and", 2, flUseLabel, OH_DirectIndirectY }, /* $31 */ - { "and", 2, flUseLabel, OH_DirectIndirectZ }, /* $32 */ - { "lbmi", 3, flLabel, OH_RelativeLong4510 }, /* $33 */ - { "bit", 2, flUseLabel, OH_DirectX }, /* $34 */ - { "and", 2, flUseLabel, OH_DirectX }, /* $35 */ - { "rol", 2, flUseLabel, OH_DirectX }, /* $36 */ - { "rmb3", 2, flUseLabel, OH_Direct }, /* $37 */ - { "sec", 1, flNone, OH_Implicit }, /* $38 */ - { "and", 3, flUseLabel, OH_AbsoluteY }, /* $39 */ - { "dec", 1, flNone, OH_Accumulator }, /* $3a */ - { "dez", 1, flNone, OH_Implicit }, /* $3b */ - { "bit", 3, flUseLabel, OH_AbsoluteX }, /* $3c */ - { "and", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $3d */ - { "rol", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $3e */ - { "bbr3", 3, flUseLabel, OH_BitBranch }, /* $3f */ - { "rti", 1, flNone, OH_Rts }, /* $40 */ - { "eor", 2, flUseLabel, OH_DirectXIndirect }, /* $41 */ - { "neg", 1, flNone, OH_Implicit }, /* $42 */ - { "asr", 1, flNone, OH_Accumulator }, /* $43 */ - { "asr", 2, flUseLabel, OH_Direct }, /* $44 */ - { "eor", 2, flUseLabel, OH_Direct }, /* $45 */ - { "lsr", 2, flUseLabel, OH_Direct }, /* $46 */ - { "rmb4", 2, flUseLabel, OH_Direct }, /* $47 */ - { "pha", 1, flNone, OH_Implicit }, /* $48 */ - { "eor", 2, flNone, OH_Immediate }, /* $49 */ - { "lsr", 1, flNone, OH_Accumulator }, /* $4a */ - { "taz", 1, flNone, OH_Implicit }, /* $4b */ - { "jmp", 3, flLabel, OH_JmpAbsolute }, /* $4c */ - { "eor", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $4d */ - { "lsr", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $4e */ - { "bbr4", 3, flUseLabel, OH_BitBranch }, /* $4f */ - { "bvc", 2, flLabel, OH_Relative }, /* $50 */ - { "eor", 2, flUseLabel, OH_DirectIndirectY }, /* $51 */ - { "eor", 2, flUseLabel, OH_DirectIndirectZ }, /* $52 */ - { "lbvc", 3, flLabel, OH_RelativeLong4510 }, /* $53 */ - { "asr", 2, flUseLabel, OH_DirectX }, /* $54 */ - { "eor", 2, flUseLabel, OH_DirectX }, /* $55 */ - { "lsr", 2, flUseLabel, OH_DirectX }, /* $56 */ - { "rmb5", 2, flUseLabel, OH_Direct }, /* $57 */ - { "cli", 1, flNone, OH_Implicit }, /* $58 */ - { "eor", 3, flUseLabel, OH_AbsoluteY }, /* $59 */ - { "phy", 1, flNone, OH_Implicit }, /* $5a */ - { "tab", 1, flNone, OH_Implicit }, /* $5b */ - { "map", 1, flNone, OH_Implicit }, /* $5c */ - { "eor", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $5d */ - { "lsr", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $5e */ - { "bbr5", 3, flUseLabel, OH_BitBranch }, /* $5f */ - { "rts", 1, flNone, OH_Rts }, /* $60 */ - { "adc", 2, flUseLabel, OH_DirectXIndirect }, /* $61 */ - { "rtn", 2, flNone, OH_Immediate }, /* $62 */ - { "bsr", 3, flLabel, OH_RelativeLong4510 }, /* $63 */ - { "stz", 2, flUseLabel, OH_Direct }, /* $64 */ - { "adc", 2, flUseLabel, OH_Direct }, /* $65 */ - { "ror", 2, flUseLabel, OH_Direct }, /* $66 */ - { "rmb6", 2, flUseLabel, OH_Direct, }, /* $67 */ - { "pla", 1, flNone, OH_Implicit }, /* $68 */ - { "adc", 2, flNone, OH_Immediate }, /* $69 */ - { "ror", 1, flNone, OH_Accumulator }, /* $6a */ - { "tza", 1, flNone, OH_Implicit }, /* $6b */ - { "jmp", 3, flLabel, OH_JmpAbsoluteIndirect }, /* $6c */ - { "adc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $6d */ - { "ror", 3, flUseLabel, OH_Absolute }, /* $6e */ - { "bbr6", 3, flUseLabel, OH_BitBranch }, /* $6f */ - { "bvs", 2, flLabel, OH_Relative }, /* $70 */ - { "adc", 2, flUseLabel, OH_DirectIndirectY }, /* $71 */ - { "adc", 2, flUseLabel, OH_DirectIndirectZ }, /* $72 */ - { "lbvs", 3, flLabel, OH_RelativeLong4510 }, /* $73 */ - { "stz", 2, flUseLabel, OH_DirectX }, /* $74 */ - { "adc", 2, flUseLabel, OH_DirectX }, /* $75 */ - { "ror", 2, flUseLabel, OH_DirectX }, /* $76 */ - { "rmb7", 2, flUseLabel, OH_Direct }, /* $77 */ - { "sei", 1, flNone, OH_Implicit }, /* $78 */ - { "adc", 3, flUseLabel, OH_AbsoluteY }, /* $79 */ - { "ply", 1, flNone, OH_Implicit }, /* $7a */ - { "tba", 1, flNone, OH_Implicit }, /* $7b */ - { "jmp", 3, flLabel, OH_AbsoluteXIndirect }, /* $7c */ - { "adc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7d */ - { "ror", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7e */ - { "bbr7", 3, flUseLabel, OH_BitBranch }, /* $7f */ - { "bra", 2, flLabel, OH_Relative }, /* $80 */ - { "sta", 2, flUseLabel, OH_DirectXIndirect }, /* $81 */ + { "brk", 1, flNone, OH_Implicit }, /* $00 */ + { "ora", 2, flUseLabel, OH_DirectXIndirect }, /* $01 */ + { "cle", 1, flNone, OH_Implicit }, /* $02 */ + { "see", 1, flNone, OH_Implicit }, /* $03 */ + { "tsb", 2, flUseLabel, OH_Direct }, /* $04 */ + { "ora", 2, flUseLabel, OH_Direct }, /* $05 */ + { "asl", 2, flUseLabel, OH_Direct }, /* $06 */ + { "rmb0", 2, flUseLabel, OH_Direct }, /* $07 */ + { "php", 1, flNone, OH_Implicit }, /* $08 */ + { "ora", 2, flNone, OH_Immediate }, /* $09 */ + { "asl", 1, flNone, OH_Accumulator }, /* $0a */ + { "tsy", 1, flNone, OH_Implicit }, /* $0b */ + { "tsb", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0c */ + { "ora", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0d */ + { "asl", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0e */ + { "bbr0", 3, flUseLabel, OH_BitBranch }, /* $0f */ + { "bpl", 2, flLabel, OH_Relative }, /* $10 */ + { "ora", 2, flUseLabel, OH_DirectIndirectY }, /* $11 */ + { "ora", 2, flUseLabel, OH_DirectIndirectZ }, /* $12 */ + { "lbpl", 3, flLabel, OH_RelativeLong4510 }, /* $13 */ + { "trb", 2, flUseLabel, OH_Direct }, /* $14 */ + { "ora", 2, flUseLabel, OH_DirectX }, /* $15 */ + { "asl", 2, flUseLabel, OH_DirectX }, /* $16 */ + { "rmb1", 2, flUseLabel, OH_Direct }, /* $17 */ + { "clc", 1, flNone, OH_Implicit }, /* $18 */ + { "ora", 3, flUseLabel, OH_AbsoluteY }, /* $19 */ + { "inc", 1, flNone, OH_Accumulator }, /* $1a */ + { "inz", 1, flNone, OH_Implicit }, /* $1b */ + { "trb", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $1c */ + { "ora", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $1d */ + { "asl", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $1e */ + { "bbr1", 3, flUseLabel, OH_BitBranch }, /* $1f */ + { "jsr", 3, flLabel, OH_Absolute }, /* $20 */ + { "and", 2, flUseLabel, OH_DirectXIndirect }, /* $21 */ + { "jsr", 3, flLabel, OH_JmpAbsoluteIndirect }, /* $22 */ + { "jsr", 3, flLabel, OH_JmpAbsoluteXIndirect }, /* $23 */ + { "bit", 2, flUseLabel, OH_Direct }, /* $24 */ + { "and", 2, flUseLabel, OH_Direct }, /* $25 */ + { "rol", 2, flUseLabel, OH_Direct }, /* $26 */ + { "rmb2", 2, flUseLabel, OH_Direct }, /* $27 */ + { "plp", 1, flNone, OH_Implicit }, /* $28 */ + { "and", 2, flNone, OH_Immediate }, /* $29 */ + { "rol", 1, flNone, OH_Accumulator }, /* $2a */ + { "tys", 1, flNone, OH_Implicit }, /* $2b */ + { "bit", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2c */ + { "and", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2d */ + { "rol", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2e */ + { "bbr2", 3, flUseLabel, OH_BitBranch }, /* $2f */ + { "bmi", 2, flLabel, OH_Relative }, /* $30 */ + { "and", 2, flUseLabel, OH_DirectIndirectY }, /* $31 */ + { "and", 2, flUseLabel, OH_DirectIndirectZ }, /* $32 */ + { "lbmi", 3, flLabel, OH_RelativeLong4510 }, /* $33 */ + { "bit", 2, flUseLabel, OH_DirectX }, /* $34 */ + { "and", 2, flUseLabel, OH_DirectX }, /* $35 */ + { "rol", 2, flUseLabel, OH_DirectX }, /* $36 */ + { "rmb3", 2, flUseLabel, OH_Direct }, /* $37 */ + { "sec", 1, flNone, OH_Implicit }, /* $38 */ + { "and", 3, flUseLabel, OH_AbsoluteY }, /* $39 */ + { "dec", 1, flNone, OH_Accumulator }, /* $3a */ + { "dez", 1, flNone, OH_Implicit }, /* $3b */ + { "bit", 3, flUseLabel, OH_AbsoluteX }, /* $3c */ + { "and", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $3d */ + { "rol", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $3e */ + { "bbr3", 3, flUseLabel, OH_BitBranch }, /* $3f */ + { "rti", 1, flNone, OH_Rts }, /* $40 */ + { "eor", 2, flUseLabel, OH_DirectXIndirect }, /* $41 */ + { "neg", 1, flNone, OH_Implicit }, /* $42 */ + { "asr", 1, flNone, OH_Accumulator }, /* $43 */ + { "asr", 2, flUseLabel, OH_Direct }, /* $44 */ + { "eor", 2, flUseLabel, OH_Direct }, /* $45 */ + { "lsr", 2, flUseLabel, OH_Direct }, /* $46 */ + { "rmb4", 2, flUseLabel, OH_Direct }, /* $47 */ + { "pha", 1, flNone, OH_Implicit }, /* $48 */ + { "eor", 2, flNone, OH_Immediate }, /* $49 */ + { "lsr", 1, flNone, OH_Accumulator }, /* $4a */ + { "taz", 1, flNone, OH_Implicit }, /* $4b */ + { "jmp", 3, flLabel, OH_JmpAbsolute }, /* $4c */ + { "eor", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $4d */ + { "lsr", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $4e */ + { "bbr4", 3, flUseLabel, OH_BitBranch }, /* $4f */ + { "bvc", 2, flLabel, OH_Relative }, /* $50 */ + { "eor", 2, flUseLabel, OH_DirectIndirectY }, /* $51 */ + { "eor", 2, flUseLabel, OH_DirectIndirectZ }, /* $52 */ + { "lbvc", 3, flLabel, OH_RelativeLong4510 }, /* $53 */ + { "asr", 2, flUseLabel, OH_DirectX }, /* $54 */ + { "eor", 2, flUseLabel, OH_DirectX }, /* $55 */ + { "lsr", 2, flUseLabel, OH_DirectX }, /* $56 */ + { "rmb5", 2, flUseLabel, OH_Direct }, /* $57 */ + { "cli", 1, flNone, OH_Implicit }, /* $58 */ + { "eor", 3, flUseLabel, OH_AbsoluteY }, /* $59 */ + { "phy", 1, flNone, OH_Implicit }, /* $5a */ + { "tab", 1, flNone, OH_Implicit }, /* $5b */ + { "map", 1, flNone, OH_Implicit }, /* $5c */ + { "eor", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $5d */ + { "lsr", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $5e */ + { "bbr5", 3, flUseLabel, OH_BitBranch }, /* $5f */ + { "rts", 1, flNone, OH_Rts }, /* $60 */ + { "adc", 2, flUseLabel, OH_DirectXIndirect }, /* $61 */ + { "rtn", 2, flNone, OH_Immediate }, /* $62 */ + { "bsr", 3, flLabel, OH_RelativeLong4510 }, /* $63 */ + { "stz", 2, flUseLabel, OH_Direct }, /* $64 */ + { "adc", 2, flUseLabel, OH_Direct }, /* $65 */ + { "ror", 2, flUseLabel, OH_Direct }, /* $66 */ + { "rmb6", 2, flUseLabel, OH_Direct, }, /* $67 */ + { "pla", 1, flNone, OH_Implicit }, /* $68 */ + { "adc", 2, flNone, OH_Immediate }, /* $69 */ + { "ror", 1, flNone, OH_Accumulator }, /* $6a */ + { "tza", 1, flNone, OH_Implicit }, /* $6b */ + { "jmp", 3, flLabel, OH_JmpAbsoluteIndirect }, /* $6c */ + { "adc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $6d */ + { "ror", 3, flUseLabel, OH_Absolute }, /* $6e */ + { "bbr6", 3, flUseLabel, OH_BitBranch }, /* $6f */ + { "bvs", 2, flLabel, OH_Relative }, /* $70 */ + { "adc", 2, flUseLabel, OH_DirectIndirectY }, /* $71 */ + { "adc", 2, flUseLabel, OH_DirectIndirectZ }, /* $72 */ + { "lbvs", 3, flLabel, OH_RelativeLong4510 }, /* $73 */ + { "stz", 2, flUseLabel, OH_DirectX }, /* $74 */ + { "adc", 2, flUseLabel, OH_DirectX }, /* $75 */ + { "ror", 2, flUseLabel, OH_DirectX }, /* $76 */ + { "rmb7", 2, flUseLabel, OH_Direct }, /* $77 */ + { "sei", 1, flNone, OH_Implicit }, /* $78 */ + { "adc", 3, flUseLabel, OH_AbsoluteY }, /* $79 */ + { "ply", 1, flNone, OH_Implicit }, /* $7a */ + { "tba", 1, flNone, OH_Implicit }, /* $7b */ + { "jmp", 3, flLabel, OH_AbsoluteXIndirect }, /* $7c */ + { "adc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7d */ + { "ror", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7e */ + { "bbr7", 3, flUseLabel, OH_BitBranch }, /* $7f */ + { "bra", 2, flLabel, OH_Relative }, /* $80 */ + { "sta", 2, flUseLabel, OH_DirectXIndirect }, /* $81 */ { "sta", 2, flNone, OH_StackRelativeIndirectY4510}, /* $82 */ - { "lbra", 3, flLabel, OH_RelativeLong4510 }, /* $83 */ - { "sty", 2, flUseLabel, OH_Direct }, /* $84 */ - { "sta", 2, flUseLabel, OH_Direct }, /* $85 */ - { "stx", 2, flUseLabel, OH_Direct }, /* $86 */ - { "smb0", 2, flUseLabel, OH_Direct }, /* $87 */ - { "dey", 1, flNone, OH_Implicit }, /* $88 */ - { "bit", 2, flNone, OH_Immediate }, /* $89 */ - { "txa", 1, flNone, OH_Implicit }, /* $8a */ - { "sty", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $8b */ - { "sty", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8c */ - { "sta", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8d */ - { "stx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8e */ - { "bbs0", 3, flUseLabel, OH_BitBranch }, /* $8f */ - { "bcc", 2, flLabel, OH_Relative }, /* $90 */ - { "sta", 2, flUseLabel, OH_DirectIndirectY }, /* $91 */ - { "sta", 2, flUseLabel, OH_DirectIndirectZ }, /* $92 */ - { "lbcc", 3, flLabel, OH_RelativeLong4510 }, /* $93 */ - { "sty", 2, flUseLabel, OH_DirectX }, /* $94 */ - { "sta", 2, flUseLabel, OH_DirectX }, /* $95 */ - { "stx", 2, flUseLabel, OH_DirectY }, /* $96 */ - { "smb1", 2, flUseLabel, OH_Direct }, /* $97 */ - { "tya", 1, flNone, OH_Implicit }, /* $98 */ - { "sta", 3, flUseLabel, OH_AbsoluteY }, /* $99 */ - { "txs", 1, flNone, OH_Implicit }, /* $9a */ - { "stx", 3, flUseLabel|flAbsOverride, OH_AbsoluteY }, /* $9b */ - { "stz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $9c */ - { "sta", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $9d */ - { "stz", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $9e */ - { "bbs1", 3, flUseLabel, OH_BitBranch }, /* $9f */ - { "ldy", 2, flNone, OH_Immediate }, /* $a0 */ - { "lda", 2, flUseLabel, OH_DirectXIndirect }, /* $a1 */ - { "ldx", 2, flNone, OH_Immediate }, /* $a2 */ - { "ldz", 2, flNone, OH_Immediate }, /* $a3 */ - { "ldy", 2, flUseLabel, OH_Direct }, /* $a4 */ - { "lda", 2, flUseLabel, OH_Direct }, /* $a5 */ - { "ldx", 2, flUseLabel, OH_Direct }, /* $a6 */ - { "smb2", 2, flUseLabel, OH_Direct }, /* $a7 */ - { "tay", 1, flNone, OH_Implicit }, /* $a8 */ - { "lda", 2, flNone, OH_Immediate }, /* $a9 */ - { "tax", 1, flNone, OH_Implicit }, /* $aa */ - { "ldz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ab */ - { "ldy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ac */ - { "lda", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ad */ - { "ldx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ae */ - { "bbs2", 3, flUseLabel, OH_BitBranch }, /* $af */ - { "bcs", 2, flLabel, OH_Relative }, /* $b0 */ - { "lda", 2, flUseLabel, OH_DirectIndirectY }, /* $b1 */ - { "lda", 2, flUseLabel, OH_DirectIndirectZ }, /* $b2 */ - { "lbcs", 3, flLabel, OH_RelativeLong4510 }, /* $b3 */ - { "ldy", 2, flUseLabel, OH_DirectX }, /* $b4 */ - { "lda", 2, flUseLabel, OH_DirectX }, /* $b5 */ - { "ldx", 2, flUseLabel, OH_DirectY }, /* $b6 */ - { "smb3", 2, flUseLabel, OH_Direct }, /* $b7 */ - { "clv", 1, flNone, OH_Implicit }, /* $b8 */ - { "lda", 3, flUseLabel, OH_AbsoluteY }, /* $b9 */ - { "tsx", 1, flNone, OH_Implicit }, /* $ba */ - { "ldz", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bb */ - { "ldy", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bc */ - { "lda", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bd */ - { "ldx", 3, flUseLabel|flAbsOverride, OH_AbsoluteY }, /* $be */ - { "bbs3", 3, flUseLabel, OH_BitBranch }, /* $bf */ - { "cpy", 2, flNone, OH_Immediate }, /* $c0 */ - { "cmp", 2, flUseLabel, OH_DirectXIndirect }, /* $c1 */ - { "cpz", 2, flNone, OH_Immediate }, /* $c2 */ - { "dew", 2, flUseLabel, OH_Direct }, /* $c3 */ - { "cpy", 2, flUseLabel, OH_Direct }, /* $c4 */ - { "cmp", 2, flUseLabel, OH_Direct }, /* $c5 */ - { "dec", 2, flUseLabel, OH_Direct }, /* $c6 */ - { "smb4", 2, flUseLabel, OH_Direct }, /* $c7 */ - { "iny", 1, flNone, OH_Implicit }, /* $c8 */ - { "cmp", 2, flNone, OH_Immediate }, /* $c9 */ - { "dex", 1, flNone, OH_Implicit }, /* $ca */ - { "asw", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cb */ - { "cpy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cc */ - { "cmp", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cd */ - { "dec", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ce */ - { "bbs4", 3, flUseLabel, OH_BitBranch }, /* $cf */ - { "bne", 2, flLabel, OH_Relative }, /* $d0 */ - { "cmp", 2, flUseLabel, OH_DirectIndirectY }, /* $d1 */ - { "cmp", 2, flUseLabel, OH_DirectIndirectZ }, /* $d2 */ - { "lbne", 3, flLabel, OH_RelativeLong4510 }, /* $d3 */ - { "cpz", 2, flUseLabel, OH_Direct }, /* $d4 */ - { "cmp", 2, flUseLabel, OH_DirectX }, /* $d5 */ - { "dec", 2, flUseLabel, OH_DirectX }, /* $d6 */ - { "smb5", 2, flUseLabel, OH_Direct }, /* $d7 */ - { "cld", 1, flNone, OH_Implicit }, /* $d8 */ - { "cmp", 3, flUseLabel, OH_AbsoluteY }, /* $d9 */ - { "phx", 1, flNone, OH_Implicit }, /* $da */ - { "phz", 1, flNone, OH_Implicit }, /* $db */ - { "cpz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $dc */ - { "cmp", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $dd */ - { "dec", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $de */ - { "bbs5", 3, flUseLabel, OH_BitBranch }, /* $df */ - { "cpx", 2, flNone, OH_Immediate }, /* $e0 */ - { "sbc", 2, flUseLabel, OH_DirectXIndirect }, /* $e1 */ + { "lbra", 3, flLabel, OH_RelativeLong4510 }, /* $83 */ + { "sty", 2, flUseLabel, OH_Direct }, /* $84 */ + { "sta", 2, flUseLabel, OH_Direct }, /* $85 */ + { "stx", 2, flUseLabel, OH_Direct }, /* $86 */ + { "smb0", 2, flUseLabel, OH_Direct }, /* $87 */ + { "dey", 1, flNone, OH_Implicit }, /* $88 */ + { "bit", 2, flNone, OH_Immediate }, /* $89 */ + { "txa", 1, flNone, OH_Implicit }, /* $8a */ + { "sty", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $8b */ + { "sty", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8c */ + { "sta", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8d */ + { "stx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8e */ + { "bbs0", 3, flUseLabel, OH_BitBranch }, /* $8f */ + { "bcc", 2, flLabel, OH_Relative }, /* $90 */ + { "sta", 2, flUseLabel, OH_DirectIndirectY }, /* $91 */ + { "sta", 2, flUseLabel, OH_DirectIndirectZ }, /* $92 */ + { "lbcc", 3, flLabel, OH_RelativeLong4510 }, /* $93 */ + { "sty", 2, flUseLabel, OH_DirectX }, /* $94 */ + { "sta", 2, flUseLabel, OH_DirectX }, /* $95 */ + { "stx", 2, flUseLabel, OH_DirectY }, /* $96 */ + { "smb1", 2, flUseLabel, OH_Direct }, /* $97 */ + { "tya", 1, flNone, OH_Implicit }, /* $98 */ + { "sta", 3, flUseLabel, OH_AbsoluteY }, /* $99 */ + { "txs", 1, flNone, OH_Implicit }, /* $9a */ + { "stx", 3, flUseLabel|flAbsOverride, OH_AbsoluteY }, /* $9b */ + { "stz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $9c */ + { "sta", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $9d */ + { "stz", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $9e */ + { "bbs1", 3, flUseLabel, OH_BitBranch }, /* $9f */ + { "ldy", 2, flNone, OH_Immediate }, /* $a0 */ + { "lda", 2, flUseLabel, OH_DirectXIndirect }, /* $a1 */ + { "ldx", 2, flNone, OH_Immediate }, /* $a2 */ + { "ldz", 2, flNone, OH_Immediate }, /* $a3 */ + { "ldy", 2, flUseLabel, OH_Direct }, /* $a4 */ + { "lda", 2, flUseLabel, OH_Direct }, /* $a5 */ + { "ldx", 2, flUseLabel, OH_Direct }, /* $a6 */ + { "smb2", 2, flUseLabel, OH_Direct }, /* $a7 */ + { "tay", 1, flNone, OH_Implicit }, /* $a8 */ + { "lda", 2, flNone, OH_Immediate }, /* $a9 */ + { "tax", 1, flNone, OH_Implicit }, /* $aa */ + { "ldz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ab */ + { "ldy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ac */ + { "lda", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ad */ + { "ldx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ae */ + { "bbs2", 3, flUseLabel, OH_BitBranch }, /* $af */ + { "bcs", 2, flLabel, OH_Relative }, /* $b0 */ + { "lda", 2, flUseLabel, OH_DirectIndirectY }, /* $b1 */ + { "lda", 2, flUseLabel, OH_DirectIndirectZ }, /* $b2 */ + { "lbcs", 3, flLabel, OH_RelativeLong4510 }, /* $b3 */ + { "ldy", 2, flUseLabel, OH_DirectX }, /* $b4 */ + { "lda", 2, flUseLabel, OH_DirectX }, /* $b5 */ + { "ldx", 2, flUseLabel, OH_DirectY }, /* $b6 */ + { "smb3", 2, flUseLabel, OH_Direct }, /* $b7 */ + { "clv", 1, flNone, OH_Implicit }, /* $b8 */ + { "lda", 3, flUseLabel, OH_AbsoluteY }, /* $b9 */ + { "tsx", 1, flNone, OH_Implicit }, /* $ba */ + { "ldz", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bb */ + { "ldy", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bc */ + { "lda", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bd */ + { "ldx", 3, flUseLabel|flAbsOverride, OH_AbsoluteY }, /* $be */ + { "bbs3", 3, flUseLabel, OH_BitBranch }, /* $bf */ + { "cpy", 2, flNone, OH_Immediate }, /* $c0 */ + { "cmp", 2, flUseLabel, OH_DirectXIndirect }, /* $c1 */ + { "cpz", 2, flNone, OH_Immediate }, /* $c2 */ + { "dew", 2, flUseLabel, OH_Direct }, /* $c3 */ + { "cpy", 2, flUseLabel, OH_Direct }, /* $c4 */ + { "cmp", 2, flUseLabel, OH_Direct }, /* $c5 */ + { "dec", 2, flUseLabel, OH_Direct }, /* $c6 */ + { "smb4", 2, flUseLabel, OH_Direct }, /* $c7 */ + { "iny", 1, flNone, OH_Implicit }, /* $c8 */ + { "cmp", 2, flNone, OH_Immediate }, /* $c9 */ + { "dex", 1, flNone, OH_Implicit }, /* $ca */ + { "asw", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cb */ + { "cpy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cc */ + { "cmp", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cd */ + { "dec", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ce */ + { "bbs4", 3, flUseLabel, OH_BitBranch }, /* $cf */ + { "bne", 2, flLabel, OH_Relative }, /* $d0 */ + { "cmp", 2, flUseLabel, OH_DirectIndirectY }, /* $d1 */ + { "cmp", 2, flUseLabel, OH_DirectIndirectZ }, /* $d2 */ + { "lbne", 3, flLabel, OH_RelativeLong4510 }, /* $d3 */ + { "cpz", 2, flUseLabel, OH_Direct }, /* $d4 */ + { "cmp", 2, flUseLabel, OH_DirectX }, /* $d5 */ + { "dec", 2, flUseLabel, OH_DirectX }, /* $d6 */ + { "smb5", 2, flUseLabel, OH_Direct }, /* $d7 */ + { "cld", 1, flNone, OH_Implicit }, /* $d8 */ + { "cmp", 3, flUseLabel, OH_AbsoluteY }, /* $d9 */ + { "phx", 1, flNone, OH_Implicit }, /* $da */ + { "phz", 1, flNone, OH_Implicit }, /* $db */ + { "cpz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $dc */ + { "cmp", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $dd */ + { "dec", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $de */ + { "bbs5", 3, flUseLabel, OH_BitBranch }, /* $df */ + { "cpx", 2, flNone, OH_Immediate }, /* $e0 */ + { "sbc", 2, flUseLabel, OH_DirectXIndirect }, /* $e1 */ { "lda", 2, flNone, OH_StackRelativeIndirectY4510}, /* $e2 */ - { "inw", 2, flUseLabel, OH_Direct }, /* $e3 */ - { "cpx", 2, flUseLabel, OH_Direct }, /* $e4 */ - { "sbc", 2, flUseLabel, OH_Direct }, /* $e5 */ - { "inc", 2, flUseLabel, OH_Direct }, /* $e6 */ - { "smb6", 2, flUseLabel, OH_Direct }, /* $e7 */ - { "inx", 1, flNone, OH_Implicit }, /* $e8 */ - { "sbc", 2, flNone, OH_Immediate }, /* $e9 */ - { "eom", 1, flNone, OH_Implicit }, /* $ea */ - { "row", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $eb */ - { "cpx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ec */ - { "sbc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ed */ - { "inc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ee */ - { "bbs6", 3, flUseLabel, OH_BitBranch }, /* $ef */ - { "beq", 2, flLabel, OH_Relative }, /* $f0 */ - { "sbc", 2, flUseLabel, OH_DirectIndirectY }, /* $f1 */ - { "sbc", 2, flUseLabel, OH_DirectIndirectZ }, /* $f2 */ - { "lbeq", 3, flLabel, OH_RelativeLong4510 }, /* $f3 */ - { "phw", 3, flNone, OH_ImmediateWord }, /* $f4 */ - { "sbc", 2, flUseLabel, OH_DirectX }, /* $f5 */ - { "inc", 2, flUseLabel, OH_DirectX }, /* $f6 */ - { "smb7", 2, flUseLabel, OH_Direct }, /* $f7 */ - { "sed", 1, flNone, OH_Implicit }, /* $f8 */ - { "sbc", 3, flUseLabel, OH_AbsoluteY }, /* $f9 */ - { "plx", 1, flNone, OH_Implicit }, /* $fa */ - { "plz", 1, flNone, OH_Implicit }, /* $fb */ - { "phw", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $fc */ - { "sbc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $fd */ - { "inc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $fe */ - { "bbs7", 3, flUseLabel, OH_BitBranch }, /* $ff */ + { "inw", 2, flUseLabel, OH_Direct }, /* $e3 */ + { "cpx", 2, flUseLabel, OH_Direct }, /* $e4 */ + { "sbc", 2, flUseLabel, OH_Direct }, /* $e5 */ + { "inc", 2, flUseLabel, OH_Direct }, /* $e6 */ + { "smb6", 2, flUseLabel, OH_Direct }, /* $e7 */ + { "inx", 1, flNone, OH_Implicit }, /* $e8 */ + { "sbc", 2, flNone, OH_Immediate }, /* $e9 */ + { "eom", 1, flNone, OH_Implicit }, /* $ea */ + { "row", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $eb */ + { "cpx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ec */ + { "sbc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ed */ + { "inc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ee */ + { "bbs6", 3, flUseLabel, OH_BitBranch }, /* $ef */ + { "beq", 2, flLabel, OH_Relative }, /* $f0 */ + { "sbc", 2, flUseLabel, OH_DirectIndirectY }, /* $f1 */ + { "sbc", 2, flUseLabel, OH_DirectIndirectZ }, /* $f2 */ + { "lbeq", 3, flLabel, OH_RelativeLong4510 }, /* $f3 */ + { "phw", 3, flNone, OH_ImmediateWord }, /* $f4 */ + { "sbc", 2, flUseLabel, OH_DirectX }, /* $f5 */ + { "inc", 2, flUseLabel, OH_DirectX }, /* $f6 */ + { "smb7", 2, flUseLabel, OH_Direct }, /* $f7 */ + { "sed", 1, flNone, OH_Implicit }, /* $f8 */ + { "sbc", 3, flUseLabel, OH_AbsoluteY }, /* $f9 */ + { "plx", 1, flNone, OH_Implicit }, /* $fa */ + { "plz", 1, flNone, OH_Implicit }, /* $fb */ + { "phw", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $fc */ + { "sbc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $fd */ + { "inc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $fe */ + { "bbs7", 3, flUseLabel, OH_BitBranch }, /* $ff */ }; From 476260a6fa79320a241d8f8a26923c5aaf3b1df5 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll <svolli@svolli.de> Date: Tue, 27 Sep 2016 12:02:57 +0200 Subject: [PATCH 167/407] 4510 support for da65: fixed docs and Makefile for testcase. --- doc/da65.sgml | 2 +- test/disassembler/Makefile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/da65.sgml b/doc/da65.sgml index 6d962e9d6..a8e32e1c8 100644 --- a/doc/da65.sgml +++ b/doc/da65.sgml @@ -243,7 +243,7 @@ manipulation and bit test-and-branch commands. When disassembling 4510 code, due to handling of 16-bit wide branches, da65 can produce output that can not be re-assembled, when one or more of those -branches point outside of the disassmbled memory. This can happen when text +branches point outside of the disassembled memory. This can happen when text or binary data is processed. While there is some code for the 65816 in the sources, it is currently diff --git a/test/disassembler/Makefile b/test/disassembler/Makefile index d60b82d19..2621b0c20 100644 --- a/test/disassembler/Makefile +++ b/test/disassembler/Makefile @@ -28,6 +28,7 @@ $$(WORKDIR)/$(1)-reass.s: $$(WORKDIR)/$(1)-disass.bin $$(WORKDIR)/$(1)-reass.bin: $$(WORKDIR)/$(1)-reass.s @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$< + @rm -f $(1)-reass.o #workaround for #168 @cmp $$@ $$(WORKDIR)/$(1)-disass.bin @echo da65 --cpu $(1) ok endef From 23cfb51e7297963b70a3c89a8c2720c817c9bb5f Mon Sep 17 00:00:00 2001 From: greg-king5 <gregdk@users.sf.net> Date: Thu, 29 Sep 2016 20:00:09 -0400 Subject: [PATCH 168/407] Shorten a URL. --- doc/pce.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/pce.sgml b/doc/pce.sgml index ba59c31a7..104dee526 100644 --- a/doc/pce.sgml +++ b/doc/pce.sgml @@ -5,7 +5,7 @@ <title>PC-Engine (TurboGrafx) System specific information for cc65 <author> <url url="mailto:groepaz@gmx.net" name="Groepaz/Hitmen"> -<date>2015-07-14 +<date>2016-09-29 <abstract> An overview over the PCE runtime system as it is implemented for the @@ -179,7 +179,7 @@ some useful resources on PCE coding: <itemize> <item><url url="http://blog.blockos.org/?tag=pc-engine"> <item><url url="http://pcedev.blockos.org/viewforum.php?f=5"> -<item><url url="http://www.romhacking.net/?page=documents&category=&platform=4&:game=&author=&perpage=20&level=&title=&desc=&docsearch=Go"> +<item><url url="http://www.romhacking.net/?page=documents&platform=4"> <item><url url="http://archaicpixels.com/Main_Page"> <item><url url="http://www.magicengine.com/mkit/doc.html"> From dfbd96f09e742dd46d67e4c10c55ba58ccb2a6e9 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sat, 15 Oct 2016 15:45:17 +0200 Subject: [PATCH 169/407] Make use of doesclrscrafterexit(). --- samples/plasma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/plasma.c b/samples/plasma.c index 7b092ec81..ac17265f3 100644 --- a/samples/plasma.c +++ b/samples/plasma.c @@ -12,6 +12,7 @@ #include <stdlib.h> #include <time.h> #include <conio.h> +#include <cc65.h> @@ -292,12 +293,11 @@ int main (void) gotoxy (0, 1); cprintf ("frames: %lu", f); gotoxy (0, 2); cprintf ("fps : %lu.%u", fps, fps10); - /* Wait for a key, then end */ - cputsxy (0, 4, "Press any key when done..."); - (void) cgetc (); + if (doesclrscrafterexit ()) { + cputsxy (0, 4, "Press any key when done..."); + (void) cgetc (); + } /* Done */ return EXIT_SUCCESS; } - - From 79e1b25c6c10f5a12b607d201bcddc3b1d98d999 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 16 Oct 2016 13:47:31 +0200 Subject: [PATCH 170/407] Removed DEL as suggested by Greg. --- test/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/Makefile b/test/Makefile index f0d63f689..4817e70e0 100644 --- a/test/Makefile +++ b/test/Makefile @@ -11,12 +11,10 @@ endif ifdef CMD_EXE EXE := .exe - DEL = -del /f $(subst /,\,$1) MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) else EXE := - DEL = $(RM) $1 MKDIR = mkdir $1 RMDIR = $(RM) -r $1 endif @@ -54,5 +52,4 @@ mostlyclean: @$(MAKE) -C misc clean clean: mostlyclean - @$(call DEL,$(WORKDIR)/bdiff$(EXE)) @$(call RMDIR,$(WORKDIR)) From 6ee1fd2a677c4ee497b5c087b4356a7b783a9b75 Mon Sep 17 00:00:00 2001 From: Alan Cox <alan@linux.intel.com> Date: Sat, 19 Nov 2016 13:02:19 +0000 Subject: [PATCH 171/407] scanner: Correct handling of \0101 The C language has this oddity that octal constants are 3 bytes so the sequence "\0101" is two bytes and well defined by the langage. cc65 currently misparses this as a 1 byte octal code. Add a count to fix this. Signed-off-by: Alan Cox <etchedpixels@gmail.com> --- src/cc65/scanner.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 16d43e2ea..d867c9857 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -267,6 +267,7 @@ static int ParseChar (void) { int C; int HadError; + int Count; /* Check for escape chars */ if (CurC == '\\') { @@ -337,8 +338,9 @@ static int ParseChar (void) case '7': /* Octal constant */ HadError = 0; + Count = 1; C = HexVal (CurC); - while (IsODigit (NextC)) { + while (IsODigit (NextC) && Count++ < 3) { if ((C << 3) >= 256) { if (!HadError) { Error ("Octal character constant out of range"); From e4aee2ba340d32ab9042fc86070e0bd263a50ba1 Mon Sep 17 00:00:00 2001 From: Alan Cox <alan@linux.intel.com> Date: Sun, 20 Nov 2016 18:02:45 +0000 Subject: [PATCH 172/407] cc65: remove un-needed logic from octal parsing We no longer need the extra error handling logic for octal parsing so simplify it as requested by Greg King. Signed-off-by: Alan Cox <etchedpixels@gmail.com> --- src/cc65/scanner.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index d867c9857..c9009bc2f 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -337,20 +337,14 @@ static int ParseChar (void) case '6': case '7': /* Octal constant */ - HadError = 0; Count = 1; C = HexVal (CurC); while (IsODigit (NextC) && Count++ < 3) { - if ((C << 3) >= 256) { - if (!HadError) { - Error ("Octal character constant out of range"); - HadError = 1; - } - } else { - C = (C << 3) | HexVal (NextC); - } + C = (C << 3) | HexVal (NextC); NextChar (); } + if (C >= 256) + Error ("Octal character constant out of range"); break; default: Error ("Illegal character constant"); From 8a0841326348c95247de8f3c7d60a141957af63b Mon Sep 17 00:00:00 2001 From: Peter Ferrie <peter.ferrie@gmail.com> Date: Sat, 3 Dec 2016 20:54:14 -0800 Subject: [PATCH 173/407] fix build break on da65 --- src/da65.vcxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/da65.vcxproj b/src/da65.vcxproj index 7810844dc..2695edc08 100644 --- a/src/da65.vcxproj +++ b/src/da65.vcxproj @@ -86,6 +86,7 @@ <ClCompile Include="da65\infofile.c" /> <ClCompile Include="da65\labels.c" /> <ClCompile Include="da65\main.c" /> + <ClCompile Include="da65\opc4510.c" /> <ClCompile Include="da65\opc6502.c" /> <ClCompile Include="da65\opc6502x.c" /> <ClCompile Include="da65\opc65816.c" /> @@ -109,6 +110,7 @@ <ClInclude Include="da65\handler.h" /> <ClInclude Include="da65\infofile.h" /> <ClInclude Include="da65\labels.h" /> + <ClInclude Include="da65\opc4510.h" /> <ClInclude Include="da65\opc6502.h" /> <ClInclude Include="da65\opc6502x.h" /> <ClInclude Include="da65\opc65816.h" /> From 252e4afb9c75b8f4068bfe647ae5a96c5df8f2e3 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Wed, 14 Dec 2016 21:22:10 +0100 Subject: [PATCH 174/407] Adding files for telemon30 --- libsrc/Makefile | 4 +- libsrc/common/fread.s | 12 +- libsrc/telemon30/_open.s | 44 +++ libsrc/telemon30/_read.s | 31 ++ libsrc/telemon30/_scrsize.s | 19 ++ libsrc/telemon30/ch376.s | 200 +++++++++++ libsrc/telemon30/crt0.s | 101 ++++++ libsrc/telemon30/ctype.s | 299 +++++++++++++++++ libsrc/telemon30/graphics.s | 51 +++ libsrc/telemon30/keyboard.s | 13 + libsrc/telemon30/mainargs.s | 137 ++++++++ libsrc/telemon30/mym.s | 626 +++++++++++++++++++++++++++++++++++ libsrc/telemon30/orixhdr.s | 36 ++ libsrc/telemon30/oserrlist.s | 75 +++++ libsrc/telemon30/oserror.s | 17 + libsrc/telemon30/print.s | 21 ++ libsrc/telemon30/sound.s | 45 +++ libsrc/telemon30/sysuname.s | 46 +++ libsrc/telemon30/write.s | 61 ++++ src/ar65.vcxproj | 6 +- src/ca65.vcxproj | 6 +- src/ca65/main.c | 17 +- src/cc65.vcxproj | 6 +- src/cc65/main.c | 10 +- src/chrcvt65.vcxproj | 6 +- src/cl65.vcxproj | 6 +- src/co65.vcxproj | 6 +- src/common.vcxproj | 6 +- src/common/target.c | 8 +- src/common/target.h | 3 +- src/da65.vcxproj | 6 +- src/grc65.vcxproj | 6 +- src/ld65.vcxproj | 6 +- src/od65.vcxproj | 6 +- src/sim65.vcxproj | 6 +- src/sp65.vcxproj | 6 +- 36 files changed, 1899 insertions(+), 55 deletions(-) create mode 100644 libsrc/telemon30/_open.s create mode 100644 libsrc/telemon30/_read.s create mode 100644 libsrc/telemon30/_scrsize.s create mode 100644 libsrc/telemon30/ch376.s create mode 100644 libsrc/telemon30/crt0.s create mode 100644 libsrc/telemon30/ctype.s create mode 100644 libsrc/telemon30/graphics.s create mode 100644 libsrc/telemon30/keyboard.s create mode 100644 libsrc/telemon30/mainargs.s create mode 100644 libsrc/telemon30/mym.s create mode 100644 libsrc/telemon30/orixhdr.s create mode 100644 libsrc/telemon30/oserrlist.s create mode 100644 libsrc/telemon30/oserror.s create mode 100644 libsrc/telemon30/print.s create mode 100644 libsrc/telemon30/sound.s create mode 100644 libsrc/telemon30/sysuname.s create mode 100644 libsrc/telemon30/write.s diff --git a/libsrc/Makefile b/libsrc/Makefile index 99f120f3a..0342a8ca4 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -30,7 +30,9 @@ TARGETS = apple2 \ pce \ sim6502 \ sim65c02 \ - supervision + supervision\ + telemon24\ + telemon30 DRVTYPES = emd \ joy \ diff --git a/libsrc/common/fread.s b/libsrc/common/fread.s index 91d692985..b87cc5cb4 100644 --- a/libsrc/common/fread.s +++ b/libsrc/common/fread.s @@ -173,13 +173,16 @@ ; Read was ok, account for the pushed back character (if any). -@L8: add pb +@L8: + add pb bcc @L9 inx ; Check for end of file. -@L9: cmp #0 ; Zero bytes read? +@L9: + + cmp #0 ; Zero bytes read? bne @L10 cpx #0 bne @L10 @@ -192,7 +195,10 @@ ; Return the number of items successfully read. Since we've checked for ; bytes == 0 above, size cannot be zero here, so the division is safe. -@L10: jsr pushax ; Push number of bytes read +@L10: + + + jsr pushax ; Push number of bytes read ldy #5 jsr ldaxysp ; Get size jsr tosudivax ; bytes / size -> a/x diff --git a/libsrc/telemon30/_open.s b/libsrc/telemon30/_open.s new file mode 100644 index 000000000..f308632d9 --- /dev/null +++ b/libsrc/telemon30/_open.s @@ -0,0 +1,44 @@ + .export _open + .import addysp,popax + .importzp sp,tmp2,tmp3,tmp1 + ; int open (const char* name, int flags, ...); /* May take a mode argument */ + .include "telemon30.inc" + +.proc _open +; Throw away any additional parameters passed through the ellipsis + + dey ; Parm count < 4 shouldn't be needed to be... + dey ; ...checked (it generates a c compiler warning) + dey + dey + beq parmok ; Branch if parameter count ok + jsr addysp ; Fix stack, throw away unused parameters + +; Parameters ok. Pop the flags and save them into tmp3 + +parmok: jsr popax ; Get flags + +; Get the filename from stack and parse it. Bail out if is not ok + + jsr popax ; Get name + + + BRK_TELEMON XOPEN + + ; jsr fnparse ; Parse it + ;tax + ;bne oserror ; Bail out if problem with name + +; Get a free file handle and remember it in tmp2 + + ; jsr freefd + ;lda #EMFILE ; Load error code + ;bcs seterrno ; Jump in case of errors + ;stx tmp2 +; + + + rts +.endproc + + \ No newline at end of file diff --git a/libsrc/telemon30/_read.s b/libsrc/telemon30/_read.s new file mode 100644 index 000000000..8f7a20a58 --- /dev/null +++ b/libsrc/telemon30/_read.s @@ -0,0 +1,31 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; + +; + + .export _read + .import popax + .importzp ptr1, ptr2, ptr3, tmp1, tmp2 + + .include "telemon30.inc" +; int read (int fd, void* buf, unsigned count); + +.proc _read + ;jsr popax ; fp pointer don't care + sta tmp1 ; count + stx tmp2 ; count + jsr popax ; get buf + ;lda #$00 + ;ldx #$a0 + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + lda tmp1 ; + ldy tmp2 ; + BRK_TELEMON XFREAD + + rts + +.endproc + + diff --git a/libsrc/telemon30/_scrsize.s b/libsrc/telemon30/_scrsize.s new file mode 100644 index 000000000..a929f97b1 --- /dev/null +++ b/libsrc/telemon30/_scrsize.s @@ -0,0 +1,19 @@ +; +; 2003-04-13, Ullrich von Bassewitz +; 2013-07-16, Greg King +; +; Screen size variables +; + + .export screensize + .include "telemon30.inc" + +.proc screensize + + ldx #SCREEN_XSIZE + ldy #SCREEN_YSIZE + rts + +.endproc + + diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s new file mode 100644 index 000000000..1b75c2b18 --- /dev/null +++ b/libsrc/telemon30/ch376.s @@ -0,0 +1,200 @@ + .export _ch376_set_file_name + .export _ch376_file_open + .export _ch376_ic_get_version + .export _ch376_reset + .export _ch376_check_exist + .export _ch376_disk_mount + + .import popax + .importzp sp,tmp2,tmp3,tmp1 + .include "telemon30.inc" + +; CODE FOR CH376_SET_USB_MODE ************************************************* + +CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY := $06 + +CH376_USB_INT_DISK_READ := $1d +CH376_USB_INT_SUCCESS := $14 +CH376_ERR_MISS_FILE := $42 + +CH376_DATA :=$340 +CH376_COMMAND :=$341 + +CH376_GET_IC_VER := $01 +CH376_SET_BAUDRATE := $02 +CH376_GET_ENTER_SLEEP := $03 +CH376_RESET_ALL := $05 +CH376_CHECK_EXIST := $06 +CH376_GET_FILE_SIZE := $0C +CH376_SET_USB_MODE := $15 +CH376_GET_STATUS := $22 +CH376_RD_USB_DATA0 := $27 +CH376_SET_FILE_NAME := $2f +CH376_DISK_CONNECT := $30 ; check the disk connection status +CH376_DISK_MOUNT := $31 +CH376_FILE_OPEN := $32 +CH376_FILE_ENUM_GO := $33 +CH376_FILE_CLOSE := $36 +CH376_BYTE_READ := $3A +CH376_BYTE_RD_GO := $3b +CH376_BYTE_WRITE := $3C +CH376_DISK_CAPACITY := $3E +CH376_DISK_RD_GO := $55 + + + +; void ch376_set_file_name(char *filename) +.proc _ch376_set_file_name + sta tmp1 + stx tmp1+1 + lda #CH376_SET_FILE_NAME ;$2f + sta CH376_COMMAND + ldy #0 +loop: + lda (tmp1),y ; replace by bufnom + beq end ; we reached 0 value + sta CH376_DATA + iny + cpy #13 ; because we don't manage longfilename shortname =11 + bne loop +end: + sta CH376_DATA + rts +.endproc + +; void _ch376_file_open(); + +.proc _ch376_file_open + lda #CH376_FILE_OPEN ; $32 + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc + + ;CMD_GET_FILE_SIZE + +.proc _ch376_get_file_size + lda #CH376_GET_FILE_SIZE + sta CH376_COMMAND + lda #$68 + sta CH376_DATA + ; store file leng + lda CH376_DATA + sta tmp1 + lda CH376_DATA + sta tmp1+1 + lda CH376_DATA + sta tmp2 + lda CH376_DATA + sta tmp2+1 + rts +.endproc + +; void ch376_reset(); + +.proc _ch376_reset + lda #CH376_RESET_ALL ; 5 + sta CH376_COMMAND + ; waiting + ldy #0 + ldx #0 +loop: + nop + inx + bne loop + iny + bne loop + rts +.endproc + +; char ch376_check_exist(char value); + +.proc _ch376_check_exist + sta tmp1 + lda #CH376_CHECK_EXIST ; + sta CH376_COMMAND + lda tmp1 + sta CH376_DATA + lda CH376_DATA + rts +.endproc + +; char ch376_ic_get_version(void) +.proc _ch376_ic_get_version + lda #CH376_GET_IC_VER + sta CH376_COMMAND + lda CH376_DATA + rts +.endproc + +; void ch376_set_usb_mode(char mode) + +.proc _ch376_set_usb_mode +; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY + sta tmp1 + lda #CH376_SET_USB_MODE ; $15 + sta CH376_COMMAND + lda tmp1 + sta CH376_DATA + rts +.endproc + + +; void ch376_set_bytes_write(int value); +.proc _ch376_set_bytes_write + sta tmp1 + stx tmp1+1 + ldx #CH376_BYTE_WRITE + stx CH376_COMMAND + lda tmp1 + sta CH376_DATA + lda tmp1+1 + sta CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +.proc _ch376_set_bytes_read + ldx #CH376_BYTE_READ + stx CH376_COMMAND + sta CH376_DATA + sty CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +; char ch376_disk_mount(); +.proc _ch376_disk_mount + lda #CH376_DISK_MOUNT ; $31 + sta CH376_COMMAND + jsr _ch376_wait_response + ; if we read data value, we have then length of the volume name + rts +.endproc + + +; char ch376_wait_response(); +.proc _ch376_wait_response +; 1 return 1 if usb controller does not respond +; else A contains answer of the controller + ldy #$ff +loop3: + ldx #$ff ; merci de laisser une valeur importante car parfois en mode non debug, le controleur ne répond pas tout de suite +loop: + lda CH376_COMMAND + and #%10000000 + cmp #128 + bne no_error + dex + bne loop + dey + bne loop3 + ; error is here + rts +no_error: + lda #CH376_GET_STATUS + sta CH376_COMMAND + lda CH376_DATA + rts +.endproc + diff --git a/libsrc/telemon30/crt0.s b/libsrc/telemon30/crt0.s new file mode 100644 index 000000000..72bad5f24 --- /dev/null +++ b/libsrc/telemon30/crt0.s @@ -0,0 +1,101 @@ +; +; Startup code for cc65 (Oric version) +; +; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org> +; 2016-03-18, Greg King +; + + .export _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + + .import initlib, donelib + .import callmain, zerobss + .import __MAIN_START__, __MAIN_SIZE__ + + .include "zeropage.inc" + .include "telemon30.inc" + +; ------------------------------------------------------------------------ +; Place the startup code in a special segment. + +.segment "STARTUP" + + tsx + stx spsave ; Save system stk ptr + +; Save space by putting some of the start-up code in a segment +; that will be re-used. + + jsr init + +; Clear the BSS variables (after the constructors have been run). + + jsr zerobss + +; Push the command-line arguments; and, call main(). + + jsr callmain + +; Call the module destructors. This is also the exit() entry. + +_exit: jsr donelib + +; Restore the system stuff. + + ldx spsave + txs +; lda stsave + ; sta STATUS + +; Copy back the zero-page stuff. + + ldx #zpspace - 1 +L2: lda zpsave,x + sta sp,x + dex + bpl L2 + +; Back to BASIC. + + rts + +; ------------------------------------------------------------------------ +; Put this code in a place that will be re-used by BSS, the heap, +; and the C stack. + +.segment "ONCE" + +; Save the zero-page area that we're about to use. + +init: ldx #zpspace - 1 +L1: lda sp,x + sta zpsave,x + dex + bpl L1 + +; Currently, color isn't supported on the text screen. +; Unprotect screen columns 0 and 1 (where each line's color codes would sit). + + ; lda STATUS + ; sta stsave + ; and #%11011111 + ; sta STATUS + +; Set up the C stack. + + lda #<(__MAIN_START__ + __MAIN_SIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__) + sta sp + stx sp+1 ; Set argument stack ptr + +; Call the module constructors. + + jmp initlib + +; ------------------------------------------------------------------------ + +.segment "INIT" + +spsave: .res 1 +stsave: .res 1 +zpsave: .res zpspace diff --git a/libsrc/telemon30/ctype.s b/libsrc/telemon30/ctype.s new file mode 100644 index 000000000..79edafbb2 --- /dev/null +++ b/libsrc/telemon30/ctype.s @@ -0,0 +1,299 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; Character specification table. +; + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it were'nt for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). +; +; * It is highly portable. The only unportable part is the table itself, +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. +; +; +; Bit assignments: +; +; 0 - Lower case char +; 1 - Upper case char +; 2 - Numeric digit +; 3 - Hex digit (both, lower and upper) +; 4 - Control character +; 5 - The space character itself +; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v') +; 7 - Space or tab character + + .export __ctype + +__ctype: + .byte $10 ; 0/00 ___ctrl_@___ + .byte $10 ; 1/01 ___ctrl_A___ + .byte $10 ; 2/02 ___ctrl_B___ + .byte $10 ; 3/03 ___ctrl_C___ + .byte $10 ; 4/04 ___ctrl_D___ + .byte $10 ; 5/05 ___ctrl_E___ + .byte $10 ; 6/06 ___ctrl_F___ + .byte $10 ; 7/07 ___ctrl_G___ + .byte $10 ; 8/08 ___ctrl_H___ + .byte $D0 ; 9/09 ___ctrl_I___ + .byte $50 ; 10/0a ___ctrl_J___ + .byte $50 ; 11/0b ___ctrl_K___ + .byte $50 ; 12/0c ___ctrl_L___ + .byte $50 ; 13/0d ___ctrl_M___ + .byte $10 ; 14/0e ___ctrl_N___ + .byte $10 ; 15/0f ___ctrl_O___ + .byte $10 ; 16/10 ___ctrl_P___ + .byte $10 ; 17/11 ___ctrl_Q___ + .byte $10 ; 18/12 ___ctrl_R___ + .byte $10 ; 19/13 ___ctrl_S___ + .byte $10 ; 20/14 ___ctrl_T___ + .byte $10 ; 21/15 ___ctrl_U___ + .byte $10 ; 22/16 ___ctrl_V___ + .byte $10 ; 23/17 ___ctrl_W___ + .byte $10 ; 24/18 ___ctrl_X___ + .byte $10 ; 25/19 ___ctrl_Y___ + .byte $10 ; 26/1a ___ctrl_Z___ + .byte $10 ; 27/1b ___ctrl_[___ + .byte $10 ; 28/1c ___ctrl_\___ + .byte $10 ; 29/1d ___ctrl_]___ + .byte $10 ; 30/1e ___ctrl_^___ + .byte $10 ; 31/1f ___ctrl_____ + .byte $A0 ; 32/20 ___SPACE___ + .byte $00 ; 33/21 _____!_____ + .byte $00 ; 34/22 _____"_____ + .byte $00 ; 35/23 _____#_____ + .byte $00 ; 36/24 _____$_____ + .byte $00 ; 37/25 _____%_____ + .byte $00 ; 38/26 _____&_____ + .byte $00 ; 39/27 _____'_____ + .byte $00 ; 40/28 _____(_____ + .byte $00 ; 41/29 _____)_____ + .byte $00 ; 42/2a _____*_____ + .byte $00 ; 43/2b _____+_____ + .byte $00 ; 44/2c _____,_____ + .byte $00 ; 45/2d _____-_____ + .byte $00 ; 46/2e _____._____ + .byte $00 ; 47/2f _____/_____ + .byte $0C ; 48/30 _____0_____ + .byte $0C ; 49/31 _____1_____ + .byte $0C ; 50/32 _____2_____ + .byte $0C ; 51/33 _____3_____ + .byte $0C ; 52/34 _____4_____ + .byte $0C ; 53/35 _____5_____ + .byte $0C ; 54/36 _____6_____ + .byte $0C ; 55/37 _____7_____ + .byte $0C ; 56/38 _____8_____ + .byte $0C ; 57/39 _____9_____ + .byte $00 ; 58/3a _____:_____ + .byte $00 ; 59/3b _____;_____ + .byte $00 ; 60/3c _____<_____ + .byte $00 ; 61/3d _____=_____ + .byte $00 ; 62/3e _____>_____ + .byte $00 ; 63/3f _____?_____ + + .byte $00 ; 64/40 _____@_____ + .byte $0A ; 65/41 _____A_____ + .byte $0A ; 66/42 _____B_____ + .byte $0A ; 67/43 _____C_____ + .byte $0A ; 68/44 _____D_____ + .byte $0A ; 69/45 _____E_____ + .byte $0A ; 70/46 _____F_____ + .byte $02 ; 71/47 _____G_____ + .byte $02 ; 72/48 _____H_____ + .byte $02 ; 73/49 _____I_____ + .byte $02 ; 74/4a _____J_____ + .byte $02 ; 75/4b _____K_____ + .byte $02 ; 76/4c _____L_____ + .byte $02 ; 77/4d _____M_____ + .byte $02 ; 78/4e _____N_____ + .byte $02 ; 79/4f _____O_____ + .byte $02 ; 80/50 _____P_____ + .byte $02 ; 81/51 _____Q_____ + .byte $02 ; 82/52 _____R_____ + .byte $02 ; 83/53 _____S_____ + .byte $02 ; 84/54 _____T_____ + .byte $02 ; 85/55 _____U_____ + .byte $02 ; 86/56 _____V_____ + .byte $02 ; 87/57 _____W_____ + .byte $02 ; 88/58 _____X_____ + .byte $02 ; 89/59 _____Y_____ + .byte $02 ; 90/5a _____Z_____ + .byte $00 ; 91/5b _____[_____ + .byte $00 ; 92/5c _____\_____ + .byte $00 ; 93/5d _____]_____ + .byte $00 ; 94/5e _____^_____ + .byte $00 ; 95/5f _UNDERLINE_ + .byte $00 ; 96/60 ___grave___ + .byte $09 ; 97/61 _____a_____ + .byte $09 ; 98/62 _____b_____ + .byte $09 ; 99/63 _____c_____ + .byte $09 ; 100/64 _____d_____ + .byte $09 ; 101/65 _____e_____ + .byte $09 ; 102/66 _____f_____ + .byte $01 ; 103/67 _____g_____ + .byte $01 ; 104/68 _____h_____ + .byte $01 ; 105/69 _____i_____ + .byte $01 ; 106/6a _____j_____ + .byte $01 ; 107/6b _____k_____ + .byte $01 ; 108/6c _____l_____ + .byte $01 ; 109/6d _____m_____ + .byte $01 ; 110/6e _____n_____ + .byte $01 ; 111/6f _____o_____ + .byte $01 ; 112/70 _____p_____ + .byte $01 ; 113/71 _____q_____ + .byte $01 ; 114/72 _____r_____ + .byte $01 ; 115/73 _____s_____ + .byte $01 ; 116/74 _____t_____ + .byte $01 ; 117/75 _____u_____ + .byte $01 ; 118/76 _____v_____ + .byte $01 ; 119/77 _____w_____ + .byte $01 ; 120/78 _____x_____ + .byte $01 ; 121/79 _____y_____ + .byte $01 ; 122/7a _____z_____ + .byte $00 ; 123/7b _____{_____ + .byte $00 ; 124/7c _____|_____ + .byte $00 ; 125/7d _____}_____ + .byte $00 ; 126/7e _____~_____ + .byte $40 ; 127/7f ____DEL____ + + .byte $00 ; 128/80 ___________ + .byte $00 ; 129/81 ___________ + .byte $00 ; 130/82 ___________ + .byte $00 ; 131/83 ___________ + .byte $00 ; 132/84 ___________ + .byte $00 ; 133/85 ___________ + .byte $00 ; 134/86 ___________ + .byte $00 ; 135/87 ___________ + .byte $00 ; 136/88 ___________ + .byte $00 ; 137/89 ___________ + .byte $00 ; 138/8a ___________ + .byte $00 ; 139/8b ___________ + .byte $00 ; 140/8c ___________ + .byte $00 ; 141/8d ___________ + .byte $00 ; 142/8e ___________ + .byte $00 ; 143/8f ___________ + .byte $00 ; 144/90 ___________ + .byte $00 ; 145/91 ___________ + .byte $00 ; 146/92 ___________ + .byte $10 ; 147/93 ___________ + .byte $00 ; 148/94 ___________ + .byte $00 ; 149/95 ___________ + .byte $00 ; 150/96 ___________ + .byte $00 ; 151/97 ___________ + .byte $00 ; 152/98 ___________ + .byte $00 ; 153/99 ___________ + .byte $00 ; 154/9a ___________ + .byte $00 ; 155/9b ___________ + .byte $00 ; 156/9c ___________ + .byte $00 ; 157/9d ___________ + .byte $00 ; 158/9e ___________ + .byte $00 ; 159/9f ___________ + + .byte $00 ; 160/a0 ___________ + .byte $00 ; 161/a1 ___________ + .byte $00 ; 162/a2 ___________ + .byte $00 ; 163/a3 ___________ + .byte $00 ; 164/a4 ___________ + .byte $00 ; 165/a5 ___________ + .byte $00 ; 166/a6 ___________ + .byte $00 ; 167/a7 ___________ + .byte $00 ; 168/a8 ___________ + .byte $00 ; 169/a9 ___________ + .byte $00 ; 170/aa ___________ + .byte $00 ; 171/ab ___________ + .byte $00 ; 172/ac ___________ + .byte $00 ; 173/ad ___________ + .byte $00 ; 174/ae ___________ + .byte $00 ; 175/af ___________ + .byte $00 ; 176/b0 ___________ + .byte $00 ; 177/b1 ___________ + .byte $00 ; 178/b2 ___________ + .byte $00 ; 179/b3 ___________ + .byte $00 ; 180/b4 ___________ + .byte $00 ; 181/b5 ___________ + .byte $00 ; 182/b6 ___________ + .byte $00 ; 183/b7 ___________ + .byte $00 ; 184/b8 ___________ + .byte $00 ; 185/b9 ___________ + .byte $00 ; 186/ba ___________ + .byte $00 ; 187/bb ___________ + .byte $00 ; 188/bc ___________ + .byte $00 ; 189/bd ___________ + .byte $00 ; 190/be ___________ + .byte $00 ; 191/bf ___________ + + .byte $02 ; 192/c0 ___________ + .byte $02 ; 193/c1 ___________ + .byte $02 ; 194/c2 ___________ + .byte $02 ; 195/c3 ___________ + .byte $02 ; 196/c4 ___________ + .byte $02 ; 197/c5 ___________ + .byte $02 ; 198/c6 ___________ + .byte $02 ; 199/c7 ___________ + .byte $02 ; 200/c8 ___________ + .byte $02 ; 201/c9 ___________ + .byte $02 ; 202/ca ___________ + .byte $02 ; 203/cb ___________ + .byte $02 ; 204/cc ___________ + .byte $02 ; 205/cd ___________ + .byte $02 ; 206/ce ___________ + .byte $02 ; 207/cf ___________ + .byte $02 ; 208/d0 ___________ + .byte $02 ; 209/d1 ___________ + .byte $02 ; 210/d2 ___________ + .byte $02 ; 211/d3 ___________ + .byte $02 ; 212/d4 ___________ + .byte $02 ; 213/d5 ___________ + .byte $02 ; 214/d6 ___________ + .byte $02 ; 215/d7 ___________ + .byte $02 ; 216/d8 ___________ + .byte $02 ; 217/d9 ___________ + .byte $02 ; 218/da ___________ + .byte $02 ; 219/db ___________ + .byte $02 ; 220/dc ___________ + .byte $02 ; 221/dd ___________ + .byte $02 ; 222/de ___________ + .byte $00 ; 223/df ___________ + .byte $01 ; 224/e0 ___________ + .byte $01 ; 225/e1 ___________ + .byte $01 ; 226/e2 ___________ + .byte $01 ; 227/e3 ___________ + .byte $01 ; 228/e4 ___________ + .byte $01 ; 229/e5 ___________ + .byte $01 ; 230/e6 ___________ + .byte $01 ; 231/e7 ___________ + .byte $01 ; 232/e8 ___________ + .byte $01 ; 233/e9 ___________ + .byte $01 ; 234/ea ___________ + .byte $01 ; 235/eb ___________ + .byte $01 ; 236/ec ___________ + .byte $01 ; 237/ed ___________ + .byte $01 ; 238/ee ___________ + .byte $01 ; 239/ef ___________ + .byte $01 ; 240/f0 ___________ + .byte $01 ; 241/f1 ___________ + .byte $01 ; 242/f2 ___________ + .byte $01 ; 243/f3 ___________ + .byte $01 ; 244/f4 ___________ + .byte $01 ; 245/f5 ___________ + .byte $01 ; 246/f6 ___________ + .byte $01 ; 247/f7 ___________ + .byte $01 ; 248/f8 ___________ + .byte $01 ; 249/f9 ___________ + .byte $01 ; 250/fa ___________ + .byte $01 ; 251/fb ___________ + .byte $01 ; 252/fc ___________ + .byte $01 ; 253/fd ___________ + .byte $01 ; 254/fe ___________ + .byte $00 ; 255/ff ___________ + diff --git a/libsrc/telemon30/graphics.s b/libsrc/telemon30/graphics.s new file mode 100644 index 000000000..1d0beefa5 --- /dev/null +++ b/libsrc/telemon30/graphics.s @@ -0,0 +1,51 @@ + .export _paper,_hires,_text,_circle,_curset, _switchOffCursor + .importzp sp,tmp2,tmp3,tmp1 + + .include "telemon30.inc" + +.proc _paper + ldx #0 ; First window + ; A contains the paper + BRK_TELEMON XPAPER + rts +.endproc + +; XINK is bugged, it corrupt memory : removing from export +.proc _ink + ldx #0 ; First window + ; A contains the ink + BRK_TELEMON XINK + rts +.endproc + +; can be optimized with a macro +.proc _hires + BRK_TELEMON XHIRES + rts +.endproc + +.proc _text + BRK_TELEMON XTEXT + rts +.endproc + +.proc _curset + sta HRSX + sty HRSY + BRK_TELEMON XCURSE + rts +.endproc + +.proc _circle + sta HRS1 + BRK_TELEMON XCIRCL + rts +.endproc + +.proc _switchOffCursor + ldx #0 + BRK_TELEMON XCOSCR + rts +.endproc + + diff --git a/libsrc/telemon30/keyboard.s b/libsrc/telemon30/keyboard.s new file mode 100644 index 000000000..974f841e6 --- /dev/null +++ b/libsrc/telemon30/keyboard.s @@ -0,0 +1,13 @@ + .export _key + .importzp sp,tmp2,tmp3,tmp1 + + .include "telemon30.inc" + + +; char key(void); + +.proc _key + BRK_TELEMON XRDW0 ; read keyboard + rts +.endproc + diff --git a/libsrc/telemon30/mainargs.s b/libsrc/telemon30/mainargs.s new file mode 100644 index 000000000..452d0d6d6 --- /dev/null +++ b/libsrc/telemon30/mainargs.s @@ -0,0 +1,137 @@ +; +; 2003-03-07, Ullrich von Bassewitz +; 2011-01-28, Stefan Haubenthal +; 2014-09-10, Greg King +; +; Set up arguments for main +; + + .constructor initmainargs, 24 + .import __argc, __argv + .import ptr1 + .include "telemon30.inc" + .macpack generic + +MAXARGS = 10 ; Maximum number of arguments allowed + + + + + +; Assume that the program was loaded, a moment ago, by the traditional LOAD +; statement. Save the "most-recent filename" as argument #0. +initmainargs: + + ldx #0 ; Limit the length + ; lda #0 ; The terminating NUL character + ; beq L1 ; Branch always +L0: lda BUFEDT,x + beq L3 + cmp #' ' + bne L1 + lda #0 + beq L3 +L1: sta name,x + inx + cpx #FNAME_LEN + bne L0 + lda #0 +L3: + sta name,x + inc __argc ; argc always is equal to, at least, 1 + + + + + + ldy #1 * 2 ; Point to second argv slot + +next: lda BUFEDT,x + beq done ; End of line reached + inx + cmp #' ' ; Skip leading spaces + beq next + + + + + +found: cmp #'"' ; Is the argument quoted? + beq setterm ; Jump if so + dex ; Reset pointer to first argument character + + + lda #' ' ; A space ends the argument +setterm:sta term ; Set end of argument marker + +; Now, store a pointer, to the argument, into the next slot. + + txa ; Get low byte + clc + adc #<BUFEDT + bcc L4 + inc L5+1 +L4: + ;add #<args + sta argv,y ; argv[y]=&arg +L5: + lda #>BUFEDT + ;adc #>args + sta argv+1,y + iny + iny + inc __argc ; Found another arg + +; Search for the end of the argument + + + +argloop:lda BUFEDT,x + beq done + inx + cmp term + bne argloop + +; We've found the end of the argument. X points one character behind it, and +; A contains the terminating character. To make the argument a valid C string, +; replace the terminating character by a zero. + + lda #0 + sta BUFEDT-1,x + +; Check if the maximum number of command line arguments is reached. If not, +; parse the next one. + + lda __argc ; Get low byte of argument count + cmp #MAXARGS ; Maximum number of arguments reached? + bcc next ; Parse next one if not + + + + +done: lda #<argv + ldx #>argv + sta __argv + stx __argv + 1 + rts + + + +.segment "INIT" + +term: .res 1 + + +.data + +name: .res FNAME_LEN + 1 +args: .res SCREEN_XSIZE * 2 - 1 + +ptr_current: + .res 2 +param_found: + .res 1 +; char* argv[MAXARGS+1]={name}; +argv: + .addr name + .res MAXARGS * 2 diff --git a/libsrc/telemon30/mym.s b/libsrc/telemon30/mym.s new file mode 100644 index 000000000..f387f9d64 --- /dev/null +++ b/libsrc/telemon30/mym.s @@ -0,0 +1,626 @@ + .export _Mym_MusicStart + .importzp sp,tmp2,tmp3,tmp1,ptr1 + + .include "telemon30.inc" + +; To check: AYC +; http://cpcwiki.eu/index.php/AYC + + + + +_DecodedByte :=$D0 ; Byte being currently decoded from the MYM stream +_DecodeBitCounter :=$D2 ; Number of bits we can read in the current byte +_DecodedResult :=$D3 ; What is returned by the 'read bits' function +_CurrentAYRegister :=$D4 ; Contains the number of the register being decoded +_RegisterBufferHigh :=$D5 ; Points to the high byte of the decoded register buffer, increment to move to the next register +_BufferFrameOffset :=$D6 ; From 0 to 127, used when filling the decoded register buffer +_MusicResetCounter :=$D7 ; 2 bytes Contains the number of rows to play before reseting +_CurrentFrame :=$D9 ; From 0 to 255 and then cycles... the index of the frame to play this vbl +_PlayerVbl :=$DA +_FrameLoadBalancer :=$DB ; We depack a new frame every 9 VBLs, this way the 14 registers are evenly depacked over 128 frames + + +VIA_1 := $30f +VIA_2 := $30c + +_MusicData := $c000 + +; mym(char *buf) + + + + +; +; Current PSG values during unpacking +; + + +.proc _Mym_MusicStart + + ; The two first bytes of the MYM music is the number of rows in the music + ; We decrement that at each frame, and when we reach zero, time to start again. + sta ptr1 + stx ptr1+1 + + ldy #0 + lda (ptr1),y + sta _MusicResetCounter+0 + iny + lda (ptr1),y + tax + inx + stx _MusicResetCounter+1 + + ;ldx _MusicData+0 + ;stx _MusicResetCounter+0 + ;ldx _MusicData+1 + ;inx + ;stx _MusicResetCounter+1 + + + ; Initialize the read bit counter + ldy #2 ; should be useless because we can do iny which earn 1 byte + + lda ptr1 + clc + adc #2 + bcc next20 + inc ptr1+1 + lda ptr1+1 + sta __auto_music_ptr+2 +next20: + sta ptr1 + sta __auto_music_ptr+1 + + + + ;lda #<(_MusicData+2) + ;sta __auto_music_ptr+1 + ;lda #>(_MusicData+2) + ;sta __auto_music_ptr+2 + + lda #1 + sta _DecodeBitCounter + + ; Clear all data + lda #0 + sta _DecodedResult + sta _DecodedByte + sta _PlayerVbl + sta _PlayerRegCurrentValue + sta _BufferFrameOffset + sta _PlayerCount + sta _CurrentAYRegister + sta _CurrentFrame + + ldx #14 +loop_init: + dex + sta _PlayerRegValues,x + bne loop_init + + + ; + ; Unpack the 128 first register frames + ; + + lda #>_PlayerBuffer + sta _RegisterBufferHigh + + ldx #0 +unpack_block_loop: + stx _CurrentAYRegister + + ; Unpack that register + jsr _PlayerUnpackRegister2 + + ; Next register + ldx _CurrentAYRegister + inx + cpx #14 + bne unpack_block_loop + + + lda #128 + sta _PlayerVbl+0 + + lda #0 + sta _PlayerCount + sta _CurrentAYRegister + sta _CurrentFrame + + lda #9 + sta _FrameLoadBalancer + + lda #1 + sta _MusicPlaying + + ; + ; Install the IRQ + ; + php + sei + lda #<_Mym_PlayFrame + sta _InterruptCallBack_3+1 + lda #>_Mym_PlayFrame + sta _InterruptCallBack_3+2 + plp + + rts + + +_Mym_MusicStop: + + ; Indicate the main code that the music is finished + lda #0 + sta _MusicPlaying + + ; Disable the IRQ so it does not conflict or cause weird things + php + sei + lda #<_DoNothing + sta _InterruptCallBack_3+1 + lda #>_DoNothing + sta _InterruptCallBack_3+2 + plp + + ; Cut the sound so it does not sounds like a dying cat + + ; y=register number + ; x=value to write + ldy #7 ; Control register + ldx #$FF + jsr _PsgPlayRegister + + ldy #8 ; Volume A + ldx #0 + jsr _PsgPlayRegister + + ldy #9 ; Volume B + ldx #0 + jsr _PsgPlayRegister + + ldy #10 ; Volume C + ldx #0 + jsr _PsgPlayRegister + rts + + +_Mym_PlayFrame: + + ; + ; Check for end of music + ; CountZero: $81,$0d + dec _MusicResetCounter+0 + bne music_contines + dec _MusicResetCounter+1 + bne music_contines + +music_resets: + jmp _Mym_MusicStop + +music_contines: + + ; + ; Play a frame of 14 registers + ; + + lda _CurrentFrame + sta _auto_psg_play_read+1 + lda #>_PlayerBuffer + sta _auto_psg_play_read+2 + + ldy #0 +register_loop: + +_auto_psg_play_read: + ldx _PlayerBuffer + + ; y=register number + ; x=value to write + jsr _PsgPlayRegister + + inc _auto_psg_play_read+2 + iny + cpy #14 + bne register_loop + + + + inc _CurrentFrame + inc _PlayerCount + + lda _CurrentAYRegister + cmp #14 + bcs end_reg + + + dec _FrameLoadBalancer + bne end + + jsr _PlayerUnpackRegister + inc _CurrentAYRegister + lda #9 + sta _FrameLoadBalancer +end: + rts + + +end_reg: + + lda _PlayerCount + cmp #128 + bcc skip2 + + lda #0 + sta _CurrentAYRegister + sta _PlayerCount + lda #9 + sta _FrameLoadBalancer + + clc + lda _PlayerVbl+0 + adc #128 + sta _PlayerVbl+0 +skip2: + + + rts + + + +; y=register number +; x=value to write +_PsgPlayRegister: + + sty VIA_1 + txa + + pha + lda VIA_2 + ora #$EE ; $EE 238 11101110 + sta VIA_2 + + and #$11 ; $11 17 00010001 + ora #$CC ; $CC 204 11001100 + sta VIA_2 + + tax + pla + sta VIA_1 + txa + ora #$EC ; $EC 236 11101100 + sta VIA_2 + + and #$11 ; $11 17 00010001 + ora #$CC ; $CC 204 11001100 + sta VIA_2 + + rts + + + + +; +; Initialise X with the number of bits to read +; Y is not modifier +; +_ReadBits: + + lda #0 + sta _DecodedResult + + ; Will iterate X times (number of bits to read) +loop_read_bits: + + dec _DecodeBitCounter + beq get_next_byte + +shift_bit: + asl _DecodedByte + rol _DecodedResult + + dex + bne loop_read_bits + rts + +get_next_byte: + ; reset mask + lda #8 + sta _DecodeBitCounter + + ; fetch a new byte, and increment the adress. +__auto_music_ptr: + lda _MusicData+2 + sta _DecodedByte + + inc __auto_music_ptr+1 + bne shift_bit + inc __auto_music_ptr+2 + jmp shift_bit + + + + + +_PlayerUnpackRegister: + lda #>_PlayerBuffer + clc + adc _CurrentAYRegister + sta _RegisterBufferHigh +_PlayerUnpackRegister2: + ; + ; Init register bit count and current value + ; + ldx _CurrentAYRegister + lda _PlayerRegValues,x + sta _PlayerRegCurrentValue + + + ; + ; Check if it's packed or not + ; and call adequate routine... + ; + ldx #1 + jsr _ReadBits + ldx _DecodedResult + bne DecompressFragment + + +UnchangedFragment: + + ; + ; No change at all, just repeat '_PlayerRegCurrentValue' 128 times + ; + lda _RegisterBufferHigh ; highpart of buffer adress + register number + sta __auto_copy_unchanged_write+2 + + ldx #128 ; 128 iterations + lda _PlayerRegCurrentValue ; Value to write + + ldy _PlayerVbl + +repeat_loop: +__auto_copy_unchanged_write: + sta _PlayerBuffer,y + iny + dex + bne repeat_loop + + + jmp player_main_return + + +player_main_return: + ; Write back register current value + ldx _CurrentAYRegister + lda _PlayerRegCurrentValue + sta _PlayerRegValues,x + + ; Move to the next register buffer + inc _RegisterBufferHigh + rts + + + + +DecompressFragment: + lda _PlayerVbl ; Either 0 or 128 at this point else we have a problem... + sta _BufferFrameOffset + +decompressFragmentLoop: + +player_copy_packed_loop: + ; Check packing method + ldx #1 + jsr _ReadBits + + ldx _DecodedResult + bne PlayerNotCopyLast + +UnchangedRegister: + + ; We just copy the current value 128 times + lda _RegisterBufferHigh ; highpart of buffer adress + register number + sta __auto_player_copy_last+2 + + ldx _BufferFrameOffset ; Value between 00 and 7f + lda _PlayerRegCurrentValue ; Value to copy +__auto_player_copy_last: + sta _PlayerBuffer,x + + inc _BufferFrameOffset + + + +player_return: + + ; Check end of loop + lda _BufferFrameOffset + and #127 + bne decompressFragmentLoop + + jmp player_main_return + + +PlayerNotCopyLast: + ; Check packing method + ldx #1 + jsr _ReadBits + + ldx _DecodedResult + beq DecompressWithOffset + +ReadNewRegisterValue: + ; Read new register value (variable bit count) + ldx _CurrentAYRegister + lda _PlayerRegBits,x + tax + jsr _ReadBits + ldx _DecodedResult + stx _PlayerRegCurrentValue + + ; Copy to stream + lda _RegisterBufferHigh ; highpart of buffer adress + register number + sta __auto_player_read_new+2 + + ldx _BufferFrameOffset ; Value between 00 and 7f + lda _PlayerRegCurrentValue ; New value to write +__auto_player_read_new: + sta _PlayerBuffer,x + + inc _BufferFrameOffset + jmp player_return + + + + +DecompressWithOffset: + + ; Read Offset (0 to 127) + ldx #7 + jsr _ReadBits + + lda _RegisterBufferHigh ; highpart of buffer adress + register number + sta __auto_write+2 ; Write adress + sta __auto_read+2 ; Read adress + + ; Compute wrap around offset... + lda _BufferFrameOffset ; between 0 and 255 + clc + adc _DecodedResult ; + Offset Between 00 and 7f + sec + sbc #128 ; -128 + tay + + ; Read count (7 bits) + ldx #7 + jsr _ReadBits + + inc _DecodedResult ; 1 to 129 + + + ldx _BufferFrameOffset + +player_copy_offset_loop: + +__auto_read: + lda _PlayerBuffer,y ; Y for reading + iny + +__auto_write: + sta _PlayerBuffer,x ; X for writing + + inx + dec _DecodedResult + bne player_copy_offset_loop + + stx _BufferFrameOffset + sta _PlayerRegCurrentValue + + jmp player_return + + + + +; +; Size in bits of each PSG register +; +_PlayerRegBits: + ; Chanel A Frequency + .byt 8 + .byt 4 + + ; Chanel B Frequency + .byt 8 + .byt 4 + + ; Chanel C Frequency + .byt 8 + .byt 4 + + ; Chanel sound generator + .byt 5 + + ; select + .byt 8 + + ; Volume A,B,C + .byt 5 + .byt 5 + .byt 5 + + ; Wave period + .byt 8 + .byt 8 + + ; Wave form + .byt 8 + +_PlayerCount: + .res 1,0 ; must be equal to 0 +_MusicPlaying: + .res 1,0 ; must be equal to 0 + + +_PlayerRegValues: +_RegisterChanAFrequency: + ; Chanel A Frequency + .res 1,8 + .res 1,4 + +_RegisterChanBFrequency: + ; Chanel B Frequency + .res 1,8 + .res 1,4 + +_RegisterChanCFrequency: + ; Chanel C Frequency + .res 1,8 + .res 1,4 + +_RegisterChanNoiseFrequency: + ; Chanel sound generator + .res 1,5 + + ; select + .res 1,8 + + ; Volume A,B,C +_RegisterChanAVolume: + .res 1,5 +_RegisterChanBVolume: + .res 1,5 +_RegisterChanCVolume: + .res 1,5 + + ; Wave period + .res 1,8 + .res 1,8 + + ; Wave form + .res 1,8 + +_PlayerRegCurrentValue: + .res 1,0 +_DoNothing: + rts + +_InterruptCallBack_3: ; Used by the music player + jsr _DoNothing ; Transformed to "jsr _Mym_PlayFrame" -> 12 cycles + +; jsr MiniScrollLoading ; -> 338 cycles + + pla + tay + pla + tax + pla + + rti +_PlayerBuffer: + .res 256*14 ; About 3.5 kilobytes somewhere in memory, we put the music file in overlay memory + +.endproc + diff --git a/libsrc/telemon30/orixhdr.s b/libsrc/telemon30/orixhdr.s new file mode 100644 index 000000000..8744e86b0 --- /dev/null +++ b/libsrc/telemon30/orixhdr.s @@ -0,0 +1,36 @@ +; +; Based on code by Debrune Jérôme <jede@oric.org> +; 2016-03-17, Greg King +; + + ; The following symbol is used by the linker config. file + ; to force this module to be included into the output file. + .export __ORIXHDR__:abs = 1 + + ; These symbols, also, come from the configuration file. + .import __AUTORUN__, __PROGFLAG__ + .import __BASHEAD_START__, __MAIN_LAST__ + + +; ------------------------------------------------------------------------ +; Oric cassette-tape header + +.segment "ORIXHDR" + + .byte $01, $00 ; + + .byte "ORI" + + .byte $01 ; version + .byte $00,$00 ; mode + .byte $00,$00 ; cpu type + .byte $00,$00 ; OS + + .byte $00 ; reserved + .byte $00 ; auto + + + .word __BASHEAD_START__ ; Address of start of file + .word __MAIN_LAST__ - 1 ; Address of end of file + .word __BASHEAD_START__ ; Address of start of file + diff --git a/libsrc/telemon30/oserrlist.s b/libsrc/telemon30/oserrlist.s new file mode 100644 index 000000000..8ec41de6d --- /dev/null +++ b/libsrc/telemon30/oserrlist.s @@ -0,0 +1,75 @@ +; +; Stefan Haubenthal, 2004-05-25 +; Ullrich von Bassewitz, 18.07.2002 +; +; Defines the platform specific error list. +; +; The table is built as a list of entries +; +; .byte entrylen +; .byte errorcode +; .asciiz errormsg +; +; and terminated by an entry with length zero that is returned if the +; error code could not be found. +; + + .export __sys_oserrlist + +;---------------------------------------------------------------------------- +; Macros used to generate the list (may get moved to an include file?) + +; Regular entry +.macro sys_oserr_entry code, msg + .local Start, End +Start: .byte End - Start + .byte code + .asciiz msg +End: +.endmacro + +; Sentinel entry +.macro sys_oserr_sentinel msg + .byte 0 ; Length is always zero + .byte 0 ; Code is unused + .asciiz msg +.endmacro + +;---------------------------------------------------------------------------- +; The error message table + +.rodata + +__sys_oserrlist: + sys_oserr_entry 1, "File not found" + sys_oserr_entry 2, "Invalid command end" + sys_oserr_entry 3, "No drive number" + sys_oserr_entry 4, "Bad drive number" + sys_oserr_entry 5, "Invalid filename" + sys_oserr_entry 6, "fderr=(error number)" + sys_oserr_entry 7, "Illegal attribute" + sys_oserr_entry 8, "Wildcard(s) not allowed" + sys_oserr_entry 9, "File already exists" + sys_oserr_entry 10, "Insufficient disc space" + sys_oserr_entry 11, "File open" + sys_oserr_entry 12, "Illegal quantity" + sys_oserr_entry 13, "End address missing" + sys_oserr_entry 14, "Start address > end address" + sys_oserr_entry 15, "Missing 'to'" + sys_oserr_entry 16, "Renamed file not on same disc" + sys_oserr_entry 17, "Unknown array" + sys_oserr_entry 18, "Target drive not source drive" + sys_oserr_entry 19, "Destination not specified" + sys_oserr_entry 20, "Cannot merge and overwrite" + sys_oserr_entry 21, "Single target file illegal" + sys_oserr_entry 22, "Syntax" + sys_oserr_entry 23, "Filename missing" + sys_oserr_entry 24, "Source file missing" + sys_oserr_entry 25, "Type mismatch" + sys_oserr_entry 26, "Disc write-protected" + sys_oserr_entry 27, "Incompatible drives" + sys_oserr_entry 28, "File not open" + sys_oserr_entry 29, "File end" + sys_oserr_sentinel "Unknown error" + + diff --git a/libsrc/telemon30/oserror.s b/libsrc/telemon30/oserror.s new file mode 100644 index 000000000..37c9bd7fc --- /dev/null +++ b/libsrc/telemon30/oserror.s @@ -0,0 +1,17 @@ +; +; Stefan Haubenthal, 2011-04-18 +; +; int __fastcall__ _osmaperrno (unsigned char oserror); +; /* Map a system specific error into a system independent code */ +; + + .include "errno.inc" + .export __osmaperrno + +.proc __osmaperrno + + lda #<EUNKNOWN + ldx #>EUNKNOWN + rts + +.endproc diff --git a/libsrc/telemon30/print.s b/libsrc/telemon30/print.s new file mode 100644 index 000000000..56c513fd6 --- /dev/null +++ b/libsrc/telemon30/print.s @@ -0,0 +1,21 @@ +; +; Jede +; +; print (char * str); +; +; This function is a hack! +; + + .export _print + .import popax + .importzp tmp1 + .include "telemon30.inc" + +.proc _print + stx tmp1 + ldy tmp1 + BRK_TELEMON XWSTR0 + rts +.endproc + + diff --git a/libsrc/telemon30/sound.s b/libsrc/telemon30/sound.s new file mode 100644 index 000000000..2df18f4a0 --- /dev/null +++ b/libsrc/telemon30/sound.s @@ -0,0 +1,45 @@ + .export _kbdclick1,_oups,_ping,_explode,_shoot,_zap + .include "telemon30.inc" + +.proc _kbdclick1 + LDX #<sound_bip_keyboard + LDY #>sound_bip_keyboard + BRK_TELEMON XSONPS + rts +sound_bip_keyboard: + .byte $1f,$00,$00,$00,$00,$00,$00,$3e,$10,$00,$00,$1f,$00,$00 +.endproc + +.proc _explode + BRK_TELEMON XEXPLO + rts +.endproc + +.proc _oups + BRK_TELEMON XOUPS + rts +.endproc + +.proc _ping + BRK_TELEMON XPING + rts +.endproc + +.proc _shoot + BRK_TELEMON XSHOOT + rts +.endproc + +.proc _zap + BRK_TELEMON XZAP + rts +.endproc + + + +; XPLAY := $43 +; XSOUND := $44 +; XMUSIC := $45 + + + diff --git a/libsrc/telemon30/sysuname.s b/libsrc/telemon30/sysuname.s new file mode 100644 index 000000000..51af1d8fe --- /dev/null +++ b/libsrc/telemon30/sysuname.s @@ -0,0 +1,46 @@ +; +; Ullrich von Bassewitz, 2003-08-12 +; +; unsigned char __fastcall__ _sysuname (struct utsname* buf); +; + + .export __sysuname, utsdata + + .import utscopy + + __sysuname = utscopy + +;-------------------------------------------------------------------------- +; Data. We define a fixed utsname struct here and just copy it. + +.rodata + +utsdata: + ; sysname + .asciiz "cc65" + + ; nodename + .asciiz "" + + ; release + .byte ((.VERSION >> 8) & $0F) + '0' + .byte '.' + .if ((.VERSION >> 4) & $0F) > 9 + .byte ((.VERSION >> 4) & $0F) / 10 + '0' + .byte ((.VERSION >> 4) & $0F) .MOD 10 + '0' + .else + .byte ((.VERSION >> 4) & $0F) + '0' + .endif + .byte $00 + + ; version + .if (.VERSION & $0F) > 9 + .byte (.VERSION & $0F) / 10 + '0' + .byte (.VERSION & $0F) .MOD 10 + '0' + .else + .byte (.VERSION & $0F) + '0' + .endif + .byte $00 + + ; machine + .asciiz "Oric Telestrat" diff --git a/libsrc/telemon30/write.s b/libsrc/telemon30/write.s new file mode 100644 index 000000000..32965fe3d --- /dev/null +++ b/libsrc/telemon30/write.s @@ -0,0 +1,61 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; int write (int fd, const void* buf, int count); +; +; This function is a hack! +; + + .export _write + .import popax + .importzp ptr1, ptr2, ptr3, tmp1 + + .include "telemon30.inc" + +.proc _write + + sta ptr3 + stx ptr3+1 ; save count as result + + eor #$FF + sta ptr2 + txa + eor #$FF + sta ptr2+1 ; Remember -count-1 + + jsr popax ; get buf + sta ptr1 + stx ptr1+1 + jsr popax ; get fd and discard +L1: inc ptr2 + bne L2 + inc ptr2+1 + beq L9 +L2: ldy #0 + lda (ptr1),y + tax + cpx #$0A ; Check for \n + bne L3 + BRK_TELEMON XWR0 ; Macro + lda #$0d ; return to the beggining of the line + BRK_TELEMON XWR0 ; Macro ; + + + ldx #$0D +L3: + BRK_TELEMON XWR0 ; Macro + + inc ptr1 + bne L1 + inc ptr1+1 + jmp L1 + +; No error, return count + +L9: lda ptr3 + ldx ptr3+1 + rts + +.endproc + + diff --git a/src/ar65.vcxproj b/src/ar65.vcxproj index b077134ce..003a5fa69 100644 --- a/src/ar65.vcxproj +++ b/src/ar65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ca65.vcxproj b/src/ca65.vcxproj index 4e02fa2a9..fb7cf2e26 100644 --- a/src/ca65.vcxproj +++ b/src/ca65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ca65/main.c b/src/ca65/main.c index d6c364e4b..4aa60f2f0 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -226,10 +226,6 @@ static void SetSys (const char* Sys) CBMSystem ("__C64__"); break; - case TGT_C65: - CBMSystem ("__C65__"); - break; - case TGT_VIC20: CBMSystem ("__VIC20__"); break; @@ -289,7 +285,15 @@ static void SetSys (const char* Sys) case TGT_ATMOS: NewSymbol ("__ATMOS__", 1); - break; + break; + + case TGT_TELEMON24: + NewSymbol ("__TELEMON24__", 1); + break; + + case TGT_TELEMON30: + NewSymbol ("__TELEMON30__", 1); + break; case TGT_NES: NewSymbol ("__NES__", 1); @@ -623,8 +627,7 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the assembler version */ { - fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); - exit(EXIT_SUCCESS); + fprintf (stderr, "ca65 V%s\n", GetVersionAsString ()); } diff --git a/src/cc65.vcxproj b/src/cc65.vcxproj index 1c1f993fe..aa85b0936 100644 --- a/src/cc65.vcxproj +++ b/src/cc65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/cc65/main.c b/src/cc65/main.c index afbec43d7..f25a44d69 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -243,6 +243,14 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__ATMOS__", 1); break; + case TGT_TELEMON24: + DefineNumericMacro ("__TELEMON24__", 1); + break; + + case TGT_TELEMON30: + DefineNumericMacro ("__TELEMON30__", 1); + break; + case TGT_NES: DefineNumericMacro ("__NES__", 1); break; @@ -742,7 +750,7 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the compiler version */ { - fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + fprintf (stderr, "cc65 V%s\n", GetVersionAsString ()); exit (EXIT_SUCCESS); } diff --git a/src/chrcvt65.vcxproj b/src/chrcvt65.vcxproj index 1daf7cae9..d120399d1 100644 --- a/src/chrcvt65.vcxproj +++ b/src/chrcvt65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/cl65.vcxproj b/src/cl65.vcxproj index 64c1126b1..b6ceb161a 100644 --- a/src/cl65.vcxproj +++ b/src/cl65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/co65.vcxproj b/src/co65.vcxproj index c66c8aac8..89eed36e1 100644 --- a/src/co65.vcxproj +++ b/src/co65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/common.vcxproj b/src/common.vcxproj index 053d23981..c466d9712 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -113,13 +113,13 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> <ConfigurationType>StaticLibrary</ConfigurationType> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/common/target.c b/src/common/target.c index 99a134c43..adbc080bf 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -147,12 +147,11 @@ static const TargetEntry TargetMap[] = { { "atari", TGT_ATARI }, { "atari5200", TGT_ATARI5200 }, { "atarixl", TGT_ATARIXL }, - { "atmos", TGT_ATMOS }, + { "atmos", TGT_ATMOS }, { "bbc", TGT_BBC }, { "c128", TGT_C128 }, { "c16", TGT_C16 }, { "c64", TGT_C64 }, - { "c65", TGT_C65 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, { "gamate", TGT_GAMATE }, @@ -171,6 +170,8 @@ static const TargetEntry TargetMap[] = { { "sim6502", TGT_SIM6502 }, { "sim65c02", TGT_SIM65C02 }, { "supervision", TGT_SUPERVISION }, + { "telemon24", TGT_TELEMON24 }, + { "telemon30", TGT_TELEMON30 }, { "vic20", TGT_VIC20 }, }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) @@ -199,6 +200,8 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, + { "telemon24", CPU_6502, BINFMT_BINARY, CTNone }, + { "telemon30", CPU_6502, BINFMT_BINARY, CTNone }, { "nes", CPU_6502, BINFMT_BINARY, CTNone }, { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, { "lynx", CPU_65SC02, BINFMT_BINARY, CTNone }, @@ -206,7 +209,6 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, - { "c65", CPU_4510, BINFMT_BINARY, CTPET }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 4115ae21a..4bc00225d 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -73,6 +73,8 @@ typedef enum { TGT_GEOS_APPLE, TGT_LUNIX, TGT_ATMOS, + TGT_TELEMON24, + TGT_TELEMON30, TGT_NES, TGT_SUPERVISION, TGT_LYNX, @@ -80,7 +82,6 @@ typedef enum { TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, - TGT_C65, TGT_COUNT /* Number of target systems */ } target_t; diff --git a/src/da65.vcxproj b/src/da65.vcxproj index 7810844dc..cf297fd32 100644 --- a/src/da65.vcxproj +++ b/src/da65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/grc65.vcxproj b/src/grc65.vcxproj index 211ad7cce..afac0cce1 100644 --- a/src/grc65.vcxproj +++ b/src/grc65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ld65.vcxproj b/src/ld65.vcxproj index acb9b4240..cc5598aad 100644 --- a/src/ld65.vcxproj +++ b/src/ld65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/od65.vcxproj b/src/od65.vcxproj index c788ac961..2ace26001 100644 --- a/src/od65.vcxproj +++ b/src/od65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/sim65.vcxproj b/src/sim65.vcxproj index f87b4db6b..9ba0980ba 100644 --- a/src/sim65.vcxproj +++ b/src/sim65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/sp65.vcxproj b/src/sp65.vcxproj index 8db98346c..6e7d992d4 100644 --- a/src/sp65.vcxproj +++ b/src/sp65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> From 15ac85b50c4aa6d32966cfeec5bc650c037aa0c1 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Wed, 14 Dec 2016 23:45:20 +0100 Subject: [PATCH 175/407] Adding ch376.h header, correcting some bugs --- include/ch376.h | 55 ++++++++++++++++++++++++++++++++++++++++ libsrc/telemon30/ch376.s | 8 +++--- 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 include/ch376.h diff --git a/include/ch376.h b/include/ch376.h new file mode 100644 index 000000000..9db801eaf --- /dev/null +++ b/include/ch376.h @@ -0,0 +1,55 @@ + + +/* /// "Portable types" */ + + + + +/* /// "CH376 interface commands and constants" */ + +// Chip version +#define CH376_DATA_IC_VER 3 + +// Commands +#define CH376_CMD_NONE 0x00 +#define CH376_CMD_GET_IC_VER 0x01 +#define CH376_CMD_CHECK_EXIST 0x06 +#define CH376_CMD_SET_USB_MODE 0x15 +#define CH376_CMD_GET_STATUS 0x22 +#define CH376_CMD_RD_USB_DATA0 0x27 +#define CH376_CMD_WR_REQ_DATA 0x2d +#define CH376_CMD_SET_FILE_NAME 0x2f +#define CH376_CMD_DISK_MOUNT 0x31 +#define CH376_CMD_FILE_OPEN 0x32 +#define CH376_CMD_FILE_ENUM_GO 0x33 +#define CH376_CMD_FILE_CREATE 0x34 +#define CH376_CMD_FILE_CLOSE 0x36 +#define CH376_CMD_BYTE_LOCATE 0x39 +#define CH376_CMD_BYTE_READ 0x3a +#define CH376_CMD_BYTE_RD_GO 0x3b +#define CH376_CMD_BYTE_WRITE 0x3c +#define CH376_CMD_BYTE_WR_GO 0x3d +#define CH376_CMD_DISK_QUERY 0x3f +#define CH376_CMD_DISK_RD_GO 0x55 + +#define CH376_ARG_SET_USB_MODE_INVALID 0x00 +#define CH376_ARG_SET_USB_MODE_SD_HOST 0x03 +#define CH376_ARG_SET_USB_MODE_USB_HOST 0x06 + +// Status & errors +#define CH376_ERR_OPEN_DIR 0x41 +#define CH376_ERR_MISS_FILE 0x42 + +#define CH376_RET_SUCCESS 0x51 +#define CH376_RET_ABORT 0x5f + +#define CH376_INT_SUCCESS 0x14 +#define CH376_INT_DISK_READ 0x1d +#define CH376_INT_DISK_WRITE 0x1e + + +unsigned char ch376_check_exist(unsigned char value); +unsigned char ch376_ic_get_version(void); +void ch376_set_usb_mode(unsigned char value); +unsigned char ch376_disk_mount(void); + diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s index 1b75c2b18..90e2878e1 100644 --- a/libsrc/telemon30/ch376.s +++ b/libsrc/telemon30/ch376.s @@ -4,7 +4,7 @@ .export _ch376_reset .export _ch376_check_exist .export _ch376_disk_mount - + .export _ch376_set_usb_mode .import popax .importzp sp,tmp2,tmp3,tmp1 .include "telemon30.inc" @@ -123,6 +123,7 @@ loop: .proc _ch376_ic_get_version lda #CH376_GET_IC_VER sta CH376_COMMAND + ldx #0 lda CH376_DATA rts .endproc @@ -131,10 +132,10 @@ loop: .proc _ch376_set_usb_mode ; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY - sta tmp1 + pha lda #CH376_SET_USB_MODE ; $15 sta CH376_COMMAND - lda tmp1 + pla sta CH376_DATA rts .endproc @@ -169,6 +170,7 @@ loop: sta CH376_COMMAND jsr _ch376_wait_response ; if we read data value, we have then length of the volume name + ldx #0 rts .endproc From 66b30f0c7aefade9dca49b7fadf746d9a0594f8c Mon Sep 17 00:00:00 2001 From: Chris Cacciatore <chris.cacciatore@gmail.com> Date: Wed, 14 Dec 2016 16:53:55 -0800 Subject: [PATCH 176/407] Added 'any' to --list-opt-steps. --- src/cc65/codeopt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index 9eb175105..e44bf2bf5 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -911,6 +911,8 @@ void ListOptSteps (FILE* F) /* List all optimization steps */ { unsigned I; + + fprintf (F, "any\n"); for (I = 0; I < OPTFUNC_COUNT; ++I) { fprintf (F, "%s\n", OptFuncs[I]->Name); } From 09495519c0d9f5f6ad070a27b7a6bdc717b7a554 Mon Sep 17 00:00:00 2001 From: Marshall Ward <git@marshallward.org> Date: Tue, 20 Dec 2016 22:12:08 +1100 Subject: [PATCH 177/407] NES memory map amend (16k prg, 8k chr default) The configuration file and runtime (crt0.s) provided for the default NES ROM layout (2x16k PRG, 8k CHR) incorrectly added interrupts (IRQ1, IRQ2, TIMERIRQ) which are not supported by the NES hardware. For example, see the NESdev wiki, which makes no reference to these interrupts. https://wiki.nesdev.com/w/index.php/CPU_memory_map The VECTORS region was also incorrectly set to 0xFFF6, which would have left the 0xFFF4 normally unspecified. This did not result in any error, however, since cc65 simply placed ROMV directly after ROM0 regardless of start address. (This layout may be due to a copy-and-paste from the PC-Engine configuration, whose interrupt registers start at 0xFFF6, begins with the three interrupts listed above, followed by NMI and START, and does not end with a final IRQ interrupt.) Despite the absence of any actual error, since START is still placed at 0xFFFC, this patch removes the nonexistent interrupts and also correctly aligns the ROM0 and ROMV regions. It also has the (admittedly very minor) benefit of freeing up 6 additional bytes for ROM0. --- cfg/nes.cfg | 4 ++-- libsrc/nes/crt0.s | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/cfg/nes.cfg b/cfg/nes.cfg index fdd992fe0..bb7d23408 100644 --- a/cfg/nes.cfg +++ b/cfg/nes.cfg @@ -12,10 +12,10 @@ MEMORY { # - code # - rodata # - data (load) - ROM0: file = %O, start = $8000, size = $7FF4, fill = yes, define = yes; + ROM0: file = %O, start = $8000, size = $7FFA, fill = yes, define = yes; # Hardware Vectors at End of 2nd 8K ROM - ROMV: file = %O, start = $FFF6, size = $000C, fill = yes; + ROMV: file = %O, start = $FFFA, size = $0006, fill = yes; # 1 8k CHR Bank ROM2: file = %O, start = $0000, size = $2000, fill = yes; diff --git a/libsrc/nes/crt0.s b/libsrc/nes/crt0.s index 4d258ff9e..a380d4dd3 100644 --- a/libsrc/nes/crt0.s +++ b/libsrc/nes/crt0.s @@ -159,9 +159,6 @@ nmi: pha ; Interrupt exit -irq2: -irq1: -timerirq: irq: rti @@ -171,9 +168,6 @@ irq: .segment "VECTORS" - .word irq2 ; $fff4 ? - .word irq1 ; $fff6 ? - .word timerirq ; $fff8 ? .word nmi ; $fffa vblank nmi .word start ; $fffc reset .word irq ; $fffe irq / brk From 1b4a7e37ce8e7fd0b8b82630da48944ccd3125cb Mon Sep 17 00:00:00 2001 From: Kyle Swanson <k@ylo.ph> Date: Tue, 27 Dec 2016 11:45:40 -0600 Subject: [PATCH 178/407] doc/ca65: fix typo --- doc/ca65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 78be90d15..2c43a9b50 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -3012,7 +3012,7 @@ Here's a list of all control commands and a description, what they do: Conditional assembly: Check if there are any remaining tokens in this line, and evaluate to FALSE if this is the case, and to TRUE otherwise. If the condition is not true, further lines are not assembled until an <tt><ref - id=".ELSE" name=".ESLE"></tt>, <tt><ref id=".ELSEIF" name=".ELSEIF"></tt> or + id=".ELSE" name=".ELSE"></tt>, <tt><ref id=".ELSEIF" name=".ELSEIF"></tt> or <tt><ref id=".ENDIF" name=".ENDIF"></tt> directive. This command is often used to check if a macro parameter was given. Since an From d5ba0636027feab064614b669c9196ef24ed6287 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Wed, 4 Jan 2017 20:03:19 +0100 Subject: [PATCH 179/407] Correcting some bugs --- include/telemon.h | 58 ++++++++++++++++++++++++++++++++++++++++ libsrc/telemon30/_open.s | 28 ++++++++++++++++--- libsrc/telemon30/ch376.s | 27 +++++++++++++++++-- 3 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 include/telemon.h diff --git a/include/telemon.h b/include/telemon.h new file mode 100644 index 000000000..70033a9ad --- /dev/null +++ b/include/telemon.h @@ -0,0 +1,58 @@ + +void print (char *); + +void hires(); +void text(); +void oups(); +void ping(); +void zap(); +void shoot(); +void explode(); + +void paper(char color); +void ink(char color); + +void kbdclick1(); + + + +void curset(char x,char y); +void circle(char rayon); + +char key(void); + + +/* PEEK, POKE, DEEK, DOKE */ + +#define POKE(addr,val) (*(unsigned char*) (addr) = (val)) + + +#define PCHN_1 001 +#define PCHN_2 002 +#define PCHN_12 003 +#define PCHN_3 004 +#define PCHN_13 005 +#define PCHN_23 006 +#define PCHN_123 007 + +#define ENV_DECAY 001 /* \_________ envelope */ +#define ENV_ATTACK_CUT 002 /* /_________ envelope */ +#define ENV_SAW_DOWN 003 /* \\\\\\\\\\ envelope */ +#define ENV_WAVE 004 /* /\/\/\/\/\ envelope */ +#define ENV_DECAY_CONT 005 /* \~~~~~~~~~ envelope */ +#define ENV_SAW_UP 006 /* ////////// envelope */ +#define ENV_ATTACK_CONT 007 /* /~~~~~~~~~ envelope */ + +#define VOL_ENVELOPE 0x0 +#define VOL_QUIETEST 0x1 +#define VOL_LOUDEST 0xe + +extern int play(int soundchanels,int noisechanels,int envelop,int volume); + + +/* Play a musical tone through the selected channel. */ + +#define CHAN_1 1 +#define CHAN_2 2 +#define CHAN_3 3 + diff --git a/libsrc/telemon30/_open.s b/libsrc/telemon30/_open.s index f308632d9..a002bbce1 100644 --- a/libsrc/telemon30/_open.s +++ b/libsrc/telemon30/_open.s @@ -3,7 +3,9 @@ .importzp sp,tmp2,tmp3,tmp1 ; int open (const char* name, int flags, ...); /* May take a mode argument */ .include "telemon30.inc" - + .include "errno.inc" + .include "fcntl.inc" + .proc _open ; Throw away any additional parameters passed through the ellipsis @@ -16,12 +18,32 @@ ; Parameters ok. Pop the flags and save them into tmp3 -parmok: jsr popax ; Get flags +parmok: jsr popax ; Get flagss + sta tmp3 ; save flags + + ;AND #O_RDONLY + ;beq READONLY + ;lda tmp3 + ;AND #O_WRONLY + ;beq WRITEONLY + ;jmp next +;READONLY: +; lda #'r' +; BRK_TELEMON XWR0 +; jmp next +;WRITEONLY: +; lda #'w' +; BRK_TELEMON XWR0 + +;next: ; Get the filename from stack and parse it. Bail out if is not ok jsr popax ; Get name - + + + ldy tmp3 ; Get flags + BRK_TELEMON XOPEN diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s index 90e2878e1..24df14471 100644 --- a/libsrc/telemon30/ch376.s +++ b/libsrc/telemon30/ch376.s @@ -1,3 +1,6 @@ + + ; For XA65 compatibily in the futur + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term .export _ch376_set_file_name .export _ch376_file_open .export _ch376_ic_get_version @@ -5,10 +8,18 @@ .export _ch376_check_exist .export _ch376_disk_mount .export _ch376_set_usb_mode + .export _ch376_file_create + .export _ch376_fcreate + + ; High level function + .export _ch376_fcreate + .import popax .importzp sp,tmp2,tmp3,tmp1 .include "telemon30.inc" +/* +*/ ; CODE FOR CH376_SET_USB_MODE ************************************************* CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY := $06 @@ -17,8 +28,7 @@ CH376_USB_INT_DISK_READ := $1d CH376_USB_INT_SUCCESS := $14 CH376_ERR_MISS_FILE := $42 -CH376_DATA :=$340 -CH376_COMMAND :=$341 + CH376_GET_IC_VER := $01 CH376_SET_BAUDRATE := $02 @@ -34,6 +44,7 @@ CH376_DISK_CONNECT := $30 ; check the disk connection status CH376_DISK_MOUNT := $31 CH376_FILE_OPEN := $32 CH376_FILE_ENUM_GO := $33 +CH376_FILE_CREATE := $34 CH376_FILE_CLOSE := $36 CH376_BYTE_READ := $3A CH376_BYTE_RD_GO := $3b @@ -41,7 +52,19 @@ CH376_BYTE_WRITE := $3C CH376_DISK_CAPACITY := $3E CH376_DISK_RD_GO := $55 +.proc _ch376_file_create + lda #CH376_FILE_CREATE + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc +; void _ch376_fcreate(char *filename) +.proc _ch376_fcreate + jsr _ch376_set_file_name + jsr _ch376_file_open + jsr _ch376_file_create +.endproc ; void ch376_set_file_name(char *filename) .proc _ch376_set_file_name From c1aac0de0e9c8fc92a325f2809dc9eacb489b137 Mon Sep 17 00:00:00 2001 From: Florent Flament <contact@florentflament.com> Date: Sun, 8 Jan 2017 19:12:55 +0100 Subject: [PATCH 180/407] Add C support for Atari 2600 (VCS) --- cfg/atari2600.cfg | 22 ++++++ include/_riot.h | 26 +++++++ include/_tia.h | 100 ++++++++++++++++++++++++ include/atari2600.h | 26 +++++++ libsrc/Makefile | 1 + libsrc/atari2600/crt0.s | 49 ++++++++++++ libsrc/atari2600/ctype.s | 162 +++++++++++++++++++++++++++++++++++++++ samples/Makefile | 3 + samples/atari2600hello.c | 56 ++++++++++++++ src/ca65/main.c | 4 + src/cc65/main.c | 4 + src/common/target.c | 2 + src/common/target.h | 1 + 13 files changed, 456 insertions(+) create mode 100644 cfg/atari2600.cfg create mode 100644 include/_riot.h create mode 100644 include/_tia.h create mode 100644 include/atari2600.h create mode 100644 libsrc/atari2600/crt0.s create mode 100644 libsrc/atari2600/ctype.s create mode 100644 samples/atari2600hello.c diff --git a/cfg/atari2600.cfg b/cfg/atari2600.cfg new file mode 100644 index 000000000..106edeb30 --- /dev/null +++ b/cfg/atari2600.cfg @@ -0,0 +1,22 @@ +# Atari VCS 2600 linker configuration file for cc65 +# +# Florent Flament (contact@florentflament.com), 2017 + +SYMBOLS { + __STACKSIZE__: type = weak, value = $0010; # 16 Bytes system stack +} + +MEMORY { + RAM: file = "", start = $0080, size = $0080 - __STACKSIZE__, define = yes; + ROM: file = %O, start = $F000, size = $1000, fill = yes, fillval = $FF; +} + +SEGMENTS { + ZEROPAGE: load = RAM, type = zp; + STARTUP: load = ROM, type = ro; + CODE: load = ROM, type = ro; + RODATA: load = ROM, type = ro, optional = yes; + DATA: load = ROM, run = RAM, type = rw, optional = yes, define = yes; + BSS: load = RAM, type = bss, optional = yes; + VECTORS: load = ROM, type = ro, start = $FFFA; +} diff --git a/include/_riot.h b/include/_riot.h new file mode 100644 index 000000000..7c431127c --- /dev/null +++ b/include/_riot.h @@ -0,0 +1,26 @@ +/*****************************************************************************/ +/* */ +/* Atari VCS 2600 RIOT registers addresses */ +/* */ +/* Source: DASM - vcs.h */ +/* */ +/* Florent Flament (contact@florentflament.com), 2017 */ +/* */ +/*****************************************************************************/ + +/* RIOT registers */ +struct __riot { + unsigned char swcha; + unsigned char swacnt; + unsigned char swchb; + unsigned char swbcnt; + unsigned char intim; + unsigned char timint; + + unsigned char unused[14]; + + unsigned char tim1t; + unsigned char tim8t; + unsigned char tim64t; + unsigned char t1024t; +}; diff --git a/include/_tia.h b/include/_tia.h new file mode 100644 index 000000000..c89c04d6c --- /dev/null +++ b/include/_tia.h @@ -0,0 +1,100 @@ +/*****************************************************************************/ +/* */ +/* Atari VCS 2600 TIA registers addresses */ +/* */ +/* Source: DASM - vcs.h */ +/* */ +/* Florent Flament (contact@florentflament.com), 2017 */ +/* */ +/*****************************************************************************/ + +/* TIA write / read registers */ +struct __tia { + union { + unsigned char vsync; + unsigned char cxm0p; + }; + union { + unsigned char vblank; + unsigned char cxm1p; + }; + union { + unsigned char wsync; + unsigned char cxp0fb; + }; + union { + unsigned char rsync; + unsigned char cxp1fb; + }; + union { + unsigned char nusiz0; + unsigned char cxm0fb; + }; + union { + unsigned char nusiz1; + unsigned char cxm1fb; + }; + union { + unsigned char colup0; + unsigned char cxblpf; + }; + union { + unsigned char colup1; + unsigned char cxppmm; + }; + union { + unsigned char colupf; + unsigned char inpt0; + }; + union { + unsigned char colubk; + unsigned char inpt1; + }; + union { + unsigned char ctrlpf; + unsigned char inpt2; + }; + union { + unsigned char refp0; + unsigned char inpt3; + }; + union { + unsigned char refp1; + unsigned char inpt4; + }; + union { + unsigned char pf0; + unsigned char inpt5; + }; + unsigned char pf1; + unsigned char pf2; + unsigned char resp0; + unsigned char resp1; + unsigned char resm0; + unsigned char resm1; + unsigned char resbl; + unsigned char audc0; + unsigned char audc1; + unsigned char audf0; + unsigned char audf1; + unsigned char audv0; + unsigned char audv1; + unsigned char grp0; + unsigned char grp1; + unsigned char enam0; + unsigned char enam1; + unsigned char enabl; + unsigned char hmp0; + unsigned char hmp1; + unsigned char hmm0; + unsigned char hmm1; + unsigned char hmbl; + unsigned char vdelp0; + unsigned char vdelp1; + unsigned char vdelbl; + unsigned char resmp0; + unsigned char resmp1; + unsigned char hmove; + unsigned char hmclr; + unsigned char cxclr; +}; diff --git a/include/atari2600.h b/include/atari2600.h new file mode 100644 index 000000000..1eb51a2dd --- /dev/null +++ b/include/atari2600.h @@ -0,0 +1,26 @@ +/*****************************************************************************/ +/* */ +/* Atari VCS 2600 TIA & RIOT registers addresses */ +/* */ +/* Source: DASM Version 1.05 - vcs.h */ +/* */ +/* Florent Flament (contact@florentflament.com), 2017 */ +/* */ +/*****************************************************************************/ + +#ifndef _ATARI2600_H +#define _ATARI2600_H + +/* Check for errors */ +#if !defined(__ATARI2600__) +# error This module may only be used when compiling for the Atari 2600! +#endif + +#include <_tia.h> +#define TIA (*(struct __tia*)0x0000) + +#include <_riot.h> +#define RIOT (*(struct __riot*)0x0280) + +/* End of atari2600.h */ +#endif /* #ifndef _ATARI2600_H */ diff --git a/libsrc/Makefile b/libsrc/Makefile index 99f120f3a..6b6a8fce8 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -19,6 +19,7 @@ TARGETS = apple2 \ apple2enh \ atari \ atarixl \ + atari2600 \ atari5200 \ atmos \ $(CBMS) \ diff --git a/libsrc/atari2600/crt0.s b/libsrc/atari2600/crt0.s new file mode 100644 index 000000000..4f09a0a5a --- /dev/null +++ b/libsrc/atari2600/crt0.s @@ -0,0 +1,49 @@ +; Atari VCS 2600 startup code for cc65 +; +; Florent Flament (contact@florentflament.com), 2017 + + .export _exit + .export __STARTUP__ : absolute = 1 + + .import __RAM_START__, __RAM_SIZE__ + .import copydata + .import _main + + .include "zeropage.inc" + + +.segment "STARTUP" +start: +; Clear decimal mode + cld + +; Initialization Loop: +; * Clears Atari 2600 whole memory (128 bytes) including BSS segment +; * Clears TIA registers +; * Sets system stack pointer to $ff (i.e top of zero-page) + ldx #0 + txa +clearLoop: + dex + txs + pha + bne clearLoop + +; Initialize data + jsr copydata + +; Initialize C stack pointer + lda #<(__RAM_START__ + __RAM_SIZE__) + ldx #>(__RAM_START__ + __RAM_SIZE__) + sta sp + stx sp+1 + +; Call main + jsr _main +_exit: jmp _exit + + +.segment "VECTORS" +.word start ; NMI +.word start ; Reset +.word start ; IRQ diff --git a/libsrc/atari2600/ctype.s b/libsrc/atari2600/ctype.s new file mode 100644 index 000000000..1892554fd --- /dev/null +++ b/libsrc/atari2600/ctype.s @@ -0,0 +1,162 @@ +; +; Ullrich von Bassewitz, 2003-10-10 +; +; Character specification table. +; + + .include "ctype.inc" + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it weren't for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). +; +; * It is highly portable. The only unportable part is the table itself, +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. + + +__ctype: + .byte CT_CTRL ; 0/00 ___ctrl_@___ + .byte CT_CTRL ; 1/01 ___ctrl_A___ + .byte CT_CTRL ; 2/02 ___ctrl_B___ + .byte CT_CTRL ; 3/03 ___ctrl_C___ + .byte CT_CTRL ; 4/04 ___ctrl_D___ + .byte CT_CTRL ; 5/05 ___ctrl_E___ + .byte CT_CTRL ; 6/06 ___ctrl_F___ + .byte CT_CTRL ; 7/07 ___ctrl_G___ + .byte CT_CTRL ; 8/08 ___ctrl_H___ + .byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB + ; 9/09 ___ctrl_I___ + .byte CT_CTRL | CT_OTHER_WS ; 10/0a ___ctrl_J___ + .byte CT_CTRL | CT_OTHER_WS ; 11/0b ___ctrl_K___ + .byte CT_CTRL | CT_OTHER_WS ; 12/0c ___ctrl_L___ + .byte CT_CTRL | CT_OTHER_WS ; 13/0d ___ctrl_M___ + .byte CT_CTRL ; 14/0e ___ctrl_N___ + .byte CT_CTRL ; 15/0f ___ctrl_O___ + .byte CT_CTRL ; 16/10 ___ctrl_P___ + .byte CT_CTRL ; 17/11 ___ctrl_Q___ + .byte CT_CTRL ; 18/12 ___ctrl_R___ + .byte CT_CTRL ; 19/13 ___ctrl_S___ + .byte CT_CTRL ; 20/14 ___ctrl_T___ + .byte CT_CTRL ; 21/15 ___ctrl_U___ + .byte CT_CTRL ; 22/16 ___ctrl_V___ + .byte CT_CTRL ; 23/17 ___ctrl_W___ + .byte CT_CTRL ; 24/18 ___ctrl_X___ + .byte CT_CTRL ; 25/19 ___ctrl_Y___ + .byte CT_CTRL ; 26/1a ___ctrl_Z___ + .byte CT_CTRL ; 27/1b ___ctrl_[___ + .byte CT_CTRL ; 28/1c ___ctrl_\___ + .byte CT_CTRL ; 29/1d ___ctrl_]___ + .byte CT_CTRL ; 30/1e ___ctrl_^___ + .byte CT_CTRL ; 31/1f ___ctrl_____ + .byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___ + .byte CT_NONE ; 33/21 _____!_____ + .byte CT_NONE ; 34/22 _____"_____ + .byte CT_NONE ; 35/23 _____#_____ + .byte CT_NONE ; 36/24 _____$_____ + .byte CT_NONE ; 37/25 _____%_____ + .byte CT_NONE ; 38/26 _____&_____ + .byte CT_NONE ; 39/27 _____'_____ + .byte CT_NONE ; 40/28 _____(_____ + .byte CT_NONE ; 41/29 _____)_____ + .byte CT_NONE ; 42/2a _____*_____ + .byte CT_NONE ; 43/2b _____+_____ + .byte CT_NONE ; 44/2c _____,_____ + .byte CT_NONE ; 45/2d _____-_____ + .byte CT_NONE ; 46/2e _____._____ + .byte CT_NONE ; 47/2f _____/_____ + .byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____ + .byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____ + .byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____ + .byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____ + .byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____ + .byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____ + .byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____ + .byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____ + .byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____ + .byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____ + .byte CT_NONE ; 58/3a _____:_____ + .byte CT_NONE ; 59/3b _____;_____ + .byte CT_NONE ; 60/3c _____<_____ + .byte CT_NONE ; 61/3d _____=_____ + .byte CT_NONE ; 62/3e _____>_____ + .byte CT_NONE ; 63/3f _____?_____ + + .byte CT_NONE ; 64/40 _____@_____ + .byte CT_UPPER | CT_XDIGIT ; 65/41 _____A_____ + .byte CT_UPPER | CT_XDIGIT ; 66/42 _____B_____ + .byte CT_UPPER | CT_XDIGIT ; 67/43 _____C_____ + .byte CT_UPPER | CT_XDIGIT ; 68/44 _____D_____ + .byte CT_UPPER | CT_XDIGIT ; 69/45 _____E_____ + .byte CT_UPPER | CT_XDIGIT ; 70/46 _____F_____ + .byte CT_UPPER ; 71/47 _____G_____ + .byte CT_UPPER ; 72/48 _____H_____ + .byte CT_UPPER ; 73/49 _____I_____ + .byte CT_UPPER ; 74/4a _____J_____ + .byte CT_UPPER ; 75/4b _____K_____ + .byte CT_UPPER ; 76/4c _____L_____ + .byte CT_UPPER ; 77/4d _____M_____ + .byte CT_UPPER ; 78/4e _____N_____ + .byte CT_UPPER ; 79/4f _____O_____ + .byte CT_UPPER ; 80/50 _____P_____ + .byte CT_UPPER ; 81/51 _____Q_____ + .byte CT_UPPER ; 82/52 _____R_____ + .byte CT_UPPER ; 83/53 _____S_____ + .byte CT_UPPER ; 84/54 _____T_____ + .byte CT_UPPER ; 85/55 _____U_____ + .byte CT_UPPER ; 86/56 _____V_____ + .byte CT_UPPER ; 87/57 _____W_____ + .byte CT_UPPER ; 88/58 _____X_____ + .byte CT_UPPER ; 89/59 _____Y_____ + .byte CT_UPPER ; 90/5a _____Z_____ + .byte CT_NONE ; 91/5b _____[_____ + .byte CT_NONE ; 92/5c _____\_____ + .byte CT_NONE ; 93/5d _____]_____ + .byte CT_NONE ; 94/5e _____^_____ + .byte CT_NONE ; 95/5f _UNDERLINE_ + .byte CT_NONE ; 96/60 ___grave___ + .byte CT_LOWER | CT_XDIGIT ; 97/61 _____a_____ + .byte CT_LOWER | CT_XDIGIT ; 98/62 _____b_____ + .byte CT_LOWER | CT_XDIGIT ; 99/63 _____c_____ + .byte CT_LOWER | CT_XDIGIT ; 100/64 _____d_____ + .byte CT_LOWER | CT_XDIGIT ; 101/65 _____e_____ + .byte CT_LOWER | CT_XDIGIT ; 102/66 _____f_____ + .byte CT_LOWER ; 103/67 _____g_____ + .byte CT_LOWER ; 104/68 _____h_____ + .byte CT_LOWER ; 105/69 _____i_____ + .byte CT_LOWER ; 106/6a _____j_____ + .byte CT_LOWER ; 107/6b _____k_____ + .byte CT_LOWER ; 108/6c _____l_____ + .byte CT_LOWER ; 109/6d _____m_____ + .byte CT_LOWER ; 110/6e _____n_____ + .byte CT_LOWER ; 111/6f _____o_____ + .byte CT_LOWER ; 112/70 _____p_____ + .byte CT_LOWER ; 113/71 _____q_____ + .byte CT_LOWER ; 114/72 _____r_____ + .byte CT_LOWER ; 115/73 _____s_____ + .byte CT_LOWER ; 116/74 _____t_____ + .byte CT_LOWER ; 117/75 _____u_____ + .byte CT_LOWER ; 118/76 _____v_____ + .byte CT_LOWER ; 119/77 _____w_____ + .byte CT_LOWER ; 120/78 _____x_____ + .byte CT_LOWER ; 121/79 _____y_____ + .byte CT_LOWER ; 122/7a _____z_____ + .byte CT_NONE ; 123/7b _____{_____ + .byte CT_NONE ; 124/7c _____|_____ + .byte CT_NONE ; 125/7d _____}_____ + .byte CT_NONE ; 126/7e _____~_____ + .byte CT_OTHER_WS ; 127/7f ____DEL____ + + .res 128, CT_NONE ; 128-255 + + + diff --git a/samples/Makefile b/samples/Makefile index 3a60798da..abd304b14 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -147,6 +147,9 @@ EXELIST_atari = \ EXELIST_atarixl = $(EXELIST_atari) +EXELIST_atari2600 = \ + atari2600hello + # -------------------------------------------------------------------------- # Rules to make the binaries and the disk diff --git a/samples/atari2600hello.c b/samples/atari2600hello.c new file mode 100644 index 000000000..e4f7893b7 --- /dev/null +++ b/samples/atari2600hello.c @@ -0,0 +1,56 @@ +/*****************************************************************************/ +/* */ +/* Atari VCS 2600 sample C program */ +/* */ +/* Florent Flament (contact@florentflament.com), 2017 */ +/* */ +/*****************************************************************************/ + +#include <atari2600.h> + +// PAL Timings +// Roughly computed based on Stella Programmer's guide (Steve Wright) +// scanlines count per section. +#define VBLANK_TIM64 51 // 45 lines * 76 cycles/line / 64 cycles/tick +#define KERNAL_T1024 17 // 228 lines * 76 cycles/line / 1024 cycles/tick +#define OVERSCAN_TIM64 42 // 36 lines * 76 cycles/line / 64 cycles/tick + +// Testing memory zones +const unsigned char rodata_v[] = "Hello!"; +unsigned char data_v = 0x77; +unsigned char bss_v; + +void main(void) { + unsigned char color = 0x79; // Stack variable + bss_v = 0x88; // Testing BSS variable + + for/*ever*/(;;) { + // Vertical Sync signal + TIA.vsync = 0x02; + TIA.wsync = 0x00; + TIA.wsync = 0x00; + TIA.wsync = 0x00; + TIA.vsync = 0x00; + + // Vertical Blank timer setting + RIOT.tim64t = VBLANK_TIM64; + + // Doing frame computation during blank + TIA.colubk = color++; // Update color + + // Wait for end of Vertical Blank + while (RIOT.timint == 0) {} + TIA.wsync = 0x00; + TIA.vblank = 0x00; // Turn on beam + + // Display frame + RIOT.t1024t = KERNAL_T1024; + while (RIOT.timint == 0) {} + TIA.wsync = 0x00; + TIA.vblank = 0x02; // Turn off beam + + // Overscan + RIOT.tim64t = OVERSCAN_TIM64; + while (RIOT.timint == 0) {} + } +} diff --git a/src/ca65/main.c b/src/ca65/main.c index d6c364e4b..1317f26cc 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -205,6 +205,10 @@ static void SetSys (const char* Sys) AbEnd ("Cannot use `module' as a target for the assembler"); break; + case TGT_ATARI2600: + NewSymbol ("__ATARI2600__", 1); + break; + case TGT_ATARI5200: NewSymbol ("__ATARI5200__", 1); break; diff --git a/src/cc65/main.c b/src/cc65/main.c index afbec43d7..2a82e5302 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -161,6 +161,10 @@ static void SetSys (const char* Sys) AbEnd ("Cannot use `module' as a target for the compiler"); break; + case TGT_ATARI2600: + DefineNumericMacro ("__ATARI2600__", 1); + break; + case TGT_ATARI5200: DefineNumericMacro ("__ATARI5200__", 1); break; diff --git a/src/common/target.c b/src/common/target.c index 99a134c43..42db5dee3 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -145,6 +145,7 @@ static const TargetEntry TargetMap[] = { { "apple2", TGT_APPLE2 }, { "apple2enh", TGT_APPLE2ENH }, { "atari", TGT_ATARI }, + { "atari2600", TGT_ATARI2600 }, { "atari5200", TGT_ATARI5200 }, { "atarixl", TGT_ATARIXL }, { "atmos", TGT_ATMOS }, @@ -181,6 +182,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "none", CPU_6502, BINFMT_BINARY, CTNone }, { "module", CPU_6502, BINFMT_O65, CTNone }, { "atari", CPU_6502, BINFMT_BINARY, CTAtari }, + { "atari2600", CPU_6502, BINFMT_BINARY, CTNone }, { "atari5200", CPU_6502, BINFMT_BINARY, CTAtari }, { "atarixl", CPU_6502, BINFMT_BINARY, CTAtari }, { "vic20", CPU_6502, BINFMT_BINARY, CTPET }, diff --git a/src/common/target.h b/src/common/target.h index 4115ae21a..a5cb44b98 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -55,6 +55,7 @@ typedef enum { TGT_NONE, TGT_MODULE, TGT_ATARI, + TGT_ATARI2600, TGT_ATARI5200, TGT_ATARIXL, TGT_VIC20, From 3d52856dd21f52c6a9bd658df53dafcf74e63452 Mon Sep 17 00:00:00 2001 From: Florent Flament <contact@florentflament.com> Date: Fri, 13 Jan 2017 21:11:44 +0100 Subject: [PATCH 181/407] Add Atari2600 ASM header (.inc) files --- asminc/atari2600.inc | 7 ++++ asminc/atari2600_riot.inc | 20 ++++++++++++ asminc/atari2600_tia.inc | 69 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 asminc/atari2600.inc create mode 100644 asminc/atari2600_riot.inc create mode 100644 asminc/atari2600_tia.inc diff --git a/asminc/atari2600.inc b/asminc/atari2600.inc new file mode 100644 index 000000000..a20926d08 --- /dev/null +++ b/asminc/atari2600.inc @@ -0,0 +1,7 @@ +; Atari 2600 TIA & RIOT read / write registers +; +; Florent Flament (contact@florentflament.com), 2017 + +; TIA & RIOT registers mapping +.include "atari2600_tia.inc" +.include "atari2600_riot.inc" diff --git a/asminc/atari2600_riot.inc b/asminc/atari2600_riot.inc new file mode 100644 index 000000000..a2c6ef633 --- /dev/null +++ b/asminc/atari2600_riot.inc @@ -0,0 +1,20 @@ +; Atari 2600 RIOT read / write registers +; +; Source: DASM - vcs.h +; Details available in: Stella Programmer's Guide by Steve Wright +; +; Florent Flament (contact@florentflament.com), 2017 + +; Read registers +SWCHA := $0280 +SWACNT := $0281 +SWCHB := $0282 +SWBCNT := $0283 +INTIM := $0284 +TIMINT := $0285 + +; Write registers +TIM1T := $0294 +TIM8T := $0295 +TIM64T := $0296 +T1024T := $0297 diff --git a/asminc/atari2600_tia.inc b/asminc/atari2600_tia.inc new file mode 100644 index 000000000..57c27adba --- /dev/null +++ b/asminc/atari2600_tia.inc @@ -0,0 +1,69 @@ +; Atari 2600 TIA read / write registers +; +; Source: DASM - vcs.h +; Details available in: Stella Programmer's Guide by Steve Wright +; +; Florent Flament (contact@florentflament.com), 2017 + +; Read registers +VSYNC := $00 +VBLANK := $01 +WSYNC := $02 +RSYNC := $03 +NUSIZ0 := $04 +NUSIZ1 := $05 +COLUP0 := $06 +COLUP1 := $07 +COLUPF := $08 +COLUBK := $09 +CTRLPF := $0A +REFP0 := $0B +REFP1 := $0C +PF0 := $0D +PF1 := $0E +PF2 := $0F +RESP0 := $10 +RESP1 := $11 +RESM0 := $12 +RESM1 := $13 +RESBL := $14 +AUDC0 := $15 +AUDC1 := $16 +AUDF0 := $17 +AUDF1 := $18 +AUDV0 := $19 +AUDV1 := $1A +GRP0 := $1B +GRP1 := $1C +ENAM0 := $1D +ENAM1 := $1E +ENABL := $1F +HMP0 := $20 +HMP1 := $21 +HMM0 := $22 +HMM1 := $23 +HMBL := $24 +VDELP0 := $25 +VDELP1 := $26 +VDELBL := $27 +RESMP0 := $28 +RESMP1 := $29 +HMOVE := $2A +HMCLR := $2B +CXCLR := $2C + +; Write registers +CXM0P := $00 +CXM1P := $01 +CXP0FB := $02 +CXP1FB := $03 +CXM0FB := $04 +CXM1FB := $05 +CXBLPF := $06 +CXPPMM := $07 +INPT0 := $08 +INPT1 := $09 +INPT2 := $0A +INPT3 := $0B +INPT4 := $0C +INPT5 := $0D From 2a81eaa06e9cb5a9afc0d8aa16fdaa9b3b6b4ffd Mon Sep 17 00:00:00 2001 From: Florent Flament <contact@florentflament.com> Date: Wed, 11 Jan 2017 23:12:30 +0100 Subject: [PATCH 182/407] Add Atari 2600 documentation --- doc/atari2600.sgml | 124 +++++++++++++++++++++++++++++++++++++++++++++ doc/ca65.sgml | 1 + doc/cc65.sgml | 4 ++ doc/index.sgml | 3 ++ doc/intro.sgml | 29 +++++++++++ doc/ld65.sgml | 1 + 6 files changed, 162 insertions(+) create mode 100644 doc/atari2600.sgml diff --git a/doc/atari2600.sgml b/doc/atari2600.sgml new file mode 100644 index 000000000..ae1b6cb5c --- /dev/null +++ b/doc/atari2600.sgml @@ -0,0 +1,124 @@ +<!doctype linuxdoc system> + +<article> + +<title>Atari 2600 specific information for cc65 +<author> +<url url="mailto:contact@florentflament.com" name="Florent Flament"><newline> +<date>2017-01-11 + +<abstract> +An overview over the Atari 2600 runtime system as it is implemented +for the cc65 C compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview<p> + +This file contains an overview of the Atari 2600 runtime system as it +comes with the cc65 C compiler. It describes the memory layout, Atari +2600 specific header files and any pitfalls specific to that platform. + +<sect>Binary format<p> + +The default binary output format generated by the linker for the Atari +2600 target is a 4K cartridge image. + +<sect>Memory layout<p> + +cc65 generated programs with the default setup can use RAM from +$0080 to $00FF - __STACKSIZE__, where __STACKSIZE__ is +the size of the system stack with a default value of 16 bytes. The +size of the system stack can be customized by defining the +__STACKSIZE__ linker variable. + +Special locations: + +<descrip> + <tag/Stack/ The C runtime stack is located at $00FF - + __STACKSIZE__ and growing downwards. + + <tag/Heap/ The C heap is located at $0080 and grows upwards. + +</descrip><p> + +<sect>Start-up condition<p> + +When powered-up, the Atari 2600 TIA registers contain random +values. During the initialization phase, the start-up code needs to +initialize the TIA registers to sound values (or else the console has +an unpredictable behavior). In this implementation, zeros are written +to all of TIA registers during the start-up phase. + +Note that RIOT registers (mostly timers) are left uninitialized, as +they don't have any consequence on the console behavior. + +<sect>Platform specific header files<p> + +Programs containing Atari 2600 specific code may use the +<tt/atari2600.h/ header file. + +The following pseudo variables declared in the <tt/atari2600.h/ header +file allow access to the Atari 2600 TIA & RIOT chips registers. + +<descrip> + + <tag><tt/TIA/</tag> The <tt/TIA/ structure allows read/write access + to the Atari 2600 TIA chip registers. See the <tt/_tia.h/ header + file located in the include directory for the declaration of the + structure. Also refer to the Stella Programmer's Guide by Steve + Wright for a detailed description of the chip and its registers. + + <tag><tt/RIOT/</tag> The <tt/RIOT/ structure allows read/write + access to the Atari 2600 RIOT chip registers. See the + <tt/_riot.h/ header file located in the include directory for the + declaration of the structure. Also refer to the Stella Programmer's + Guide by Steve Wright for a detailed description of the chip and its + registers. + +</descrip><p> + + +<sect>Loadable drivers<p> + +There are no drivers for the Atari 2600. + + +<sect>Limitations<p> + +TBD + + +<sect>Other hints<p> + +One may write a custom linker configuration file to tune the memory +layout of a program. See the <tt/atari2600.cfg/ file in the cfg +directory as a starting point. + + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 2c43a9b50..da0233c62 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4583,6 +4583,7 @@ compiler, depending on the target system selected: <itemize> <item><tt/__APPLE2__/ - Target system is <tt/apple2/ or <tt/apple2enh/ <item><tt/__APPLE2ENH__/ - Target system is <tt/apple2enh/ +<item><tt/__ATARI2600__/ - Target system is <tt/atari2600/ <item><tt/__ATARI5200__/ - Target system is <tt/atari5200/ <item><tt/__ATARI__/ - Target system is <tt/atari/ or <tt/atarixl/ <item><tt/__ATARIXL__/ - Target system is <tt/atarixl/ diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 3e59d4cf0..80dba89b8 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -752,6 +752,10 @@ The compiler defines several macros at startup: This macro is defined if the target is the enhanced Apple //e (-t apple2enh). + <tag><tt>__ATARI2600__</tt></tag> + + This macro is defined if the target is the Atari 2600 game console. + <tag><tt>__ATARI5200__</tt></tag> This macro is defined if the target is the Atari 5200 game console. diff --git a/doc/index.sgml b/doc/index.sgml index 44b58ef5e..9b7ab794e 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -116,6 +116,9 @@ <tag><htmlurl url="atari.html" name="atari.html"></tag> Topics specific to the Atari 8-bit machines. + <tag><htmlurl url="atari2600.html" name="atari2600.html"></tag> + Topics specific to the Atari 2600 Game Console. + <tag><htmlurl url="atari5200.html" name="atari5200.html"></tag> Topics specific to the Atari 5200 Game Console. diff --git a/doc/intro.sgml b/doc/intro.sgml index d92fd1d20..bb8965c60 100644 --- a/doc/intro.sgml +++ b/doc/intro.sgml @@ -335,6 +335,35 @@ your harddrive directly. to the DOS menu. Your C program should wait for a keypress if you want to see any output. +<sect2>Stella<p> +Available at <url +url="http://stella.sourceforge.net">: + +Stella is a multi-platform Atari 2600 VCS emulator. The latest version +is available on the emulator's website. It is also available through +the package manager of most Linux distributions (Fedora, Ubuntu, ..). + +Compile the Atari 2600 sample with + +<tscreen><verb> +make SYS=atari2600 samples +</verb></tscreen> + +Then execute it with + +<tscreen><verb> +stella samples/atari2600hello +</verb></tscreen> + +<sect2>Harmony Cartridge<p> +Available at <url +url="http://harmony.atariage.com/Site/Harmony.html">: + +The Harmony Cartridge allows running any Atari 2600 binary on real +hardware. The binary must be copied on an SD card, to be inserted in +the Harmony Cartridge. It can then be inserted on an Atari 2600 +console, and run any binary on the SD card. + <sect1>Atmos diff --git a/doc/ld65.sgml b/doc/ld65.sgml index 448157ce0..5687aa8ab 100644 --- a/doc/ld65.sgml +++ b/doc/ld65.sgml @@ -156,6 +156,7 @@ Here is a description of all of the command-line options: <item>module <item>apple2 <item>apple2enh + <item>atari2600 <item>atari <item>atarixl <item>atmos From 54ff808c2ce007cdae3418a82b4affcf8e0fe2fc Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 18 Jan 2017 16:05:47 -0500 Subject: [PATCH 183/407] Added a way to show the default mouse pointer on C64 TGI (graphics) screens. --- doc/c64.sgml | 27 +++++++++++++++++++++------ libsrc/c64/extra/tgimousedata.s | 21 +++++++++++++++++++++ libsrc/c64/tgi/c64-hi.s | 10 +++++----- 3 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 libsrc/c64/extra/tgimousedata.s diff --git a/doc/c64.sgml b/doc/c64.sgml index 40bcb37ac..645b57491 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -3,8 +3,9 @@ <article> <title>Commodore 64-specific information for cc65 -<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>2014-04-14 +<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"><newline> +<url url="mailto:greg.king5@verizon.net" name="Greg King"> +<date>2017-01-18 <abstract> An overview over the C64 runtime system as it is implemented for the cc65 C @@ -235,12 +236,22 @@ structures, accessing the struct fields will access the chip registers. The names in the parentheses denote the symbols to be used for static linking of the drivers. +<label id="graphics-drivers"> <sect1>Graphics drivers<p> <em>Note:</em> All available graphics drivers for the TGI interface will use -the space below the I/O area and kernal ROM, so you can have hires graphics in -the standard setup without any memory loss or need for a changed -configuration. +the space below the I/O area and Kernal ROM; so, you can have hires graphics in +the standard setup without any memory loss or need for a changed configuration. + +You can use a mouse driver at the same time that you use a TGI driver. But, if +you want to see the default mouse pointer on the graphics screen, then you +explicitly must link a special object file into your program. It will put the +arrow into the "high RAM" area where the bitmaps are put. It's name is +"<tt/c64-tgimousedata.o/". Example: + +<tscreen><verb> +cl65 -t c64 -o program-file main-code.c subroutines.s c64-tgimousedata.o +</verb></tscreen> <descrip> <tag><tt/c64-hi.tgi (c64_hi_tgi)/</tag> @@ -251,7 +262,8 @@ configuration. Note that the graphics drivers are incompatible with the <tt/c64-ram.emd (c64_ram_emd)/ extended memory driver and the - <tt/c64-soft80.o/ software 80 columns conio driver. + <tt/c64-soft80.o/ software 80-columns conio driver. + <sect1>Extended memory drivers<p> @@ -336,6 +348,9 @@ The default drivers, <tt/joy_stddrv (joy_static_stddrv)/, point to <tt/c64-stdjo <sect1>Mouse drivers<p> +You can use these drivers in text-mode or graphics-mode (TGI) programs. See +the description of <ref id="graphics-drivers" name="the graphics drivers">. + The default drivers, <tt/mouse_stddrv (mouse_static_stddrv)/, point to <tt/c64-1351.mou (c64_1351_mou)/. <descrip> diff --git a/libsrc/c64/extra/tgimousedata.s b/libsrc/c64/extra/tgimousedata.s new file mode 100644 index 000000000..f4087e106 --- /dev/null +++ b/libsrc/c64/extra/tgimousedata.s @@ -0,0 +1,21 @@ +; C64 sprite addresses for the TGI mouse pointer +; +; 2017-01-13, Greg King + +; In order to provide a visible mouse pointer during TGI's graphics mode, +; the object file "c64-tgimousedata.o" must be linked explicitly into +; a program file. Example: +; +; cl65 -t c64 -o program-file main-code.c subroutines.s c64-tgimousedata.o +; +; Note: Currently, a program cannot have default +; pointers for both text and graphic modes. + +; The TGI graphics mode uses VIC-II's 16K bank number three. +; +; Address of the TGI bitmap's color RAM + +COLORMAP := $D000 + + .export mcb_spritepointer := COLORMAP + $03F8 + .export mcb_spritememory := COLORMAP + $0400 diff --git a/libsrc/c64/tgi/c64-hi.s b/libsrc/c64/tgi/c64-hi.s index 6d33f00a8..580220ecc 100644 --- a/libsrc/c64/tgi/c64-hi.s +++ b/libsrc/c64/tgi/c64-hi.s @@ -1,7 +1,9 @@ ; ; Graphics driver for the 320x200x2 mode on the C64. ; -; Based on Stephen L. Judds GRLIB code +; Based on Stephen L. Judd's GRLIB code. +; +; 2017-01-13, Greg King ; .include "zeropage.inc" @@ -351,7 +353,7 @@ SETPALETTE: @L2: sta CBASE+$0000,y sta CBASE+$0100,y sta CBASE+$0200,y - sta CBASE+$0300,y + sta CBASE+$02e8,y iny bne @L2 pla @@ -872,7 +874,7 @@ TEXTSTYLE: OUTTEXT: ; Calculate a pointer to the representation of the character in the -; character ROM +; character ROM ldx #((>(CHARROM + $0800)) >> 3) ldy #0 @@ -957,5 +959,3 @@ CALC: lda Y1 lda #00 @L9: sta INRANGE rts - - From 69c293919a6c272033713ebba227aecb47fe7324 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 22 Jan 2017 12:04:21 +0100 Subject: [PATCH 184/407] Fixed typo. --- doc/c64.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/c64.sgml b/doc/c64.sgml index 645b57491..9ab9b96c3 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -246,7 +246,7 @@ the standard setup without any memory loss or need for a changed configuration. You can use a mouse driver at the same time that you use a TGI driver. But, if you want to see the default mouse pointer on the graphics screen, then you explicitly must link a special object file into your program. It will put the -arrow into the "high RAM" area where the bitmaps are put. It's name is +arrow into the "high RAM" area where the bitmaps are put. Its name is "<tt/c64-tgimousedata.o/". Example: <tscreen><verb> From 038ac5a65a1f56af105635ceb2065af0a1a53ec0 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 22 Jan 2017 21:41:49 +0100 Subject: [PATCH 185/407] Correcting doc adding telemon 2.4 primitives --- doc/telemon24.sgml | 42 +++++ doc/telemon30.sgml | 177 +++++++++++++++++++++ libsrc/telemon24/_scrsize.s | 19 +++ libsrc/telemon24/crt0.s | 101 ++++++++++++ libsrc/telemon24/ctype.s | 299 +++++++++++++++++++++++++++++++++++ libsrc/telemon24/hires.s | 22 +++ libsrc/telemon24/mainargs.s | 36 +++++ libsrc/telemon24/oserrlist.s | 75 +++++++++ libsrc/telemon24/oserror.s | 17 ++ libsrc/telemon24/print.s | 25 +++ libsrc/telemon24/sysuname.s | 46 ++++++ libsrc/telemon24/tapehdr.s | 36 +++++ libsrc/telemon24/write.s | 59 +++++++ 13 files changed, 954 insertions(+) create mode 100644 doc/telemon24.sgml create mode 100644 doc/telemon30.sgml create mode 100644 libsrc/telemon24/_scrsize.s create mode 100644 libsrc/telemon24/crt0.s create mode 100644 libsrc/telemon24/ctype.s create mode 100644 libsrc/telemon24/hires.s create mode 100644 libsrc/telemon24/mainargs.s create mode 100644 libsrc/telemon24/oserrlist.s create mode 100644 libsrc/telemon24/oserror.s create mode 100644 libsrc/telemon24/print.s create mode 100644 libsrc/telemon24/sysuname.s create mode 100644 libsrc/telemon24/tapehdr.s create mode 100644 libsrc/telemon24/write.s diff --git a/doc/telemon24.sgml b/doc/telemon24.sgml new file mode 100644 index 000000000..b4e1befa1 --- /dev/null +++ b/doc/telemon24.sgml @@ -0,0 +1,42 @@ +<!doctype linuxdoc system> + +<article> + +<title>Oric Telemon 2.4 -specific information for cc65 +<author> + +<url url="mailto:greg.king5@verizon.net" name="Greg King"> +<date>2017-01-22 + +<abstract> +An overview over the Telemon 3.0 runtime system as it is implemented for the cc65 C +compiler. +</abstract> + +<!-- Table of contents --> +<toc> + + + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> diff --git a/doc/telemon30.sgml b/doc/telemon30.sgml new file mode 100644 index 000000000..ce9e044b4 --- /dev/null +++ b/doc/telemon30.sgml @@ -0,0 +1,177 @@ +<!doctype linuxdoc system> + +<article> + +<title>Oric Telestrat-specific information for cc65 +<author> +<url url="mailto:jede@oric.org" name="Jede">,<newline> + +<date>2017-01-22 + +<abstract> +An overview over the Telestrat (telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C +compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview<p> + +This file contains an overview of the Telestrat runtime system as it comes with the +cc65 C compiler. It describes the memory layout, Telemon3.0-specific header files, +available drivers, and any pitfalls specific to that platform. + +Please note that Telemon3.0-specific functions are just mentioned here, they are +described in detail in the separate <url url="funcref.html" name="function +reference">. Even functions marked as "platform dependent" may be available on +more than one platform. Please see the function reference for more +information. + + + +<sect>Binary format<p> + +The standard binary output format generated by the linker for the Telemon 3.0 target +is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header + + + +<sect>Memory layout<p> + +In the standard setup, cc65-generated programs use the memory from +$0801 to $9800; so, nearly 37K of memory (including the stack) is +available. ROM calls are possible without further precautions. + + + +Special locations: + +<descrip> + <tag/Stack/ + The C runtime stack is located at $97FF (or $B3FF), and grows + downwards. + + <tag/Heap/ + The C heap is located at the end of the program, and grows towards the C + runtime stack. + +</descrip><p> + + + +<sect>Platform-specific header files<p> + +Programs containing Telemon 3.0 -specific code may use the <tt/telemon.h/ header file. + + +<sect1>Telemon 3.0-specific functions<p> + +The functions listed below are special for the Telemon 3.0. See the <url +url="funcref.html" name="function reference"> for declaration and usage. + +<itemize> +<item>explode +<item>ping +<item>shoot +<item>zap +<item>oupsx +</itemize> + + +<sect1>Hardware access<p> + +The following pseudo variables declared in the <tt/atmos.h/ header file do allow +access to hardware located in the address space. Some variables are +structures; accessing the struct fields will access the chip registers. + +<descrip> + + <tag><tt/VIA/</tag> + Access to the VIA (Versatile Interface Adapter) chip is available via the + <tt/VIA/ variable. The structure behind this variable is explained in <tt/_6522.h/. + +</descrip><p> + + + +<sect>Loadable drivers<p> + +<em>Note:</em> Since the Atmos doesn't have working disk I/O +(see <ref id="limitations" name="section "Limitations"">), the +available drivers cannot be loaded at runtime (so the term "loadable drivers" +is somewhat misleading). Instead, the drivers have to be statically linked. While +this may seem overhead, it has two advantages: + + +<sect1>Extended memory drivers<p> + +No extended memory drivers are currently available for the Atmos. + + +<sect1>Joystick drivers<p> + +<descrip> + +telemon 3.0 manages joysticks but it had been handled yet. + +</descrip><p> + + +<sect1>Mouse drivers<p> + +Telemon 3.0 manages also mouse, but it had been no handled yet in this version. + +<sect1>RS232 device drivers<p> + +<descrip> + +not done + +</descrip><p> + + + +<sect>Limitations<label id="limitations"><p> + +<sect1>Disk I/O<p> + +This version handles fopen, fread, fclose primitives. Because Telemon 3.0 handles these two primitives. By the way, +it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. + +<itemize> +<item>fclose +<item>fopen +<item>fread + +</itemize> + + + +<sect>Other hints<p> + + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> diff --git a/libsrc/telemon24/_scrsize.s b/libsrc/telemon24/_scrsize.s new file mode 100644 index 000000000..305e41c46 --- /dev/null +++ b/libsrc/telemon24/_scrsize.s @@ -0,0 +1,19 @@ +; +; 2003-04-13, Ullrich von Bassewitz +; 2013-07-16, Greg King +; +; Screen size variables +; + + .export screensize + .include "telemon24.inc" + +.proc screensize + + ldx #SCREEN_XSIZE + ldy #SCREEN_YSIZE + rts + +.endproc + + diff --git a/libsrc/telemon24/crt0.s b/libsrc/telemon24/crt0.s new file mode 100644 index 000000000..a3c92a360 --- /dev/null +++ b/libsrc/telemon24/crt0.s @@ -0,0 +1,101 @@ +; +; Startup code for cc65 (Oric version) +; +; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org> +; 2016-03-18, Greg King +; + + .export _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + + .import initlib, donelib + .import callmain, zerobss + .import __MAIN_START__, __MAIN_SIZE__ + + .include "zeropage.inc" + .include "telemon24.inc" + +; ------------------------------------------------------------------------ +; Place the startup code in a special segment. + +.segment "STARTUP" + + tsx + stx spsave ; Save system stk ptr + +; Save space by putting some of the start-up code in a segment +; that will be re-used. + + jsr init + +; Clear the BSS variables (after the constructors have been run). + + jsr zerobss + +; Push the command-line arguments; and, call main(). + + jsr callmain + +; Call the module destructors. This is also the exit() entry. + +_exit: jsr donelib + +; Restore the system stuff. + + ldx spsave + txs +; lda stsave + ; sta STATUS + +; Copy back the zero-page stuff. + + ldx #zpspace - 1 +L2: lda zpsave,x + sta sp,x + dex + bpl L2 + +; Back to BASIC. + + rts + +; ------------------------------------------------------------------------ +; Put this code in a place that will be re-used by BSS, the heap, +; and the C stack. + +.segment "ONCE" + +; Save the zero-page area that we're about to use. + +init: ldx #zpspace - 1 +L1: lda sp,x + sta zpsave,x + dex + bpl L1 + +; Currently, color isn't supported on the text screen. +; Unprotect screen columns 0 and 1 (where each line's color codes would sit). + + ; lda STATUS + ; sta stsave + ; and #%11011111 + ; sta STATUS + +; Set up the C stack. + + lda #<(__MAIN_START__ + __MAIN_SIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__) + sta sp + stx sp+1 ; Set argument stack ptr + +; Call the module constructors. + + jmp initlib + +; ------------------------------------------------------------------------ + +.segment "INIT" + +spsave: .res 1 +stsave: .res 1 +zpsave: .res zpspace diff --git a/libsrc/telemon24/ctype.s b/libsrc/telemon24/ctype.s new file mode 100644 index 000000000..79edafbb2 --- /dev/null +++ b/libsrc/telemon24/ctype.s @@ -0,0 +1,299 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; Character specification table. +; + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it were'nt for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). +; +; * It is highly portable. The only unportable part is the table itself, +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. +; +; +; Bit assignments: +; +; 0 - Lower case char +; 1 - Upper case char +; 2 - Numeric digit +; 3 - Hex digit (both, lower and upper) +; 4 - Control character +; 5 - The space character itself +; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v') +; 7 - Space or tab character + + .export __ctype + +__ctype: + .byte $10 ; 0/00 ___ctrl_@___ + .byte $10 ; 1/01 ___ctrl_A___ + .byte $10 ; 2/02 ___ctrl_B___ + .byte $10 ; 3/03 ___ctrl_C___ + .byte $10 ; 4/04 ___ctrl_D___ + .byte $10 ; 5/05 ___ctrl_E___ + .byte $10 ; 6/06 ___ctrl_F___ + .byte $10 ; 7/07 ___ctrl_G___ + .byte $10 ; 8/08 ___ctrl_H___ + .byte $D0 ; 9/09 ___ctrl_I___ + .byte $50 ; 10/0a ___ctrl_J___ + .byte $50 ; 11/0b ___ctrl_K___ + .byte $50 ; 12/0c ___ctrl_L___ + .byte $50 ; 13/0d ___ctrl_M___ + .byte $10 ; 14/0e ___ctrl_N___ + .byte $10 ; 15/0f ___ctrl_O___ + .byte $10 ; 16/10 ___ctrl_P___ + .byte $10 ; 17/11 ___ctrl_Q___ + .byte $10 ; 18/12 ___ctrl_R___ + .byte $10 ; 19/13 ___ctrl_S___ + .byte $10 ; 20/14 ___ctrl_T___ + .byte $10 ; 21/15 ___ctrl_U___ + .byte $10 ; 22/16 ___ctrl_V___ + .byte $10 ; 23/17 ___ctrl_W___ + .byte $10 ; 24/18 ___ctrl_X___ + .byte $10 ; 25/19 ___ctrl_Y___ + .byte $10 ; 26/1a ___ctrl_Z___ + .byte $10 ; 27/1b ___ctrl_[___ + .byte $10 ; 28/1c ___ctrl_\___ + .byte $10 ; 29/1d ___ctrl_]___ + .byte $10 ; 30/1e ___ctrl_^___ + .byte $10 ; 31/1f ___ctrl_____ + .byte $A0 ; 32/20 ___SPACE___ + .byte $00 ; 33/21 _____!_____ + .byte $00 ; 34/22 _____"_____ + .byte $00 ; 35/23 _____#_____ + .byte $00 ; 36/24 _____$_____ + .byte $00 ; 37/25 _____%_____ + .byte $00 ; 38/26 _____&_____ + .byte $00 ; 39/27 _____'_____ + .byte $00 ; 40/28 _____(_____ + .byte $00 ; 41/29 _____)_____ + .byte $00 ; 42/2a _____*_____ + .byte $00 ; 43/2b _____+_____ + .byte $00 ; 44/2c _____,_____ + .byte $00 ; 45/2d _____-_____ + .byte $00 ; 46/2e _____._____ + .byte $00 ; 47/2f _____/_____ + .byte $0C ; 48/30 _____0_____ + .byte $0C ; 49/31 _____1_____ + .byte $0C ; 50/32 _____2_____ + .byte $0C ; 51/33 _____3_____ + .byte $0C ; 52/34 _____4_____ + .byte $0C ; 53/35 _____5_____ + .byte $0C ; 54/36 _____6_____ + .byte $0C ; 55/37 _____7_____ + .byte $0C ; 56/38 _____8_____ + .byte $0C ; 57/39 _____9_____ + .byte $00 ; 58/3a _____:_____ + .byte $00 ; 59/3b _____;_____ + .byte $00 ; 60/3c _____<_____ + .byte $00 ; 61/3d _____=_____ + .byte $00 ; 62/3e _____>_____ + .byte $00 ; 63/3f _____?_____ + + .byte $00 ; 64/40 _____@_____ + .byte $0A ; 65/41 _____A_____ + .byte $0A ; 66/42 _____B_____ + .byte $0A ; 67/43 _____C_____ + .byte $0A ; 68/44 _____D_____ + .byte $0A ; 69/45 _____E_____ + .byte $0A ; 70/46 _____F_____ + .byte $02 ; 71/47 _____G_____ + .byte $02 ; 72/48 _____H_____ + .byte $02 ; 73/49 _____I_____ + .byte $02 ; 74/4a _____J_____ + .byte $02 ; 75/4b _____K_____ + .byte $02 ; 76/4c _____L_____ + .byte $02 ; 77/4d _____M_____ + .byte $02 ; 78/4e _____N_____ + .byte $02 ; 79/4f _____O_____ + .byte $02 ; 80/50 _____P_____ + .byte $02 ; 81/51 _____Q_____ + .byte $02 ; 82/52 _____R_____ + .byte $02 ; 83/53 _____S_____ + .byte $02 ; 84/54 _____T_____ + .byte $02 ; 85/55 _____U_____ + .byte $02 ; 86/56 _____V_____ + .byte $02 ; 87/57 _____W_____ + .byte $02 ; 88/58 _____X_____ + .byte $02 ; 89/59 _____Y_____ + .byte $02 ; 90/5a _____Z_____ + .byte $00 ; 91/5b _____[_____ + .byte $00 ; 92/5c _____\_____ + .byte $00 ; 93/5d _____]_____ + .byte $00 ; 94/5e _____^_____ + .byte $00 ; 95/5f _UNDERLINE_ + .byte $00 ; 96/60 ___grave___ + .byte $09 ; 97/61 _____a_____ + .byte $09 ; 98/62 _____b_____ + .byte $09 ; 99/63 _____c_____ + .byte $09 ; 100/64 _____d_____ + .byte $09 ; 101/65 _____e_____ + .byte $09 ; 102/66 _____f_____ + .byte $01 ; 103/67 _____g_____ + .byte $01 ; 104/68 _____h_____ + .byte $01 ; 105/69 _____i_____ + .byte $01 ; 106/6a _____j_____ + .byte $01 ; 107/6b _____k_____ + .byte $01 ; 108/6c _____l_____ + .byte $01 ; 109/6d _____m_____ + .byte $01 ; 110/6e _____n_____ + .byte $01 ; 111/6f _____o_____ + .byte $01 ; 112/70 _____p_____ + .byte $01 ; 113/71 _____q_____ + .byte $01 ; 114/72 _____r_____ + .byte $01 ; 115/73 _____s_____ + .byte $01 ; 116/74 _____t_____ + .byte $01 ; 117/75 _____u_____ + .byte $01 ; 118/76 _____v_____ + .byte $01 ; 119/77 _____w_____ + .byte $01 ; 120/78 _____x_____ + .byte $01 ; 121/79 _____y_____ + .byte $01 ; 122/7a _____z_____ + .byte $00 ; 123/7b _____{_____ + .byte $00 ; 124/7c _____|_____ + .byte $00 ; 125/7d _____}_____ + .byte $00 ; 126/7e _____~_____ + .byte $40 ; 127/7f ____DEL____ + + .byte $00 ; 128/80 ___________ + .byte $00 ; 129/81 ___________ + .byte $00 ; 130/82 ___________ + .byte $00 ; 131/83 ___________ + .byte $00 ; 132/84 ___________ + .byte $00 ; 133/85 ___________ + .byte $00 ; 134/86 ___________ + .byte $00 ; 135/87 ___________ + .byte $00 ; 136/88 ___________ + .byte $00 ; 137/89 ___________ + .byte $00 ; 138/8a ___________ + .byte $00 ; 139/8b ___________ + .byte $00 ; 140/8c ___________ + .byte $00 ; 141/8d ___________ + .byte $00 ; 142/8e ___________ + .byte $00 ; 143/8f ___________ + .byte $00 ; 144/90 ___________ + .byte $00 ; 145/91 ___________ + .byte $00 ; 146/92 ___________ + .byte $10 ; 147/93 ___________ + .byte $00 ; 148/94 ___________ + .byte $00 ; 149/95 ___________ + .byte $00 ; 150/96 ___________ + .byte $00 ; 151/97 ___________ + .byte $00 ; 152/98 ___________ + .byte $00 ; 153/99 ___________ + .byte $00 ; 154/9a ___________ + .byte $00 ; 155/9b ___________ + .byte $00 ; 156/9c ___________ + .byte $00 ; 157/9d ___________ + .byte $00 ; 158/9e ___________ + .byte $00 ; 159/9f ___________ + + .byte $00 ; 160/a0 ___________ + .byte $00 ; 161/a1 ___________ + .byte $00 ; 162/a2 ___________ + .byte $00 ; 163/a3 ___________ + .byte $00 ; 164/a4 ___________ + .byte $00 ; 165/a5 ___________ + .byte $00 ; 166/a6 ___________ + .byte $00 ; 167/a7 ___________ + .byte $00 ; 168/a8 ___________ + .byte $00 ; 169/a9 ___________ + .byte $00 ; 170/aa ___________ + .byte $00 ; 171/ab ___________ + .byte $00 ; 172/ac ___________ + .byte $00 ; 173/ad ___________ + .byte $00 ; 174/ae ___________ + .byte $00 ; 175/af ___________ + .byte $00 ; 176/b0 ___________ + .byte $00 ; 177/b1 ___________ + .byte $00 ; 178/b2 ___________ + .byte $00 ; 179/b3 ___________ + .byte $00 ; 180/b4 ___________ + .byte $00 ; 181/b5 ___________ + .byte $00 ; 182/b6 ___________ + .byte $00 ; 183/b7 ___________ + .byte $00 ; 184/b8 ___________ + .byte $00 ; 185/b9 ___________ + .byte $00 ; 186/ba ___________ + .byte $00 ; 187/bb ___________ + .byte $00 ; 188/bc ___________ + .byte $00 ; 189/bd ___________ + .byte $00 ; 190/be ___________ + .byte $00 ; 191/bf ___________ + + .byte $02 ; 192/c0 ___________ + .byte $02 ; 193/c1 ___________ + .byte $02 ; 194/c2 ___________ + .byte $02 ; 195/c3 ___________ + .byte $02 ; 196/c4 ___________ + .byte $02 ; 197/c5 ___________ + .byte $02 ; 198/c6 ___________ + .byte $02 ; 199/c7 ___________ + .byte $02 ; 200/c8 ___________ + .byte $02 ; 201/c9 ___________ + .byte $02 ; 202/ca ___________ + .byte $02 ; 203/cb ___________ + .byte $02 ; 204/cc ___________ + .byte $02 ; 205/cd ___________ + .byte $02 ; 206/ce ___________ + .byte $02 ; 207/cf ___________ + .byte $02 ; 208/d0 ___________ + .byte $02 ; 209/d1 ___________ + .byte $02 ; 210/d2 ___________ + .byte $02 ; 211/d3 ___________ + .byte $02 ; 212/d4 ___________ + .byte $02 ; 213/d5 ___________ + .byte $02 ; 214/d6 ___________ + .byte $02 ; 215/d7 ___________ + .byte $02 ; 216/d8 ___________ + .byte $02 ; 217/d9 ___________ + .byte $02 ; 218/da ___________ + .byte $02 ; 219/db ___________ + .byte $02 ; 220/dc ___________ + .byte $02 ; 221/dd ___________ + .byte $02 ; 222/de ___________ + .byte $00 ; 223/df ___________ + .byte $01 ; 224/e0 ___________ + .byte $01 ; 225/e1 ___________ + .byte $01 ; 226/e2 ___________ + .byte $01 ; 227/e3 ___________ + .byte $01 ; 228/e4 ___________ + .byte $01 ; 229/e5 ___________ + .byte $01 ; 230/e6 ___________ + .byte $01 ; 231/e7 ___________ + .byte $01 ; 232/e8 ___________ + .byte $01 ; 233/e9 ___________ + .byte $01 ; 234/ea ___________ + .byte $01 ; 235/eb ___________ + .byte $01 ; 236/ec ___________ + .byte $01 ; 237/ed ___________ + .byte $01 ; 238/ee ___________ + .byte $01 ; 239/ef ___________ + .byte $01 ; 240/f0 ___________ + .byte $01 ; 241/f1 ___________ + .byte $01 ; 242/f2 ___________ + .byte $01 ; 243/f3 ___________ + .byte $01 ; 244/f4 ___________ + .byte $01 ; 245/f5 ___________ + .byte $01 ; 246/f6 ___________ + .byte $01 ; 247/f7 ___________ + .byte $01 ; 248/f8 ___________ + .byte $01 ; 249/f9 ___________ + .byte $01 ; 250/fa ___________ + .byte $01 ; 251/fb ___________ + .byte $01 ; 252/fc ___________ + .byte $01 ; 253/fd ___________ + .byte $01 ; 254/fe ___________ + .byte $00 ; 255/ff ___________ + diff --git a/libsrc/telemon24/hires.s b/libsrc/telemon24/hires.s new file mode 100644 index 000000000..80d67824c --- /dev/null +++ b/libsrc/telemon24/hires.s @@ -0,0 +1,22 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; void hires(void); +; +; This function is a hack! +; + + .export _hires + + + .include "telemon24.inc" + + +; can be optimized with a macro +.proc _hires + brk + .byt $1a + rts +.endproc + + diff --git a/libsrc/telemon24/mainargs.s b/libsrc/telemon24/mainargs.s new file mode 100644 index 000000000..d8547e500 --- /dev/null +++ b/libsrc/telemon24/mainargs.s @@ -0,0 +1,36 @@ +; +; 2003-03-07, Ullrich von Bassewitz +; 2011-01-28, Stefan Haubenthal +; 2014-09-10, Greg King +; +; Set up arguments for main +; + + .constructor initmainargs, 24 + .import __argc, __argv + + .include "telemon24.inc" + .macpack generic + +MAXARGS = 10 ; Maximum number of arguments allowed + + +.segment "ONCE" + +.proc initmainargs + +.endproc + +.segment "INIT" + +term: .res 1 +name: .res FNAME_LEN + 1 +args: .res SCREEN_XSIZE * 2 - 1 + +.data + +; This array has zeroes when initmainargs starts. +; char* argv[MAXARGS+1]={name}; + +argv: .addr name + .res MAXARGS * 2 diff --git a/libsrc/telemon24/oserrlist.s b/libsrc/telemon24/oserrlist.s new file mode 100644 index 000000000..8ec41de6d --- /dev/null +++ b/libsrc/telemon24/oserrlist.s @@ -0,0 +1,75 @@ +; +; Stefan Haubenthal, 2004-05-25 +; Ullrich von Bassewitz, 18.07.2002 +; +; Defines the platform specific error list. +; +; The table is built as a list of entries +; +; .byte entrylen +; .byte errorcode +; .asciiz errormsg +; +; and terminated by an entry with length zero that is returned if the +; error code could not be found. +; + + .export __sys_oserrlist + +;---------------------------------------------------------------------------- +; Macros used to generate the list (may get moved to an include file?) + +; Regular entry +.macro sys_oserr_entry code, msg + .local Start, End +Start: .byte End - Start + .byte code + .asciiz msg +End: +.endmacro + +; Sentinel entry +.macro sys_oserr_sentinel msg + .byte 0 ; Length is always zero + .byte 0 ; Code is unused + .asciiz msg +.endmacro + +;---------------------------------------------------------------------------- +; The error message table + +.rodata + +__sys_oserrlist: + sys_oserr_entry 1, "File not found" + sys_oserr_entry 2, "Invalid command end" + sys_oserr_entry 3, "No drive number" + sys_oserr_entry 4, "Bad drive number" + sys_oserr_entry 5, "Invalid filename" + sys_oserr_entry 6, "fderr=(error number)" + sys_oserr_entry 7, "Illegal attribute" + sys_oserr_entry 8, "Wildcard(s) not allowed" + sys_oserr_entry 9, "File already exists" + sys_oserr_entry 10, "Insufficient disc space" + sys_oserr_entry 11, "File open" + sys_oserr_entry 12, "Illegal quantity" + sys_oserr_entry 13, "End address missing" + sys_oserr_entry 14, "Start address > end address" + sys_oserr_entry 15, "Missing 'to'" + sys_oserr_entry 16, "Renamed file not on same disc" + sys_oserr_entry 17, "Unknown array" + sys_oserr_entry 18, "Target drive not source drive" + sys_oserr_entry 19, "Destination not specified" + sys_oserr_entry 20, "Cannot merge and overwrite" + sys_oserr_entry 21, "Single target file illegal" + sys_oserr_entry 22, "Syntax" + sys_oserr_entry 23, "Filename missing" + sys_oserr_entry 24, "Source file missing" + sys_oserr_entry 25, "Type mismatch" + sys_oserr_entry 26, "Disc write-protected" + sys_oserr_entry 27, "Incompatible drives" + sys_oserr_entry 28, "File not open" + sys_oserr_entry 29, "File end" + sys_oserr_sentinel "Unknown error" + + diff --git a/libsrc/telemon24/oserror.s b/libsrc/telemon24/oserror.s new file mode 100644 index 000000000..37c9bd7fc --- /dev/null +++ b/libsrc/telemon24/oserror.s @@ -0,0 +1,17 @@ +; +; Stefan Haubenthal, 2011-04-18 +; +; int __fastcall__ _osmaperrno (unsigned char oserror); +; /* Map a system specific error into a system independent code */ +; + + .include "errno.inc" + .export __osmaperrno + +.proc __osmaperrno + + lda #<EUNKNOWN + ldx #>EUNKNOWN + rts + +.endproc diff --git a/libsrc/telemon24/print.s b/libsrc/telemon24/print.s new file mode 100644 index 000000000..a135cdd18 --- /dev/null +++ b/libsrc/telemon24/print.s @@ -0,0 +1,25 @@ +; +; Jede +; +; print (char * str); +; +; This function is a hack! +; + + .export _print + .import popax + .importzp tmp1 + .include "telemon24.inc" + +.proc _print + + jsr popax ; get buf + stx tmp1 + ldy tmp1 + brk + .byte $14 + rts + +.endproc + + diff --git a/libsrc/telemon24/sysuname.s b/libsrc/telemon24/sysuname.s new file mode 100644 index 000000000..51af1d8fe --- /dev/null +++ b/libsrc/telemon24/sysuname.s @@ -0,0 +1,46 @@ +; +; Ullrich von Bassewitz, 2003-08-12 +; +; unsigned char __fastcall__ _sysuname (struct utsname* buf); +; + + .export __sysuname, utsdata + + .import utscopy + + __sysuname = utscopy + +;-------------------------------------------------------------------------- +; Data. We define a fixed utsname struct here and just copy it. + +.rodata + +utsdata: + ; sysname + .asciiz "cc65" + + ; nodename + .asciiz "" + + ; release + .byte ((.VERSION >> 8) & $0F) + '0' + .byte '.' + .if ((.VERSION >> 4) & $0F) > 9 + .byte ((.VERSION >> 4) & $0F) / 10 + '0' + .byte ((.VERSION >> 4) & $0F) .MOD 10 + '0' + .else + .byte ((.VERSION >> 4) & $0F) + '0' + .endif + .byte $00 + + ; version + .if (.VERSION & $0F) > 9 + .byte (.VERSION & $0F) / 10 + '0' + .byte (.VERSION & $0F) .MOD 10 + '0' + .else + .byte (.VERSION & $0F) + '0' + .endif + .byte $00 + + ; machine + .asciiz "Oric Telestrat" diff --git a/libsrc/telemon24/tapehdr.s b/libsrc/telemon24/tapehdr.s new file mode 100644 index 000000000..9b183e11e --- /dev/null +++ b/libsrc/telemon24/tapehdr.s @@ -0,0 +1,36 @@ +; +; Based on code by Debrune Jérôme <jede@oric.org> +; 2016-03-17, Greg King +; + + ; The following symbol is used by the linker config. file + ; to force this module to be included into the output file. + .export __ORIXHDR__:abs = 1 + + ; These symbols, also, come from the configuration file. + .import __AUTORUN__, __PROGFLAG__ + .import __BASHEAD_START__, __MAIN_LAST__ + + +; ------------------------------------------------------------------------ +; Oric cassette-tape header + +.segment "ORIXHDR" + + .byte $01, $00 ; + + .byte "ORI" + + .byte $01 ; version + .byte $00,$00 ; mode + .byte $00,$00 ; cpu type + .byte $00,$00 ; OS + + .byte $00 ; reserved + .byte $00 ; auto + + + .dbyt __BASHEAD_START__ ; Address of start of file + .dbyt __MAIN_LAST__ - 1 ; Address of end of file + .dbyt __BASHEAD_START__ ; Address of start of file + diff --git a/libsrc/telemon24/write.s b/libsrc/telemon24/write.s new file mode 100644 index 000000000..32bbf617c --- /dev/null +++ b/libsrc/telemon24/write.s @@ -0,0 +1,59 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; int write (int fd, const void* buf, int count); +; +; This function is a hack! +; + + .export _write + .import popax + .importzp ptr1, ptr2, ptr3, tmp1 + + .include "telemon24.inc" + +.proc _write + + sta ptr3 + stx ptr3+1 ; save count as result + + eor #$FF + sta ptr2 + txa + eor #$FF + sta ptr2+1 ; Remember -count-1 + + jsr popax ; get buf + sta ptr1 + stx ptr1+1 + jsr popax ; get fd and discard +L1: inc ptr2 + bne L2 + inc ptr2+1 + beq L9 +L2: ldy #0 + lda (ptr1),y + tax + cpx #$0A ; Check for \n + bne L3 + brk + .byt $10 + + ldx #$0D +L3: + brk + .byt $10 + inc ptr1 + bne L1 + inc ptr1+1 + jmp L1 + +; No error, return count + +L9: lda ptr3 + ldx ptr3+1 + rts + +.endproc + + From 6f463d60a3c9c61f35fc97a9fbf1ca52282bf5df Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 24 Jan 2017 20:21:56 +0100 Subject: [PATCH 186/407] Small space optimization in libsrc/atari/is_cmdline_dos.s. --- libsrc/atari/is_cmdline_dos.s | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libsrc/atari/is_cmdline_dos.s b/libsrc/atari/is_cmdline_dos.s index 71b35fbad..eb474dbfb 100644 --- a/libsrc/atari/is_cmdline_dos.s +++ b/libsrc/atari/is_cmdline_dos.s @@ -11,10 +11,9 @@ .include "atari.inc" __is_cmdline_dos: - ldx #0 lda __dos_type cmp #MAX_DOS_WITH_CMDLINE + 1 - txa + lda #0 rol a eor #$01 rts From f613ee0f5737d28392232f8cdeaa61249b5e40cc Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 24 Jan 2017 21:01:42 +0100 Subject: [PATCH 187/407] More optimization in libsrc/atari/is_cmdline_dos.s. Suggestion by Spiro Trikaliotis. --- libsrc/atari/is_cmdline_dos.s | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libsrc/atari/is_cmdline_dos.s b/libsrc/atari/is_cmdline_dos.s index eb474dbfb..2a9c49e38 100644 --- a/libsrc/atari/is_cmdline_dos.s +++ b/libsrc/atari/is_cmdline_dos.s @@ -11,9 +11,8 @@ .include "atari.inc" __is_cmdline_dos: - lda __dos_type - cmp #MAX_DOS_WITH_CMDLINE + 1 + lda #MAX_DOS_WITH_CMDLINE + cmp __dos_type lda #0 rol a - eor #$01 rts From bba7c980e44545cdb63bce4084f425a31ee8edec Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Thu, 26 Jan 2017 16:43:47 +0100 Subject: [PATCH 188/407] libsrc/c16/get_tv.s: remove code duplication Use the plus4 version of get_tv.s. --- libsrc/c16/get_tv.s | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/libsrc/c16/get_tv.s b/libsrc/c16/get_tv.s index f6d82a351..1bfe3db97 100644 --- a/libsrc/c16/get_tv.s +++ b/libsrc/c16/get_tv.s @@ -1,27 +1 @@ -; -; Ullrich von Bassewitz, 2002-12-03 -; -; unsigned char __fastcall__ get_tv (void); -; /* Return the video mode the machine is using */ -; - - .include "plus4.inc" - .include "get_tv.inc" - - -;-------------------------------------------------------------------------- -; _get_tv - -.proc _get_tv - - ldx #TV::PAL ; Assume PAL - bit TED_MULTI1 ; Test bit 6 - bvc pal - dex ; NTSC -pal: txa - ldx #0 - rts - -.endproc - - +.include "../plus4/get_tv.s" From d1b5a6632d558c0ffb9b89f1cbf239ae04533b90 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 21:18:49 +0100 Subject: [PATCH 189/407] Adding telemon30 and telemon24 primitives --- asminc/telemon24.inc | 68 ++++++++ asminc/telemon30.inc | 150 ++++++++++++++++++ cfg/telemon24.cfg | 43 +++++ include/telemon30.h | 21 +++ libsrc/telemon30/_close.s | 17 ++ libsrc/telemon30/_open.s | 60 ++----- libsrc/telemon30/_read.s | 46 ++++-- libsrc/telemon30/ch376.s | 307 +++++++++++++++++++++++++++--------- libsrc/telemon30/graphics.s | 13 +- libsrc/telemon30/orixhdr.s | 15 +- libsrc/telemon30/write.s | 22 +++ 11 files changed, 616 insertions(+), 146 deletions(-) create mode 100644 asminc/telemon24.inc create mode 100644 asminc/telemon30.inc create mode 100644 cfg/telemon24.cfg create mode 100644 include/telemon30.h create mode 100644 libsrc/telemon30/_close.s diff --git a/asminc/telemon24.inc b/asminc/telemon24.inc new file mode 100644 index 000000000..0b58d63a6 --- /dev/null +++ b/asminc/telemon24.inc @@ -0,0 +1,68 @@ +; +; Oric Telemon definition +; Telemon 2.4 +; + + +; --------------------------------------------------------------------------- +; Constants + +SCREEN_XSIZE = 40 ; screen columns +SCREEN_YSIZE = 28 ; screen rows + +FUNCTKEY = $A5 + +FNAME_LEN = 11 ; maximum length of file-name + + +; --------------------------------------------------------------------------- +; Zero page + + + + +; --------------------------------------------------------------------------- +; Low memory + + + + +; --------------------------------------------------------------------------- +; I/O locations + +; 6522 +.struct VIA ; Versatile Interface Adapter + .res $0300 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + +; 6551 +.struct ACIA ; Asynchronous Communications Interface Adapter + .res $031C +DATA .byte +STATUS .byte +CMD .byte ; Command register +CTRL .byte ; Control register +.endstruct + +SCREEN := $BB80 + + +; --------------------------------------------------------------------------- +; ROM entries + +XWR0 := $10 +XWSTR0 := $14 + diff --git a/asminc/telemon30.inc b/asminc/telemon30.inc new file mode 100644 index 000000000..acfd7e919 --- /dev/null +++ b/asminc/telemon30.inc @@ -0,0 +1,150 @@ +; +; Oric Telemon definition +; Telemon 2.4 +; + + +; --------------------------------------------------------------------------- +; Constants + +SCREEN_XSIZE = 40 ; screen columns +SCREEN_YSIZE = 28 ; screen rows + +FUNCTKEY = $A5 + +FNAME_LEN = 11 ; maximum length of file-name + + +; --------------------------------------------------------------------------- +; Zero page + + + + +; --------------------------------------------------------------------------- +; Low memory + + + + +; --------------------------------------------------------------------------- +; I/O locations + +; 6522 +.struct VIA ; Versatile Interface Adapter + .res $0300 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + + +.struct VIA2 ; Versatile Interface Adapter + .res $0320 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + +; 6551 +.struct ACIA ; Asynchronous Communications Interface Adapter + .res $031C +DATA .byte +STATUS .byte +CMD .byte ; Command register +CTRL .byte ; Control register +.endstruct + +SCREEN := $BB80 + + +; --------------------------------------------------------------------------- +; ROM entries + +; primitives telemon 2.4 +XRD0 := $08 +XRDW0 := $0c +XWR0 := $10 +XWSTR0 := $14 +XTEXT := $19 +XHIRES := $1A +XMINMA := $1f +XFREAD := $27 ; only in TELEMON 3.0 +XOPEN := $30 ; only in TELEMON 3.0 +XCOSCR := $34 ; switch off cursor +XCSSCR := $35 ; switch on cursor +XCLOSE := $3a ; Close file +XFWRITE:= $3b ; write + +XSONPS := $40 +XOUPS := $42 +XPLAY := $43 +XSOUND := $44 +XMUSIC := $45 +XZAP := $46 +XSHOOT := $47 +XCIRCL := $8f +XCURSE := $90 +XEXPLO := $9c +XPING := $9d +XPAPER := $92 +XINK := $93 + + +; --------------------------------------------------------------------------- +; Page 00 +RES := $00 +RESB := $02 + +TR0 := $0c +TR1 := $0d + +PTR_READ_DEST := $2c ; used for XFREAD and XWRITE + +HRSX := $46 +HRSY := $47 + +HRS1 := $4D +HRS2 := $4F +HRS3 := $51 +HRS4 := $53 +HRS5 := $55 + +; --------------------------------------------------------------------------- +; Page $500 + +BUFNOM := $517 +BUFEDT := $590 + +MAX_BUFEDT_LENGTH=110 + +; Hardware +CH376_DATA :=$340 +CH376_COMMAND :=$341 + +; MACRO + + +.macro BRK_TELEMON value + .byte $00,value +.endmacro diff --git a/cfg/telemon24.cfg b/cfg/telemon24.cfg new file mode 100644 index 000000000..b76350868 --- /dev/null +++ b/cfg/telemon24.cfg @@ -0,0 +1,43 @@ +SYMBOLS { + + __ORIXHDR__: type = import; + + __STACKSIZE__: type = weak, value = $0800; # 2K stack + + __RAMEND__: type = weak, value = $9800 + $1C00 ; +} +MEMORY { + ZP: file = "", define = yes, start = $00E2, size = $001A; + ORIXHDR: file = %O, type = ro, start = $0000, size = $001F; + BASHEAD: file = %O, define = yes, start = $0801, size = $000D; + MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__; + BSS: file = "", start = __ONCE_RUN__, size = __RAMEND__ - __STACKSIZE__ - __ONCE_RUN__; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + ORIXHDR: load = ORIXHDR, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + BASTAIL: load = MAIN, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/include/telemon30.h b/include/telemon30.h new file mode 100644 index 000000000..73b018444 --- /dev/null +++ b/include/telemon30.h @@ -0,0 +1,21 @@ + +void print (char *); + +void hires(); +void text(); +void oups(); +void ping(); +void zap(); +void shoot(); +void explode(); + +void paper(char color); +void ink(char color); + +void kbdclick1(); + +void curset(char x,char y, char display, char display); +void circle(char rayon); + + + diff --git a/libsrc/telemon30/_close.s b/libsrc/telemon30/_close.s new file mode 100644 index 000000000..84bee3a1b --- /dev/null +++ b/libsrc/telemon30/_close.s @@ -0,0 +1,17 @@ + .export _close + .import addysp,popax + .importzp sp,tmp2,tmp3,tmp1 + + ; int open (const char* name, int flags, ...); /* May take a mode argument */ + .include "telemon30.inc" + .include "errno.inc" + .include "fcntl.inc" + +.proc _close +; Throw away any additional parameters passed through the ellipsis + + BRK_TELEMON XCLOSE ; launch primitive ROM + rts +.endproc + + \ No newline at end of file diff --git a/libsrc/telemon30/_open.s b/libsrc/telemon30/_open.s index a002bbce1..7ea2d8310 100644 --- a/libsrc/telemon30/_open.s +++ b/libsrc/telemon30/_open.s @@ -1,11 +1,12 @@ .export _open .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 - ; int open (const char* name, int flags, ...); /* May take a mode argument */ - .include "telemon30.inc" - .include "errno.inc" - .include "fcntl.inc" + .importzp sp,tmp2,tmp3,tmp1 + ; int open (const char* name, int flags, ...); /* May take a mode argument */ + .include "telemon30.inc" + .include "errno.inc" + .include "fcntl.inc" + .proc _open ; Throw away any additional parameters passed through the ellipsis @@ -13,53 +14,18 @@ dey ; ...checked (it generates a c compiler warning) dey dey - beq parmok ; Branch if parameter count ok - jsr addysp ; Fix stack, throw away unused parameters + beq parmok ; Branch if parameter count ok + jsr addysp ; Fix stack, throw away unused parameters ; Parameters ok. Pop the flags and save them into tmp3 -parmok: jsr popax ; Get flagss - sta tmp3 ; save flags - - ;AND #O_RDONLY - ;beq READONLY - ;lda tmp3 - ;AND #O_WRONLY - ;beq WRITEONLY - ;jmp next - -;READONLY: -; lda #'r' -; BRK_TELEMON XWR0 -; jmp next -;WRITEONLY: -; lda #'w' -; BRK_TELEMON XWR0 - -;next: +parmok: jsr popax ; Get flagss + sta tmp3 ; save flags ; Get the filename from stack and parse it. Bail out if is not ok - jsr popax ; Get name - - - ldy tmp3 ; Get flags - - - BRK_TELEMON XOPEN - - ; jsr fnparse ; Parse it - ;tax - ;bne oserror ; Bail out if problem with name - -; Get a free file handle and remember it in tmp2 - - ; jsr freefd - ;lda #EMFILE ; Load error code - ;bcs seterrno ; Jump in case of errors - ;stx tmp2 -; - - + jsr popax ; Get name + ldy tmp3 ; Get flags again + BRK_TELEMON XOPEN ; launch primitive ROM rts .endproc diff --git a/libsrc/telemon30/_read.s b/libsrc/telemon30/_read.s index 8f7a20a58..e8bcc3fd0 100644 --- a/libsrc/telemon30/_read.s +++ b/libsrc/telemon30/_read.s @@ -1,29 +1,45 @@ ; -; Ullrich von Bassewitz, 2003-04-13 +; jede jede@oric.org 2017-01-22 ; -; + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term .export _read .import popax - .importzp ptr1, ptr2, ptr3, tmp1, tmp2 - + + .include "zeropage.inc" .include "telemon30.inc" ; int read (int fd, void* buf, unsigned count); .proc _read - ;jsr popax ; fp pointer don't care - sta tmp1 ; count - stx tmp2 ; count - jsr popax ; get buf - ;lda #$00 - ;ldx #$a0 - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - lda tmp1 ; - ldy tmp2 ; - BRK_TELEMON XFREAD + + sta ptr1 ; count + stx ptr1+1 ; count + jsr popax ; get buf + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + sta ptr2 ; in order to calculate nb of bytes read + stx ptr2+1 ; + + ;jsr popax ; fp pointer don't care in this version + + lda ptr1 ; + ldy ptr1+1 ; + BRK_TELEMON XFREAD ; calls telemon30 routine + ; compute nb of bytes read + lda PTR_READ_DEST+1 + sec + sbc ptr2+1 + tax + lda PTR_READ_DEST + sec + sbc ptr2 + + + + ; Here A and X contains number of bytes read + rts .endproc diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s index 24df14471..97245add9 100644 --- a/libsrc/telemon30/ch376.s +++ b/libsrc/telemon30/ch376.s @@ -1,5 +1,5 @@ - ; For XA65 compatibily in the futur + ; For XA65 compatibily in the future .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term .export _ch376_set_file_name .export _ch376_file_open @@ -8,14 +8,16 @@ .export _ch376_check_exist .export _ch376_disk_mount .export _ch376_set_usb_mode - .export _ch376_file_create - .export _ch376_fcreate - + + .export _ch376_file_close + .export _ch376_seek_file + .export _ch376_file_create + .export _ch376_fwrite ; High level function - .export _ch376_fcreate + .import popax - .importzp sp,tmp2,tmp3,tmp1 + .include "zeropage.inc" .include "telemon30.inc" /* @@ -24,10 +26,27 @@ CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY := $06 -CH376_USB_INT_DISK_READ := $1d -CH376_USB_INT_SUCCESS := $14 -CH376_ERR_MISS_FILE := $42 - +CH376_USB_INT_SUCCESS := $14 +CH376_USB_INT_CONNECT := $15 +CH376_USB_INT_DISCONNECT := $16 +CH376_USB_INT_BUF_OVER := $17 +CH376_USB_INT_USB_READY := $18 +CH376_USB_INT_DISK_READ := $1D +CH376_USB_INT_DISK_WRITE := $1E +CH376_USB_INT_DISK_ERR := $1F + + +CH376_ERR_OPEN_DIR := $41 +CH376_ERR_MISS_FILE := $42 +CH376_ERR_FOUND_NAME := $43 +CH376_ERR_DISK_DISCON := $82 +CH376_ERR_LARGE_SECTOR := $84 +CH376_ERR_TYPE_ERROR := $92 +CH376_ERR_BPB_ERROR := $A1 +CH376_ERR_DISK_FULL := $B1 +CH376_ERR_FDT_OVER := $B2 +CH376_ERR_FILE_CLOSE := $B4 + CH376_GET_IC_VER := $01 @@ -36,80 +55,92 @@ CH376_GET_ENTER_SLEEP := $03 CH376_RESET_ALL := $05 CH376_CHECK_EXIST := $06 CH376_GET_FILE_SIZE := $0C + CH376_SET_USB_MODE := $15 CH376_GET_STATUS := $22 CH376_RD_USB_DATA0 := $27 -CH376_SET_FILE_NAME := $2f +CH376_CMD_WR_REQ_DATA := $2d +CH376_SET_FILE_NAME := $2F + CH376_DISK_CONNECT := $30 ; check the disk connection status CH376_DISK_MOUNT := $31 CH376_FILE_OPEN := $32 CH376_FILE_ENUM_GO := $33 CH376_FILE_CREATE := $34 CH376_FILE_CLOSE := $36 +CH376_BYTE_LOCATE := $39 CH376_BYTE_READ := $3A -CH376_BYTE_RD_GO := $3b +CH376_BYTE_RD_GO := $3B CH376_BYTE_WRITE := $3C +CH376_BYTE_WR_GO := $3D CH376_DISK_CAPACITY := $3E CH376_DISK_RD_GO := $55 -.proc _ch376_file_create - lda #CH376_FILE_CREATE - sta CH376_COMMAND - jsr _ch376_wait_response - rts +.proc _ch376_file_close + lda #CH376_FILE_CLOSE + sta CH376_COMMAND + jsr _ch376_wait_response + rts .endproc -; void _ch376_fcreate(char *filename) -.proc _ch376_fcreate - jsr _ch376_set_file_name - jsr _ch376_file_open - jsr _ch376_file_create +.proc _ch376_seek_file + ldx #CH376_BYTE_LOCATE + stx CH376_COMMAND + sta CH376_DATA + sty CH376_DATA + lda #$00 ; Don't manage 32 bits length + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response + rts .endproc ; void ch376_set_file_name(char *filename) .proc _ch376_set_file_name - sta tmp1 - stx tmp1+1 - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - ldy #0 + sta ptr1 + stx ptr1+1 + lda #CH376_SET_FILE_NAME ;$2f + sta CH376_COMMAND + ldy #0 loop: - lda (tmp1),y ; replace by bufnom - beq end ; we reached 0 value - sta CH376_DATA + lda (ptr1),y ; replace by bufnom + beq end ; we reached 0 value + ;BRK_TELEMON XMINMA + sta CH376_DATA iny - cpy #13 ; because we don't manage longfilename shortname =11 - bne loop + cpy #13 ; because we don't manage longfilename shortname =11 + bne loop end: - sta CH376_DATA + sta CH376_DATA rts .endproc -; void _ch376_file_open(); +; char _ch376_file_open(); .proc _ch376_file_open - lda #CH376_FILE_OPEN ; $32 - sta CH376_COMMAND - jsr _ch376_wait_response + lda #CH376_FILE_OPEN ; $32 + sta CH376_COMMAND + jsr _ch376_wait_response +; ldx #0 rts .endproc ;CMD_GET_FILE_SIZE .proc _ch376_get_file_size - lda #CH376_GET_FILE_SIZE - sta CH376_COMMAND - lda #$68 - sta CH376_DATA + lda #CH376_GET_FILE_SIZE + sta CH376_COMMAND + lda #$68 + sta CH376_DATA ; store file leng - lda CH376_DATA - sta tmp1 - lda CH376_DATA - sta tmp1+1 - lda CH376_DATA - sta tmp2 - lda CH376_DATA - sta tmp2+1 + lda CH376_DATA + sta tmp1 + lda CH376_DATA + sta tmp1+1 + lda CH376_DATA + sta tmp2 + lda CH376_DATA + sta tmp2+1 rts .endproc @@ -155,35 +186,35 @@ loop: .proc _ch376_set_usb_mode ; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY - pha - lda #CH376_SET_USB_MODE ; $15 - sta CH376_COMMAND - pla - sta CH376_DATA + ldx #CH376_SET_USB_MODE ; $15 + stx CH376_COMMAND + sta CH376_DATA rts .endproc - - + ; void ch376_set_bytes_write(int value); .proc _ch376_set_bytes_write - sta tmp1 - stx tmp1+1 - ldx #CH376_BYTE_WRITE - stx CH376_COMMAND - lda tmp1 - sta CH376_DATA - lda tmp1+1 - sta CH376_DATA - jsr _ch376_wait_response + ldy #CH376_BYTE_WRITE + sty CH376_COMMAND + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc .proc _ch376_set_bytes_read - ldx #CH376_BYTE_READ - stx CH376_COMMAND - sta CH376_DATA - sty CH376_DATA - jsr _ch376_wait_response + ldy #CH376_BYTE_READ + sty CH376_COMMAND + ; Storing 32 bits value + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc @@ -204,7 +235,7 @@ loop: ; else A contains answer of the controller ldy #$ff loop3: - ldx #$ff ; merci de laisser une valeur importante car parfois en mode non debug, le controleur ne répond pas tout de suite + ldx #$ff ; don't decrease this counter. Because ch376 won't respond if there is a lower value loop: lda CH376_COMMAND and #%10000000 @@ -223,3 +254,137 @@ no_error: rts .endproc +.proc _ch376_fread + ; use ptr1 to count bytes + jsr _ch376_set_bytes_read + +continue: + cmp #CH376_USB_INT_DISK_READ ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished + ; TODO in A : $ff X: $ff + lda #0 + tax + rts +we_read: + lda #CH376_RD_USB_DATA0 + sta CH376_COMMAND + + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read + + ldy #0 +loop: + lda CH376_DATA ; read the data + sta (PTR_READ_DEST),y + + iny + cpy tmp2 + bne loop + tya + clc + adc PTR_READ_DEST + bcc next + inc PTR_READ_DEST+1 +next: + sta PTR_READ_DEST + + lda #CH376_BYTE_RD_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue +finished: + ; TODO return bytes read + lda tmp1 + + ldx tmp1+1 + + rts +.endproc + +; void _ch376_fwrite(void *ptr,int number) +.proc _ch376_fwrite + ; use ptr1 to count bytes + sta ptr2 + stx ptr2+1 + + jsr popax + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + + lda ptr2 + ldx ptr2+1 + jsr _ch376_set_bytes_write + ;cmp #CH376_USB_INT_SUCCESS + ;beq finished + ;jsr popax + + ;jsr _ch376_wait_response + +continue: + cmp #CH376_USB_INT_DISK_WRITE ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished + ; TODO in A : $ff X: $ff + lda #0 + tax + rts +we_read: + lda #CH376_CMD_WR_REQ_DATA + sta CH376_COMMAND + + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read + + + ;ldy #0 +loop: + ;lda (PTR_READ_DEST),y + lda #65 + sta CH376_DATA ; read the data + dec tmp2 + bne loop +; dec ptr2 + ;bne continue3 + ;dec ptr2+1 + ;bne continue3 +;continue3 +; lda ptr2+1 + ;bne continue2 + ;lda ptr2 + ;beq finished +;continue2 +; iny +; cpy tmp2 +; bne loop +; tya +; clc +; adc PTR_READ_DEST +; bcc next +; inc PTR_READ_DEST+1 +;next: +; sta PTR_READ_DEST + + lda #CH376_BYTE_WR_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue +finished: + ; TODO return bytes read + lda tmp1 + ;lda #<8000 + ldx tmp1+1 + ;ldx #>8000 + rts +.endproc + + + +.proc _ch376_file_create + lda #CH376_FILE_CREATE + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc \ No newline at end of file diff --git a/libsrc/telemon30/graphics.s b/libsrc/telemon30/graphics.s index 1d0beefa5..4f2b09162 100644 --- a/libsrc/telemon30/graphics.s +++ b/libsrc/telemon30/graphics.s @@ -1,7 +1,7 @@ - .export _paper,_hires,_text,_circle,_curset, _switchOffCursor - .importzp sp,tmp2,tmp3,tmp1 - - .include "telemon30.inc" + .export _paper,_hires,_text,_circle,_curset, _switchOffCursor + .importzp sp,tmp2,tmp3,tmp1 + .import popa + .include "telemon30.inc" .proc _paper ldx #0 ; First window @@ -30,8 +30,11 @@ .endproc .proc _curset + jsr popa ; Pixel + jsr popa sta HRSX - sty HRSY + jsr popa + sta HRSY BRK_TELEMON XCURSE rts .endproc diff --git a/libsrc/telemon30/orixhdr.s b/libsrc/telemon30/orixhdr.s index 8744e86b0..1b0351885 100644 --- a/libsrc/telemon30/orixhdr.s +++ b/libsrc/telemon30/orixhdr.s @@ -1,5 +1,5 @@ ; -; Based on code by Debrune Jérôme <jede@oric.org> +; Based on code by Debrune Jérôme <jede@oric.org> ; 2016-03-17, Greg King ; @@ -17,18 +17,17 @@ .segment "ORIXHDR" - .byte $01, $00 ; + .byte $01, $00 ; - .byte "ORI" + .byte "ori" .byte $01 ; version - .byte $00,$00 ; mode - .byte $00,$00 ; cpu type + .byte $00,%00000000 ; 6502 only + .byte $00,$00 ; Extends .byte $00,$00 ; OS - .byte $00 ; reserved - .byte $00 ; auto - + .byte $00 ; reserved + .byte $00 ; auto .word __BASHEAD_START__ ; Address of start of file .word __MAIN_LAST__ - 1 ; Address of end of file diff --git a/libsrc/telemon30/write.s b/libsrc/telemon30/write.s index 32965fe3d..d762eb92c 100644 --- a/libsrc/telemon30/write.s +++ b/libsrc/telemon30/write.s @@ -27,6 +27,28 @@ sta ptr1 stx ptr1+1 jsr popax ; get fd and discard + + ; if fd=0001 then it stdout + + + cpx #0 + beq next + jmp L1 +next: + cmp #1 + beq L1 + + ; Here it's a file opened + lda ptr1 + sta PTR_READ_DEST + lda ptr1+1 + sta PTR_READ_DEST+1 + lda ptr3 + ldy ptr3+1 + BRK_TELEMON XFWRITE + rts + + L1: inc ptr2 bne L2 inc ptr2+1 From 6ed57af9fd44a4eb80d882f26d31c268c126db81 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:14:56 +0100 Subject: [PATCH 190/407] removing ch376.h --- include/ch376.h | 55 ------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 include/ch376.h diff --git a/include/ch376.h b/include/ch376.h deleted file mode 100644 index 9db801eaf..000000000 --- a/include/ch376.h +++ /dev/null @@ -1,55 +0,0 @@ - - -/* /// "Portable types" */ - - - - -/* /// "CH376 interface commands and constants" */ - -// Chip version -#define CH376_DATA_IC_VER 3 - -// Commands -#define CH376_CMD_NONE 0x00 -#define CH376_CMD_GET_IC_VER 0x01 -#define CH376_CMD_CHECK_EXIST 0x06 -#define CH376_CMD_SET_USB_MODE 0x15 -#define CH376_CMD_GET_STATUS 0x22 -#define CH376_CMD_RD_USB_DATA0 0x27 -#define CH376_CMD_WR_REQ_DATA 0x2d -#define CH376_CMD_SET_FILE_NAME 0x2f -#define CH376_CMD_DISK_MOUNT 0x31 -#define CH376_CMD_FILE_OPEN 0x32 -#define CH376_CMD_FILE_ENUM_GO 0x33 -#define CH376_CMD_FILE_CREATE 0x34 -#define CH376_CMD_FILE_CLOSE 0x36 -#define CH376_CMD_BYTE_LOCATE 0x39 -#define CH376_CMD_BYTE_READ 0x3a -#define CH376_CMD_BYTE_RD_GO 0x3b -#define CH376_CMD_BYTE_WRITE 0x3c -#define CH376_CMD_BYTE_WR_GO 0x3d -#define CH376_CMD_DISK_QUERY 0x3f -#define CH376_CMD_DISK_RD_GO 0x55 - -#define CH376_ARG_SET_USB_MODE_INVALID 0x00 -#define CH376_ARG_SET_USB_MODE_SD_HOST 0x03 -#define CH376_ARG_SET_USB_MODE_USB_HOST 0x06 - -// Status & errors -#define CH376_ERR_OPEN_DIR 0x41 -#define CH376_ERR_MISS_FILE 0x42 - -#define CH376_RET_SUCCESS 0x51 -#define CH376_RET_ABORT 0x5f - -#define CH376_INT_SUCCESS 0x14 -#define CH376_INT_DISK_READ 0x1d -#define CH376_INT_DISK_WRITE 0x1e - - -unsigned char ch376_check_exist(unsigned char value); -unsigned char ch376_ic_get_version(void); -void ch376_set_usb_mode(unsigned char value); -unsigned char ch376_disk_mount(void); - From 29881fb7c920a65004ee45a16e6769147367ce38 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:28:54 +0100 Subject: [PATCH 191/407] Revert --- libsrc/common/fread.s | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/libsrc/common/fread.s b/libsrc/common/fread.s index b87cc5cb4..91d692985 100644 --- a/libsrc/common/fread.s +++ b/libsrc/common/fread.s @@ -173,16 +173,13 @@ ; Read was ok, account for the pushed back character (if any). -@L8: - add pb +@L8: add pb bcc @L9 inx ; Check for end of file. -@L9: - - cmp #0 ; Zero bytes read? +@L9: cmp #0 ; Zero bytes read? bne @L10 cpx #0 bne @L10 @@ -195,10 +192,7 @@ ; Return the number of items successfully read. Since we've checked for ; bytes == 0 above, size cannot be zero here, so the division is safe. -@L10: - - - jsr pushax ; Push number of bytes read +@L10: jsr pushax ; Push number of bytes read ldy #5 jsr ldaxysp ; Get size jsr tosudivax ; bytes / size -> a/x From 0f8fb4d79d4fd91bea2f8659e0eabdc1db2b2de2 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:39:51 +0100 Subject: [PATCH 192/407] Merge with current version --- cfg/telemon30.cfg | 43 +++++++++++++++++++++++++++++++++++++++++++ src/ca65/main.c | 13 +++++++++---- src/cc65/main.c | 11 ++++++----- src/common/target.c | 2 ++ src/common/target.h | 1 + 5 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 cfg/telemon30.cfg diff --git a/cfg/telemon30.cfg b/cfg/telemon30.cfg new file mode 100644 index 000000000..b9f0b4026 --- /dev/null +++ b/cfg/telemon30.cfg @@ -0,0 +1,43 @@ +SYMBOLS { + + __ORIXHDR__: type = import; + + __STACKSIZE__: type = weak, value = $0800; # 2K stack + + __RAMEND__: type = weak, value = $9800; +} +MEMORY { + ZP: file = "", define = yes, start = $00E0, size = $001A; + ORIXHDR: file = %O, type = ro, start = $0000, size = $001F; + BASHEAD: file = %O, define = yes, start = $0801, size = $000D; + MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__; + BSS: file = "", start = __ONCE_RUN__, size = __RAMEND__ - __STACKSIZE__ - __ONCE_RUN__; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + ORIXHDR: load = ORIXHDR, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + BASTAIL: load = MAIN, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/src/ca65/main.c b/src/ca65/main.c index 4aa60f2f0..91f652811 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -222,6 +222,10 @@ static void SetSys (const char* Sys) CBMSystem ("__C16__"); break; + case TGT_C65: + CBMSystem("__C65__"); + break; + case TGT_C64: CBMSystem ("__C64__"); break; @@ -623,11 +627,12 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) -/* Print the assembler version */ +static void OptVersion(const char* Opt attribute((unused)), + const char* Arg attribute((unused))) + /* Print the assembler version */ { - fprintf (stderr, "ca65 V%s\n", GetVersionAsString ()); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + exit(EXIT_SUCCESS); } diff --git a/src/cc65/main.c b/src/cc65/main.c index f25a44d69..b7abf959c 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -746,12 +746,13 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) -/* Print the compiler version */ + +static void OptVersion(const char* Opt attribute((unused)), + const char* Arg attribute((unused))) + /* Print the compiler version */ { - fprintf (stderr, "cc65 V%s\n", GetVersionAsString ()); - exit (EXIT_SUCCESS); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + exit(EXIT_SUCCESS); } diff --git a/src/common/target.c b/src/common/target.c index adbc080bf..31274d48a 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -209,6 +209,8 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, + { "c65", CPU_4510, BINFMT_BINARY, CTPET }, + }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 4bc00225d..93bcfe20d 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -82,6 +82,7 @@ typedef enum { TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, + TGT_C65, TGT_COUNT /* Number of target systems */ } target_t; From 2697499b3c245a98871bb43380bdd068facd06c8 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:53:50 +0100 Subject: [PATCH 193/407] Fixing old pull request --- src/ca65/main.c | 14 +++++++------- src/cc65/main.c | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index 91f652811..fd06f685d 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -222,14 +222,14 @@ static void SetSys (const char* Sys) CBMSystem ("__C16__"); break; - case TGT_C65: - CBMSystem("__C65__"); - break; - case TGT_C64: CBMSystem ("__C64__"); break; + case TGT_C65: + CBMSystem("__C65__"); + break; + case TGT_VIC20: CBMSystem ("__VIC20__"); break; @@ -628,11 +628,11 @@ static void OptVerbose (const char* Opt attribute ((unused)), static void OptVersion(const char* Opt attribute((unused)), - const char* Arg attribute((unused))) + const char* Arg attribute((unused))) /* Print the assembler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); - exit(EXIT_SUCCESS); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + exit(EXIT_SUCCESS); } diff --git a/src/cc65/main.c b/src/cc65/main.c index b7abf959c..1fd670340 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -748,11 +748,11 @@ static void OptVerbose (const char* Opt attribute ((unused)), static void OptVersion(const char* Opt attribute((unused)), - const char* Arg attribute((unused))) + const char* Arg attribute((unused))) /* Print the compiler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); - exit(EXIT_SUCCESS); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + exit(EXIT_SUCCESS); } From e21eca942b00e30c2d33c3220dbb1225e1751668 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:55:35 +0100 Subject: [PATCH 194/407] new pull fix --- src/ca65/main.c | 6 +++--- src/cc65/main.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index fd06f685d..cbd514bc3 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -627,9 +627,9 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion(const char* Opt attribute((unused)), - const char* Arg attribute((unused))) - /* Print the assembler version */ +static void OptVersion (const char* Opt attribute((unused)), + const char* Arg attribute((unused))) +/* Print the assembler version */ { fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); exit(EXIT_SUCCESS); diff --git a/src/cc65/main.c b/src/cc65/main.c index 1fd670340..8fc774f87 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -747,9 +747,9 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion(const char* Opt attribute((unused)), - const char* Arg attribute((unused))) - /* Print the compiler version */ +static void OptVersion (const char* Opt attribute((unused)), + const char* Arg attribute((unused))) +/* Print the compiler version */ { fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); exit(EXIT_SUCCESS); From bd82bf6a7fe9b7644dadb579f1fe4b72c184e9eb Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:59:53 +0100 Subject: [PATCH 195/407] Fix --- src/ca65/main.c | 2 +- src/cc65/main.c | 4 ++-- src/common/target.c | 8 ++++---- src/common/target.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index cbd514bc3..ff321d87d 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -631,7 +631,7 @@ static void OptVersion (const char* Opt attribute((unused)), const char* Arg attribute((unused))) /* Print the assembler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString ()); exit(EXIT_SUCCESS); } diff --git a/src/cc65/main.c b/src/cc65/main.c index 8fc774f87..e4e5ce81f 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -751,8 +751,8 @@ static void OptVersion (const char* Opt attribute((unused)), const char* Arg attribute((unused))) /* Print the compiler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); - exit(EXIT_SUCCESS); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit (EXIT_SUCCESS); } diff --git a/src/common/target.c b/src/common/target.c index 31274d48a..dfbe4d354 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -152,6 +152,7 @@ static const TargetEntry TargetMap[] = { { "c128", TGT_C128 }, { "c16", TGT_C16 }, { "c64", TGT_C64 }, + { "c65", TGT_C65 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, { "gamate", TGT_GAMATE }, @@ -200,8 +201,8 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, - { "telemon24", CPU_6502, BINFMT_BINARY, CTNone }, - { "telemon30", CPU_6502, BINFMT_BINARY, CTNone }, + { "telemon24", CPU_6502, BINFMT_BINARY, CTNone }, + { "telemon30", CPU_6502, BINFMT_BINARY, CTNone }, { "nes", CPU_6502, BINFMT_BINARY, CTNone }, { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, { "lynx", CPU_65SC02, BINFMT_BINARY, CTNone }, @@ -209,8 +210,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, - { "c65", CPU_4510, BINFMT_BINARY, CTPET }, - + { "c65", CPU_4510, BINFMT_BINARY, CTPET }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 93bcfe20d..2b0a4e196 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -82,7 +82,7 @@ typedef enum { TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, - TGT_C65, + TGT_C65, TGT_COUNT /* Number of target systems */ } target_t; From db3b6603e510741faee19da56cebfaabff3d33d5 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 23:03:01 +0100 Subject: [PATCH 196/407] Fix --- src/ca65/main.c | 12 ++++++------ src/cc65/main.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index ff321d87d..8022b7818 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -226,9 +226,9 @@ static void SetSys (const char* Sys) CBMSystem ("__C64__"); break; - case TGT_C65: - CBMSystem("__C65__"); - break; + case TGT_C65: + CBMSystem("__C65__"); + break; case TGT_VIC20: CBMSystem ("__VIC20__"); @@ -627,11 +627,11 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion (const char* Opt attribute((unused)), - const char* Arg attribute((unused))) +static void OptVersion (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) /* Print the assembler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); exit(EXIT_SUCCESS); } diff --git a/src/cc65/main.c b/src/cc65/main.c index e4e5ce81f..6847c4b14 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -747,8 +747,8 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion (const char* Opt attribute((unused)), - const char* Arg attribute((unused))) +static void OptVersion (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) /* Print the compiler version */ { fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); From 858e95250586aa6ba9feb478a07accfd4ced42ae Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 23:05:18 +0100 Subject: [PATCH 197/407] Fix --- src/ca65/main.c | 2 +- src/cc65/main.c | 1 - src/common/target.c | 4 ++-- src/common/target.h | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index 8022b7818..1e0c5996f 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -227,7 +227,7 @@ static void SetSys (const char* Sys) break; case TGT_C65: - CBMSystem("__C65__"); + CBMSystem ("__C65__"); break; case TGT_VIC20: diff --git a/src/cc65/main.c b/src/cc65/main.c index 6847c4b14..b0c9261fe 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -746,7 +746,6 @@ static void OptVerbose (const char* Opt attribute ((unused)), - static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the compiler version */ diff --git a/src/common/target.c b/src/common/target.c index dfbe4d354..67e4ad51b 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -147,7 +147,7 @@ static const TargetEntry TargetMap[] = { { "atari", TGT_ATARI }, { "atari5200", TGT_ATARI5200 }, { "atarixl", TGT_ATARIXL }, - { "atmos", TGT_ATMOS }, + { "atmos", TGT_ATMOS }, { "bbc", TGT_BBC }, { "c128", TGT_C128 }, { "c16", TGT_C16 }, @@ -172,7 +172,7 @@ static const TargetEntry TargetMap[] = { { "sim65c02", TGT_SIM65C02 }, { "supervision", TGT_SUPERVISION }, { "telemon24", TGT_TELEMON24 }, - { "telemon30", TGT_TELEMON30 }, + { "telemon30", TGT_TELEMON30 }, { "vic20", TGT_VIC20 }, }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) diff --git a/src/common/target.h b/src/common/target.h index 2b0a4e196..68c0953fe 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -73,8 +73,8 @@ typedef enum { TGT_GEOS_APPLE, TGT_LUNIX, TGT_ATMOS, - TGT_TELEMON24, - TGT_TELEMON30, + TGT_TELEMON24, + TGT_TELEMON30, TGT_NES, TGT_SUPERVISION, TGT_LYNX, From 06b2b83ab298e5a8898d2d588c0e94daea2b7308 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 23:18:32 +0100 Subject: [PATCH 198/407] Correcting spaces --- libsrc/telemon30/_read.s | 36 +++--- libsrc/telemon30/ch376.s | 272 ++++++++++++++++++--------------------- 2 files changed, 139 insertions(+), 169 deletions(-) diff --git a/libsrc/telemon30/_read.s b/libsrc/telemon30/_read.s index e8bcc3fd0..ee822f1fd 100644 --- a/libsrc/telemon30/_read.s +++ b/libsrc/telemon30/_read.s @@ -12,36 +12,30 @@ ; int read (int fd, void* buf, unsigned count); .proc _read - - sta ptr1 ; count - stx ptr1+1 ; count - jsr popax ; get buf + sta ptr1 ; count + stx ptr1+1 ; count + jsr popax ; get buf - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - sta ptr2 ; in order to calculate nb of bytes read - stx ptr2+1 ; + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + sta ptr2 ; in order to calculate nb of bytes read + stx ptr2+1 ; - ;jsr popax ; fp pointer don't care in this version + ; jsr popax ; fp pointer don't care in this version - lda ptr1 ; - ldy ptr1+1 ; + lda ptr1 ; + ldy ptr1+1 ; BRK_TELEMON XFREAD ; calls telemon30 routine ; compute nb of bytes read - lda PTR_READ_DEST+1 + lda PTR_READ_DEST+1 sec - sbc ptr2+1 - tax - lda PTR_READ_DEST + sbc ptr2+1 + tax + lda PTR_READ_DEST sec - sbc ptr2 - - - + sbc ptr2 ; Here A and X contains number of bytes read - rts - .endproc diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s index 97245add9..460a70052 100644 --- a/libsrc/telemon30/ch376.s +++ b/libsrc/telemon30/ch376.s @@ -77,108 +77,107 @@ CH376_DISK_CAPACITY := $3E CH376_DISK_RD_GO := $55 .proc _ch376_file_close - lda #CH376_FILE_CLOSE - sta CH376_COMMAND - jsr _ch376_wait_response + lda #CH376_FILE_CLOSE + sta CH376_COMMAND + jsr _ch376_wait_response rts .endproc .proc _ch376_seek_file - ldx #CH376_BYTE_LOCATE - stx CH376_COMMAND - sta CH376_DATA - sty CH376_DATA - lda #$00 ; Don't manage 32 bits length - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response + ldx #CH376_BYTE_LOCATE + stx CH376_COMMAND + sta CH376_DATA + sty CH376_DATA + lda #$00 ; Don't manage 32 bits length + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc ; void ch376_set_file_name(char *filename) .proc _ch376_set_file_name - sta ptr1 - stx ptr1+1 - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - ldy #0 + sta ptr1 + stx ptr1+1 + lda #CH376_SET_FILE_NAME ;$2f + sta CH376_COMMAND + ldy #0 loop: - lda (ptr1),y ; replace by bufnom - beq end ; we reached 0 value - ;BRK_TELEMON XMINMA - sta CH376_DATA + lda (ptr1),y ; replace by bufnom + beq end ; we reached 0 value + BRK_TELEMON XMINMA + sta CH376_DATA iny - cpy #13 ; because we don't manage longfilename shortname =11 - bne loop + cpy #13 ; because we don't manage longfilename shortname =11 + bne loop end: - sta CH376_DATA + sta CH376_DATA rts .endproc ; char _ch376_file_open(); .proc _ch376_file_open - lda #CH376_FILE_OPEN ; $32 - sta CH376_COMMAND - jsr _ch376_wait_response -; ldx #0 + lda #CH376_FILE_OPEN ; $32 + sta CH376_COMMAND + jsr _ch376_wait_response rts .endproc - ;CMD_GET_FILE_SIZE + .proc _ch376_get_file_size - lda #CH376_GET_FILE_SIZE - sta CH376_COMMAND - lda #$68 - sta CH376_DATA - ; store file leng - lda CH376_DATA - sta tmp1 - lda CH376_DATA - sta tmp1+1 - lda CH376_DATA - sta tmp2 - lda CH376_DATA - sta tmp2+1 + lda #CH376_GET_FILE_SIZE + sta CH376_COMMAND + lda #$68 + sta CH376_DATA + ; store file length 32 bits + lda CH376_DATA + sta tmp1 + lda CH376_DATA + sta tmp1+1 + lda CH376_DATA + sta tmp2 + lda CH376_DATA + sta tmp2+1 rts .endproc ; void ch376_reset(); .proc _ch376_reset - lda #CH376_RESET_ALL ; 5 - sta CH376_COMMAND + lda #CH376_RESET_ALL ; 5 + sta CH376_COMMAND ; waiting - ldy #0 - ldx #0 + ldy #0 + ldx #0 loop: nop inx - bne loop + bne loop iny - bne loop + bne loop rts .endproc ; char ch376_check_exist(char value); .proc _ch376_check_exist - sta tmp1 - lda #CH376_CHECK_EXIST ; - sta CH376_COMMAND - lda tmp1 - sta CH376_DATA - lda CH376_DATA + sta tmp1 + lda #CH376_CHECK_EXIST ; + sta CH376_COMMAND + lda tmp1 + sta CH376_DATA + lda CH376_DATA rts .endproc ; char ch376_ic_get_version(void) .proc _ch376_ic_get_version - lda #CH376_GET_IC_VER - sta CH376_COMMAND - ldx #0 - lda CH376_DATA + lda #CH376_GET_IC_VER + sta CH376_COMMAND + ldx #0 + lda CH376_DATA rts .endproc @@ -186,45 +185,45 @@ loop: .proc _ch376_set_usb_mode ; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY - ldx #CH376_SET_USB_MODE ; $15 - stx CH376_COMMAND - sta CH376_DATA + ldx #CH376_SET_USB_MODE ; $15 + stx CH376_COMMAND + sta CH376_DATA rts .endproc ; void ch376_set_bytes_write(int value); .proc _ch376_set_bytes_write - ldy #CH376_BYTE_WRITE - sty CH376_COMMAND - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response + ldy #CH376_BYTE_WRITE + sty CH376_COMMAND + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc .proc _ch376_set_bytes_read - ldy #CH376_BYTE_READ - sty CH376_COMMAND + ldy #CH376_BYTE_READ + sty CH376_COMMAND ; Storing 32 bits value - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc ; char ch376_disk_mount(); .proc _ch376_disk_mount - lda #CH376_DISK_MOUNT ; $31 - sta CH376_COMMAND - jsr _ch376_wait_response + lda #CH376_DISK_MOUNT ; $31 + sta CH376_COMMAND + jsr _ch376_wait_response ; if we read data value, we have then length of the volume name - ldx #0 + ldx #0 rts .endproc @@ -233,89 +232,87 @@ loop: .proc _ch376_wait_response ; 1 return 1 if usb controller does not respond ; else A contains answer of the controller - ldy #$ff + ldy #$ff loop3: - ldx #$ff ; don't decrease this counter. Because ch376 won't respond if there is a lower value + ldx #$ff ; don't decrease this counter. Because ch376 won't respond if there is a lower value loop: - lda CH376_COMMAND - and #%10000000 - cmp #128 - bne no_error + lda CH376_COMMAND + and #%10000000 + cmp #128 + bne no_error dex - bne loop + bne loop dey - bne loop3 + bne loop3 ; error is here rts no_error: - lda #CH376_GET_STATUS - sta CH376_COMMAND - lda CH376_DATA + lda #CH376_GET_STATUS + sta CH376_COMMAND + lda CH376_DATA rts .endproc .proc _ch376_fread ; use ptr1 to count bytes - jsr _ch376_set_bytes_read + jsr _ch376_set_bytes_read continue: - cmp #CH376_USB_INT_DISK_READ ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished + cmp #CH376_USB_INT_DISK_READ ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished ; TODO in A : $ff X: $ff - lda #0 + lda #0 tax rts we_read: - lda #CH376_RD_USB_DATA0 - sta CH376_COMMAND + lda #CH376_RD_USB_DATA0 + sta CH376_COMMAND - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read ldy #0 loop: - lda CH376_DATA ; read the data - sta (PTR_READ_DEST),y + lda CH376_DATA ; read the data + sta (PTR_READ_DEST),y iny - cpy tmp2 - bne loop + cpy tmp2 + bne loop tya clc - adc PTR_READ_DEST - bcc next - inc PTR_READ_DEST+1 + adc PTR_READ_DEST + bcc next + inc PTR_READ_DEST+1 next: - sta PTR_READ_DEST + sta PTR_READ_DEST - lda #CH376_BYTE_RD_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue + lda #CH376_BYTE_RD_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue finished: ; TODO return bytes read - lda tmp1 - - ldx tmp1+1 - + lda tmp1 + ldx tmp1+1 rts .endproc ; void _ch376_fwrite(void *ptr,int number) .proc _ch376_fwrite - ; use ptr1 to count bytes - sta ptr2 - stx ptr2+1 + ; use ptr1 to count bytes + sta ptr2 + stx ptr2+1 - jsr popax - sta PTR_READ_DEST - stx PTR_READ_DEST+1 + jsr popax + sta PTR_READ_DEST + stx PTR_READ_DEST+1 - lda ptr2 - ldx ptr2+1 - jsr _ch376_set_bytes_write + lda ptr2 + ldx ptr2+1 + jsr _ch376_set_bytes_write ;cmp #CH376_USB_INT_SUCCESS ;beq finished ;jsr popax @@ -346,26 +343,7 @@ loop: sta CH376_DATA ; read the data dec tmp2 bne loop -; dec ptr2 - ;bne continue3 - ;dec ptr2+1 - ;bne continue3 -;continue3 -; lda ptr2+1 - ;bne continue2 - ;lda ptr2 - ;beq finished -;continue2 -; iny -; cpy tmp2 -; bne loop -; tya -; clc -; adc PTR_READ_DEST -; bcc next -; inc PTR_READ_DEST+1 -;next: -; sta PTR_READ_DEST + lda #CH376_BYTE_WR_GO sta CH376_COMMAND @@ -380,8 +358,6 @@ finished: rts .endproc - - .proc _ch376_file_create lda #CH376_FILE_CREATE sta CH376_COMMAND From b5fef66f37d3a6f8419f32177f27a01108091d48 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Tue, 31 Jan 2017 22:09:14 +0100 Subject: [PATCH 199/407] Merge telemon24 and telemon30 into telestrat target. Cleaning, and replace tab to spaces Converting hex lowercase value into uppercase char. Changing := and = when it was needed --- asminc/telemon24.inc | 68 ---- asminc/{telemon30.inc => telestrat.inc} | 103 +++-- cfg/telemon24.cfg | 43 -- cfg/{telemon30.cfg => telestrat.cfg} | 0 doc/telemon24.sgml | 42 -- doc/{telemon30.sgml => telestrat.sgml} | 0 include/telemon.h | 58 --- include/{telemon30.h => telestrat.h} | 0 libsrc/Makefile | 3 +- libsrc/telemon24/crt0.s | 101 ----- libsrc/telemon24/hires.s | 22 -- libsrc/telemon24/mainargs.s | 36 -- libsrc/telemon24/print.s | 25 -- libsrc/telemon24/tapehdr.s | 36 -- libsrc/telemon24/write.s | 59 --- libsrc/telemon30/_close.s | 17 - libsrc/telemon30/_read.s | 41 -- libsrc/telemon30/_scrsize.s | 19 - libsrc/telemon30/ch376.s | 366 ------------------ libsrc/telemon30/ctype.s | 299 -------------- libsrc/telemon30/graphics.s | 54 --- libsrc/telemon30/keyboard.s | 13 - libsrc/telemon30/oserrlist.s | 75 ---- libsrc/telemon30/oserror.s | 17 - libsrc/telemon30/print.s | 21 - libsrc/telemon30/sound.s | 45 --- libsrc/telemon30/sysuname.s | 46 --- libsrc/telestrat/ch376.s | 344 ++++++++++++++++ libsrc/telestrat/close.s | 18 + libsrc/{telemon30 => telestrat}/crt0.s | 12 +- libsrc/{telemon24 => telestrat}/ctype.s | 0 libsrc/telestrat/graphics.s | 58 +++ libsrc/telestrat/keyboard.s | 14 + libsrc/{telemon30 => telestrat}/mainargs.s | 29 +- libsrc/{telemon30 => telestrat}/mym.s | 2 +- .../{telemon30/_open.s => telestrat/open.s} | 21 +- libsrc/{telemon30 => telestrat}/orixhdr.s | 22 +- libsrc/{telemon24 => telestrat}/oserrlist.s | 0 libsrc/{telemon24 => telestrat}/oserror.s | 0 libsrc/telestrat/print.s | 16 + libsrc/telestrat/read.s | 43 ++ .../_scrsize.s => telestrat/scrsize.s} | 2 +- libsrc/telestrat/sound.s | 42 ++ libsrc/{telemon24 => telestrat}/sysuname.s | 0 libsrc/{telemon30 => telestrat}/write.s | 14 +- src/ca65/main.c | 8 +- src/cc65/main.c | 8 +- src/common/target.c | 6 +- src/common/target.h | 3 +- 49 files changed, 629 insertions(+), 1642 deletions(-) delete mode 100644 asminc/telemon24.inc rename asminc/{telemon30.inc => telestrat.inc} (69%) delete mode 100644 cfg/telemon24.cfg rename cfg/{telemon30.cfg => telestrat.cfg} (100%) delete mode 100644 doc/telemon24.sgml rename doc/{telemon30.sgml => telestrat.sgml} (100%) delete mode 100644 include/telemon.h rename include/{telemon30.h => telestrat.h} (100%) delete mode 100644 libsrc/telemon24/crt0.s delete mode 100644 libsrc/telemon24/hires.s delete mode 100644 libsrc/telemon24/mainargs.s delete mode 100644 libsrc/telemon24/print.s delete mode 100644 libsrc/telemon24/tapehdr.s delete mode 100644 libsrc/telemon24/write.s delete mode 100644 libsrc/telemon30/_close.s delete mode 100644 libsrc/telemon30/_read.s delete mode 100644 libsrc/telemon30/_scrsize.s delete mode 100644 libsrc/telemon30/ch376.s delete mode 100644 libsrc/telemon30/ctype.s delete mode 100644 libsrc/telemon30/graphics.s delete mode 100644 libsrc/telemon30/keyboard.s delete mode 100644 libsrc/telemon30/oserrlist.s delete mode 100644 libsrc/telemon30/oserror.s delete mode 100644 libsrc/telemon30/print.s delete mode 100644 libsrc/telemon30/sound.s delete mode 100644 libsrc/telemon30/sysuname.s create mode 100644 libsrc/telestrat/ch376.s create mode 100644 libsrc/telestrat/close.s rename libsrc/{telemon30 => telestrat}/crt0.s (85%) rename libsrc/{telemon24 => telestrat}/ctype.s (100%) create mode 100644 libsrc/telestrat/graphics.s create mode 100644 libsrc/telestrat/keyboard.s rename libsrc/{telemon30 => telestrat}/mainargs.s (90%) rename libsrc/{telemon30 => telestrat}/mym.s (99%) rename libsrc/{telemon30/_open.s => telestrat/open.s} (65%) rename libsrc/{telemon30 => telestrat}/orixhdr.s (56%) rename libsrc/{telemon24 => telestrat}/oserrlist.s (100%) rename libsrc/{telemon24 => telestrat}/oserror.s (100%) create mode 100644 libsrc/telestrat/print.s create mode 100644 libsrc/telestrat/read.s rename libsrc/{telemon24/_scrsize.s => telestrat/scrsize.s} (85%) create mode 100644 libsrc/telestrat/sound.s rename libsrc/{telemon24 => telestrat}/sysuname.s (100%) rename libsrc/{telemon30 => telestrat}/write.s (86%) diff --git a/asminc/telemon24.inc b/asminc/telemon24.inc deleted file mode 100644 index 0b58d63a6..000000000 --- a/asminc/telemon24.inc +++ /dev/null @@ -1,68 +0,0 @@ -; -; Oric Telemon definition -; Telemon 2.4 -; - - -; --------------------------------------------------------------------------- -; Constants - -SCREEN_XSIZE = 40 ; screen columns -SCREEN_YSIZE = 28 ; screen rows - -FUNCTKEY = $A5 - -FNAME_LEN = 11 ; maximum length of file-name - - -; --------------------------------------------------------------------------- -; Zero page - - - - -; --------------------------------------------------------------------------- -; Low memory - - - - -; --------------------------------------------------------------------------- -; I/O locations - -; 6522 -.struct VIA ; Versatile Interface Adapter - .res $0300 -PRB .byte ; Port Register B -PRA .byte ; Port Register A -DDRB .byte ; Data Direction Register B -DDRA .byte ; Data Direction Register A -T1 .word ; Timer 1 -T1L .word ; Timer 1 Latch -T2 .word ; Timer 2 -SR .byte ; Shift Register -ACR .byte ; Auxiliary Control Register -PCR .byte ; Peripheral Control Register -IFR .byte ; Interrupt Flags Register -IER .byte ; Interrupt Enable Register -PRA2 .byte ; Port Register A without handshaking -.endstruct - -; 6551 -.struct ACIA ; Asynchronous Communications Interface Adapter - .res $031C -DATA .byte -STATUS .byte -CMD .byte ; Command register -CTRL .byte ; Control register -.endstruct - -SCREEN := $BB80 - - -; --------------------------------------------------------------------------- -; ROM entries - -XWR0 := $10 -XWSTR0 := $14 - diff --git a/asminc/telemon30.inc b/asminc/telestrat.inc similarity index 69% rename from asminc/telemon30.inc rename to asminc/telestrat.inc index acfd7e919..fedda1946 100644 --- a/asminc/telemon30.inc +++ b/asminc/telestrat.inc @@ -1,6 +1,7 @@ ; ; Oric Telemon definition -; Telemon 2.4 +; Telemon 2.4 & Telemon 3.0 +; For telemon 3.0 check http://orix.oric.org ; @@ -18,6 +19,24 @@ FNAME_LEN = 11 ; maximum length of file-name ; --------------------------------------------------------------------------- ; Zero page +; --------------------------------------------------------------------------- +; Page 00 +RES := $00 +RESB := $02 + +TR0 := $0C +TR1 := $0D + +PTR_READ_DEST := $2D ; used for XFREAD and XWRITE only in telemon 3.0 + +HRSX := $46 +HRSY := $47 + +HRS1 := $4D +HRS2 := $4F +HRS3 := $51 +HRS4 := $53 +HRS5 := $55 @@ -82,69 +101,47 @@ SCREEN := $BB80 ; ROM entries ; primitives telemon 2.4 -XRD0 := $08 -XRDW0 := $0c -XWR0 := $10 -XWSTR0 := $14 -XTEXT := $19 -XHIRES := $1A -XMINMA := $1f -XFREAD := $27 ; only in TELEMON 3.0 -XOPEN := $30 ; only in TELEMON 3.0 -XCOSCR := $34 ; switch off cursor -XCSSCR := $35 ; switch on cursor -XCLOSE := $3a ; Close file -XFWRITE:= $3b ; write - -XSONPS := $40 -XOUPS := $42 -XPLAY := $43 -XSOUND := $44 -XMUSIC := $45 -XZAP := $46 -XSHOOT := $47 -XCIRCL := $8f -XCURSE := $90 -XEXPLO := $9c -XPING := $9d -XPAPER := $92 -XINK := $93 - - -; --------------------------------------------------------------------------- -; Page 00 -RES := $00 -RESB := $02 - -TR0 := $0c -TR1 := $0d - -PTR_READ_DEST := $2c ; used for XFREAD and XWRITE - -HRSX := $46 -HRSY := $47 - -HRS1 := $4D -HRS2 := $4F -HRS3 := $51 -HRS4 := $53 -HRS5 := $55 +XRD0 = $08 +XRDW0 = $0C +XWR0 = $10 +XWSTR0 = $14 +XTEXT = $19 +XHIRES = $1A +XMINMA = $1F +XFREAD = $27 ; only in TELEMON 3.0 +XOPEN = $30 ; only in TELEMON 3.0 +XCOSCR = $34 ; switch off cursor +XCSSCR = $35 ; switch on cursor +XCLOSE = $3A ; only in TELEMON 3.0 Close file +XFWRITE = $3B ; only in TELEMON 3.0 write file +XSONPS = $40 +XOUPS = $42 +XPLAY = $43 +XSOUND = $44 +XMUSIC = $45 +XZAP = $46 +XSHOOT = $47 +XCIRCL = $8F +XCURSE = $90 +XEXPLO = $9C +XPING = $9D +XPAPER = $92 +XINK = $93 ; --------------------------------------------------------------------------- ; Page $500 -BUFNOM := $517 -BUFEDT := $590 +BUFNOM := $517 +BUFEDT := $590 MAX_BUFEDT_LENGTH=110 ; Hardware -CH376_DATA :=$340 -CH376_COMMAND :=$341 +CH376_DATA :=$340 +CH376_COMMAND :=$341 ; MACRO - .macro BRK_TELEMON value .byte $00,value .endmacro diff --git a/cfg/telemon24.cfg b/cfg/telemon24.cfg deleted file mode 100644 index b76350868..000000000 --- a/cfg/telemon24.cfg +++ /dev/null @@ -1,43 +0,0 @@ -SYMBOLS { - - __ORIXHDR__: type = import; - - __STACKSIZE__: type = weak, value = $0800; # 2K stack - - __RAMEND__: type = weak, value = $9800 + $1C00 ; -} -MEMORY { - ZP: file = "", define = yes, start = $00E2, size = $001A; - ORIXHDR: file = %O, type = ro, start = $0000, size = $001F; - BASHEAD: file = %O, define = yes, start = $0801, size = $000D; - MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__; - BSS: file = "", start = __ONCE_RUN__, size = __RAMEND__ - __STACKSIZE__ - __ONCE_RUN__; -} -SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - ORIXHDR: load = ORIXHDR, type = ro; - STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = rw; - ONCE: load = MAIN, type = ro, define = yes; - BASTAIL: load = MAIN, type = ro, optional = yes; - BSS: load = BSS, type = bss, define = yes; -} -FEATURES { - CONDES: type = constructor, - label = __CONSTRUCTOR_TABLE__, - count = __CONSTRUCTOR_COUNT__, - segment = ONCE; - CONDES: type = destructor, - label = __DESTRUCTOR_TABLE__, - count = __DESTRUCTOR_COUNT__, - segment = RODATA; - CONDES: type = interruptor, - label = __INTERRUPTOR_TABLE__, - count = __INTERRUPTOR_COUNT__, - segment = RODATA, - import = __CALLIRQ__; -} diff --git a/cfg/telemon30.cfg b/cfg/telestrat.cfg similarity index 100% rename from cfg/telemon30.cfg rename to cfg/telestrat.cfg diff --git a/doc/telemon24.sgml b/doc/telemon24.sgml deleted file mode 100644 index b4e1befa1..000000000 --- a/doc/telemon24.sgml +++ /dev/null @@ -1,42 +0,0 @@ -<!doctype linuxdoc system> - -<article> - -<title>Oric Telemon 2.4 -specific information for cc65 -<author> - -<url url="mailto:greg.king5@verizon.net" name="Greg King"> -<date>2017-01-22 - -<abstract> -An overview over the Telemon 3.0 runtime system as it is implemented for the cc65 C -compiler. -</abstract> - -<!-- Table of contents --> -<toc> - - - -<sect>License<p> - -This software is provided 'as-is', without any expressed or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -<enum> -<item> The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. -<item> Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. -<item> This notice may not be removed or altered from any source - distribution. -</enum> - -</article> diff --git a/doc/telemon30.sgml b/doc/telestrat.sgml similarity index 100% rename from doc/telemon30.sgml rename to doc/telestrat.sgml diff --git a/include/telemon.h b/include/telemon.h deleted file mode 100644 index 70033a9ad..000000000 --- a/include/telemon.h +++ /dev/null @@ -1,58 +0,0 @@ - -void print (char *); - -void hires(); -void text(); -void oups(); -void ping(); -void zap(); -void shoot(); -void explode(); - -void paper(char color); -void ink(char color); - -void kbdclick1(); - - - -void curset(char x,char y); -void circle(char rayon); - -char key(void); - - -/* PEEK, POKE, DEEK, DOKE */ - -#define POKE(addr,val) (*(unsigned char*) (addr) = (val)) - - -#define PCHN_1 001 -#define PCHN_2 002 -#define PCHN_12 003 -#define PCHN_3 004 -#define PCHN_13 005 -#define PCHN_23 006 -#define PCHN_123 007 - -#define ENV_DECAY 001 /* \_________ envelope */ -#define ENV_ATTACK_CUT 002 /* /_________ envelope */ -#define ENV_SAW_DOWN 003 /* \\\\\\\\\\ envelope */ -#define ENV_WAVE 004 /* /\/\/\/\/\ envelope */ -#define ENV_DECAY_CONT 005 /* \~~~~~~~~~ envelope */ -#define ENV_SAW_UP 006 /* ////////// envelope */ -#define ENV_ATTACK_CONT 007 /* /~~~~~~~~~ envelope */ - -#define VOL_ENVELOPE 0x0 -#define VOL_QUIETEST 0x1 -#define VOL_LOUDEST 0xe - -extern int play(int soundchanels,int noisechanels,int envelop,int volume); - - -/* Play a musical tone through the selected channel. */ - -#define CHAN_1 1 -#define CHAN_2 2 -#define CHAN_3 3 - diff --git a/include/telemon30.h b/include/telestrat.h similarity index 100% rename from include/telemon30.h rename to include/telestrat.h diff --git a/libsrc/Makefile b/libsrc/Makefile index 0342a8ca4..8bcbe4410 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -31,8 +31,7 @@ TARGETS = apple2 \ sim6502 \ sim65c02 \ supervision\ - telemon24\ - telemon30 + telestrat DRVTYPES = emd \ joy \ diff --git a/libsrc/telemon24/crt0.s b/libsrc/telemon24/crt0.s deleted file mode 100644 index a3c92a360..000000000 --- a/libsrc/telemon24/crt0.s +++ /dev/null @@ -1,101 +0,0 @@ -; -; Startup code for cc65 (Oric version) -; -; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org> -; 2016-03-18, Greg King -; - - .export _exit - .export __STARTUP__ : absolute = 1 ; Mark as startup - - .import initlib, donelib - .import callmain, zerobss - .import __MAIN_START__, __MAIN_SIZE__ - - .include "zeropage.inc" - .include "telemon24.inc" - -; ------------------------------------------------------------------------ -; Place the startup code in a special segment. - -.segment "STARTUP" - - tsx - stx spsave ; Save system stk ptr - -; Save space by putting some of the start-up code in a segment -; that will be re-used. - - jsr init - -; Clear the BSS variables (after the constructors have been run). - - jsr zerobss - -; Push the command-line arguments; and, call main(). - - jsr callmain - -; Call the module destructors. This is also the exit() entry. - -_exit: jsr donelib - -; Restore the system stuff. - - ldx spsave - txs -; lda stsave - ; sta STATUS - -; Copy back the zero-page stuff. - - ldx #zpspace - 1 -L2: lda zpsave,x - sta sp,x - dex - bpl L2 - -; Back to BASIC. - - rts - -; ------------------------------------------------------------------------ -; Put this code in a place that will be re-used by BSS, the heap, -; and the C stack. - -.segment "ONCE" - -; Save the zero-page area that we're about to use. - -init: ldx #zpspace - 1 -L1: lda sp,x - sta zpsave,x - dex - bpl L1 - -; Currently, color isn't supported on the text screen. -; Unprotect screen columns 0 and 1 (where each line's color codes would sit). - - ; lda STATUS - ; sta stsave - ; and #%11011111 - ; sta STATUS - -; Set up the C stack. - - lda #<(__MAIN_START__ + __MAIN_SIZE__) - ldx #>(__MAIN_START__ + __MAIN_SIZE__) - sta sp - stx sp+1 ; Set argument stack ptr - -; Call the module constructors. - - jmp initlib - -; ------------------------------------------------------------------------ - -.segment "INIT" - -spsave: .res 1 -stsave: .res 1 -zpsave: .res zpspace diff --git a/libsrc/telemon24/hires.s b/libsrc/telemon24/hires.s deleted file mode 100644 index 80d67824c..000000000 --- a/libsrc/telemon24/hires.s +++ /dev/null @@ -1,22 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-04-13 -; -; void hires(void); -; -; This function is a hack! -; - - .export _hires - - - .include "telemon24.inc" - - -; can be optimized with a macro -.proc _hires - brk - .byt $1a - rts -.endproc - - diff --git a/libsrc/telemon24/mainargs.s b/libsrc/telemon24/mainargs.s deleted file mode 100644 index d8547e500..000000000 --- a/libsrc/telemon24/mainargs.s +++ /dev/null @@ -1,36 +0,0 @@ -; -; 2003-03-07, Ullrich von Bassewitz -; 2011-01-28, Stefan Haubenthal -; 2014-09-10, Greg King -; -; Set up arguments for main -; - - .constructor initmainargs, 24 - .import __argc, __argv - - .include "telemon24.inc" - .macpack generic - -MAXARGS = 10 ; Maximum number of arguments allowed - - -.segment "ONCE" - -.proc initmainargs - -.endproc - -.segment "INIT" - -term: .res 1 -name: .res FNAME_LEN + 1 -args: .res SCREEN_XSIZE * 2 - 1 - -.data - -; This array has zeroes when initmainargs starts. -; char* argv[MAXARGS+1]={name}; - -argv: .addr name - .res MAXARGS * 2 diff --git a/libsrc/telemon24/print.s b/libsrc/telemon24/print.s deleted file mode 100644 index a135cdd18..000000000 --- a/libsrc/telemon24/print.s +++ /dev/null @@ -1,25 +0,0 @@ -; -; Jede -; -; print (char * str); -; -; This function is a hack! -; - - .export _print - .import popax - .importzp tmp1 - .include "telemon24.inc" - -.proc _print - - jsr popax ; get buf - stx tmp1 - ldy tmp1 - brk - .byte $14 - rts - -.endproc - - diff --git a/libsrc/telemon24/tapehdr.s b/libsrc/telemon24/tapehdr.s deleted file mode 100644 index 9b183e11e..000000000 --- a/libsrc/telemon24/tapehdr.s +++ /dev/null @@ -1,36 +0,0 @@ -; -; Based on code by Debrune Jérôme <jede@oric.org> -; 2016-03-17, Greg King -; - - ; The following symbol is used by the linker config. file - ; to force this module to be included into the output file. - .export __ORIXHDR__:abs = 1 - - ; These symbols, also, come from the configuration file. - .import __AUTORUN__, __PROGFLAG__ - .import __BASHEAD_START__, __MAIN_LAST__ - - -; ------------------------------------------------------------------------ -; Oric cassette-tape header - -.segment "ORIXHDR" - - .byte $01, $00 ; - - .byte "ORI" - - .byte $01 ; version - .byte $00,$00 ; mode - .byte $00,$00 ; cpu type - .byte $00,$00 ; OS - - .byte $00 ; reserved - .byte $00 ; auto - - - .dbyt __BASHEAD_START__ ; Address of start of file - .dbyt __MAIN_LAST__ - 1 ; Address of end of file - .dbyt __BASHEAD_START__ ; Address of start of file - diff --git a/libsrc/telemon24/write.s b/libsrc/telemon24/write.s deleted file mode 100644 index 32bbf617c..000000000 --- a/libsrc/telemon24/write.s +++ /dev/null @@ -1,59 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-04-13 -; -; int write (int fd, const void* buf, int count); -; -; This function is a hack! -; - - .export _write - .import popax - .importzp ptr1, ptr2, ptr3, tmp1 - - .include "telemon24.inc" - -.proc _write - - sta ptr3 - stx ptr3+1 ; save count as result - - eor #$FF - sta ptr2 - txa - eor #$FF - sta ptr2+1 ; Remember -count-1 - - jsr popax ; get buf - sta ptr1 - stx ptr1+1 - jsr popax ; get fd and discard -L1: inc ptr2 - bne L2 - inc ptr2+1 - beq L9 -L2: ldy #0 - lda (ptr1),y - tax - cpx #$0A ; Check for \n - bne L3 - brk - .byt $10 - - ldx #$0D -L3: - brk - .byt $10 - inc ptr1 - bne L1 - inc ptr1+1 - jmp L1 - -; No error, return count - -L9: lda ptr3 - ldx ptr3+1 - rts - -.endproc - - diff --git a/libsrc/telemon30/_close.s b/libsrc/telemon30/_close.s deleted file mode 100644 index 84bee3a1b..000000000 --- a/libsrc/telemon30/_close.s +++ /dev/null @@ -1,17 +0,0 @@ - .export _close - .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 - - ; int open (const char* name, int flags, ...); /* May take a mode argument */ - .include "telemon30.inc" - .include "errno.inc" - .include "fcntl.inc" - -.proc _close -; Throw away any additional parameters passed through the ellipsis - - BRK_TELEMON XCLOSE ; launch primitive ROM - rts -.endproc - - \ No newline at end of file diff --git a/libsrc/telemon30/_read.s b/libsrc/telemon30/_read.s deleted file mode 100644 index ee822f1fd..000000000 --- a/libsrc/telemon30/_read.s +++ /dev/null @@ -1,41 +0,0 @@ -; -; jede jede@oric.org 2017-01-22 -; - - - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term - .export _read - .import popax - - .include "zeropage.inc" - .include "telemon30.inc" -; int read (int fd, void* buf, unsigned count); - -.proc _read - sta ptr1 ; count - stx ptr1+1 ; count - jsr popax ; get buf - - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - sta ptr2 ; in order to calculate nb of bytes read - stx ptr2+1 ; - - ; jsr popax ; fp pointer don't care in this version - - lda ptr1 ; - ldy ptr1+1 ; - BRK_TELEMON XFREAD ; calls telemon30 routine - ; compute nb of bytes read - lda PTR_READ_DEST+1 - sec - sbc ptr2+1 - tax - lda PTR_READ_DEST - sec - sbc ptr2 - ; Here A and X contains number of bytes read - rts -.endproc - - diff --git a/libsrc/telemon30/_scrsize.s b/libsrc/telemon30/_scrsize.s deleted file mode 100644 index a929f97b1..000000000 --- a/libsrc/telemon30/_scrsize.s +++ /dev/null @@ -1,19 +0,0 @@ -; -; 2003-04-13, Ullrich von Bassewitz -; 2013-07-16, Greg King -; -; Screen size variables -; - - .export screensize - .include "telemon30.inc" - -.proc screensize - - ldx #SCREEN_XSIZE - ldy #SCREEN_YSIZE - rts - -.endproc - - diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s deleted file mode 100644 index 460a70052..000000000 --- a/libsrc/telemon30/ch376.s +++ /dev/null @@ -1,366 +0,0 @@ - - ; For XA65 compatibily in the future - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term - .export _ch376_set_file_name - .export _ch376_file_open - .export _ch376_ic_get_version - .export _ch376_reset - .export _ch376_check_exist - .export _ch376_disk_mount - .export _ch376_set_usb_mode - - .export _ch376_file_close - .export _ch376_seek_file - .export _ch376_file_create - .export _ch376_fwrite - ; High level function - - - .import popax - .include "zeropage.inc" - .include "telemon30.inc" -/* - -*/ -; CODE FOR CH376_SET_USB_MODE ************************************************* - -CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY := $06 - -CH376_USB_INT_SUCCESS := $14 -CH376_USB_INT_CONNECT := $15 -CH376_USB_INT_DISCONNECT := $16 -CH376_USB_INT_BUF_OVER := $17 -CH376_USB_INT_USB_READY := $18 -CH376_USB_INT_DISK_READ := $1D -CH376_USB_INT_DISK_WRITE := $1E -CH376_USB_INT_DISK_ERR := $1F - - -CH376_ERR_OPEN_DIR := $41 -CH376_ERR_MISS_FILE := $42 -CH376_ERR_FOUND_NAME := $43 -CH376_ERR_DISK_DISCON := $82 -CH376_ERR_LARGE_SECTOR := $84 -CH376_ERR_TYPE_ERROR := $92 -CH376_ERR_BPB_ERROR := $A1 -CH376_ERR_DISK_FULL := $B1 -CH376_ERR_FDT_OVER := $B2 -CH376_ERR_FILE_CLOSE := $B4 - - - -CH376_GET_IC_VER := $01 -CH376_SET_BAUDRATE := $02 -CH376_GET_ENTER_SLEEP := $03 -CH376_RESET_ALL := $05 -CH376_CHECK_EXIST := $06 -CH376_GET_FILE_SIZE := $0C - -CH376_SET_USB_MODE := $15 -CH376_GET_STATUS := $22 -CH376_RD_USB_DATA0 := $27 -CH376_CMD_WR_REQ_DATA := $2d -CH376_SET_FILE_NAME := $2F - -CH376_DISK_CONNECT := $30 ; check the disk connection status -CH376_DISK_MOUNT := $31 -CH376_FILE_OPEN := $32 -CH376_FILE_ENUM_GO := $33 -CH376_FILE_CREATE := $34 -CH376_FILE_CLOSE := $36 -CH376_BYTE_LOCATE := $39 -CH376_BYTE_READ := $3A -CH376_BYTE_RD_GO := $3B -CH376_BYTE_WRITE := $3C -CH376_BYTE_WR_GO := $3D -CH376_DISK_CAPACITY := $3E -CH376_DISK_RD_GO := $55 - -.proc _ch376_file_close - lda #CH376_FILE_CLOSE - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_seek_file - ldx #CH376_BYTE_LOCATE - stx CH376_COMMAND - sta CH376_DATA - sty CH376_DATA - lda #$00 ; Don't manage 32 bits length - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -; void ch376_set_file_name(char *filename) -.proc _ch376_set_file_name - sta ptr1 - stx ptr1+1 - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - ldy #0 -loop: - lda (ptr1),y ; replace by bufnom - beq end ; we reached 0 value - BRK_TELEMON XMINMA - sta CH376_DATA - iny - cpy #13 ; because we don't manage longfilename shortname =11 - bne loop -end: - sta CH376_DATA - rts -.endproc - -; char _ch376_file_open(); - -.proc _ch376_file_open - lda #CH376_FILE_OPEN ; $32 - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc - - - -.proc _ch376_get_file_size - lda #CH376_GET_FILE_SIZE - sta CH376_COMMAND - lda #$68 - sta CH376_DATA - ; store file length 32 bits - lda CH376_DATA - sta tmp1 - lda CH376_DATA - sta tmp1+1 - lda CH376_DATA - sta tmp2 - lda CH376_DATA - sta tmp2+1 - rts -.endproc - -; void ch376_reset(); - -.proc _ch376_reset - lda #CH376_RESET_ALL ; 5 - sta CH376_COMMAND - ; waiting - ldy #0 - ldx #0 -loop: - nop - inx - bne loop - iny - bne loop - rts -.endproc - -; char ch376_check_exist(char value); - -.proc _ch376_check_exist - sta tmp1 - lda #CH376_CHECK_EXIST ; - sta CH376_COMMAND - lda tmp1 - sta CH376_DATA - lda CH376_DATA - rts -.endproc - -; char ch376_ic_get_version(void) -.proc _ch376_ic_get_version - lda #CH376_GET_IC_VER - sta CH376_COMMAND - ldx #0 - lda CH376_DATA - rts -.endproc - -; void ch376_set_usb_mode(char mode) - -.proc _ch376_set_usb_mode -; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY - ldx #CH376_SET_USB_MODE ; $15 - stx CH376_COMMAND - sta CH376_DATA - rts -.endproc - -; void ch376_set_bytes_write(int value); -.proc _ch376_set_bytes_write - ldy #CH376_BYTE_WRITE - sty CH376_COMMAND - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_set_bytes_read - ldy #CH376_BYTE_READ - sty CH376_COMMAND - ; Storing 32 bits value - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -; char ch376_disk_mount(); -.proc _ch376_disk_mount - lda #CH376_DISK_MOUNT ; $31 - sta CH376_COMMAND - jsr _ch376_wait_response - ; if we read data value, we have then length of the volume name - ldx #0 - rts -.endproc - - -; char ch376_wait_response(); -.proc _ch376_wait_response -; 1 return 1 if usb controller does not respond -; else A contains answer of the controller - ldy #$ff -loop3: - ldx #$ff ; don't decrease this counter. Because ch376 won't respond if there is a lower value -loop: - lda CH376_COMMAND - and #%10000000 - cmp #128 - bne no_error - dex - bne loop - dey - bne loop3 - ; error is here - rts -no_error: - lda #CH376_GET_STATUS - sta CH376_COMMAND - lda CH376_DATA - rts -.endproc - -.proc _ch376_fread - ; use ptr1 to count bytes - jsr _ch376_set_bytes_read - -continue: - cmp #CH376_USB_INT_DISK_READ ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished - ; TODO in A : $ff X: $ff - lda #0 - tax - rts -we_read: - lda #CH376_RD_USB_DATA0 - sta CH376_COMMAND - - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read - - ldy #0 -loop: - lda CH376_DATA ; read the data - sta (PTR_READ_DEST),y - - iny - cpy tmp2 - bne loop - tya - clc - adc PTR_READ_DEST - bcc next - inc PTR_READ_DEST+1 -next: - sta PTR_READ_DEST - - lda #CH376_BYTE_RD_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue -finished: - ; TODO return bytes read - lda tmp1 - ldx tmp1+1 - rts -.endproc - -; void _ch376_fwrite(void *ptr,int number) -.proc _ch376_fwrite - ; use ptr1 to count bytes - sta ptr2 - stx ptr2+1 - - jsr popax - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - - lda ptr2 - ldx ptr2+1 - jsr _ch376_set_bytes_write - ;cmp #CH376_USB_INT_SUCCESS - ;beq finished - ;jsr popax - - ;jsr _ch376_wait_response - -continue: - cmp #CH376_USB_INT_DISK_WRITE ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished - ; TODO in A : $ff X: $ff - lda #0 - tax - rts -we_read: - lda #CH376_CMD_WR_REQ_DATA - sta CH376_COMMAND - - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read - - - ;ldy #0 -loop: - ;lda (PTR_READ_DEST),y - lda #65 - sta CH376_DATA ; read the data - dec tmp2 - bne loop - - - lda #CH376_BYTE_WR_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue -finished: - ; TODO return bytes read - lda tmp1 - ;lda #<8000 - ldx tmp1+1 - ;ldx #>8000 - rts -.endproc - -.proc _ch376_file_create - lda #CH376_FILE_CREATE - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc \ No newline at end of file diff --git a/libsrc/telemon30/ctype.s b/libsrc/telemon30/ctype.s deleted file mode 100644 index 79edafbb2..000000000 --- a/libsrc/telemon30/ctype.s +++ /dev/null @@ -1,299 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-04-13 -; -; Character specification table. -; - -; The tables are readonly, put them into the rodata segment - -.rodata - -; The following 256 byte wide table specifies attributes for the isxxx type -; of functions. Doing it by a table means some overhead in space, but it -; has major advantages: -; -; * It is fast. If it were'nt for the slow parameter passing of cc65, one -; could even define macros for the isxxx functions (this is usually -; done on other platforms). -; -; * It is highly portable. The only unportable part is the table itself, -; all real code goes into the common library. -; -; * We save some code in the isxxx functions. -; -; -; Bit assignments: -; -; 0 - Lower case char -; 1 - Upper case char -; 2 - Numeric digit -; 3 - Hex digit (both, lower and upper) -; 4 - Control character -; 5 - The space character itself -; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v') -; 7 - Space or tab character - - .export __ctype - -__ctype: - .byte $10 ; 0/00 ___ctrl_@___ - .byte $10 ; 1/01 ___ctrl_A___ - .byte $10 ; 2/02 ___ctrl_B___ - .byte $10 ; 3/03 ___ctrl_C___ - .byte $10 ; 4/04 ___ctrl_D___ - .byte $10 ; 5/05 ___ctrl_E___ - .byte $10 ; 6/06 ___ctrl_F___ - .byte $10 ; 7/07 ___ctrl_G___ - .byte $10 ; 8/08 ___ctrl_H___ - .byte $D0 ; 9/09 ___ctrl_I___ - .byte $50 ; 10/0a ___ctrl_J___ - .byte $50 ; 11/0b ___ctrl_K___ - .byte $50 ; 12/0c ___ctrl_L___ - .byte $50 ; 13/0d ___ctrl_M___ - .byte $10 ; 14/0e ___ctrl_N___ - .byte $10 ; 15/0f ___ctrl_O___ - .byte $10 ; 16/10 ___ctrl_P___ - .byte $10 ; 17/11 ___ctrl_Q___ - .byte $10 ; 18/12 ___ctrl_R___ - .byte $10 ; 19/13 ___ctrl_S___ - .byte $10 ; 20/14 ___ctrl_T___ - .byte $10 ; 21/15 ___ctrl_U___ - .byte $10 ; 22/16 ___ctrl_V___ - .byte $10 ; 23/17 ___ctrl_W___ - .byte $10 ; 24/18 ___ctrl_X___ - .byte $10 ; 25/19 ___ctrl_Y___ - .byte $10 ; 26/1a ___ctrl_Z___ - .byte $10 ; 27/1b ___ctrl_[___ - .byte $10 ; 28/1c ___ctrl_\___ - .byte $10 ; 29/1d ___ctrl_]___ - .byte $10 ; 30/1e ___ctrl_^___ - .byte $10 ; 31/1f ___ctrl_____ - .byte $A0 ; 32/20 ___SPACE___ - .byte $00 ; 33/21 _____!_____ - .byte $00 ; 34/22 _____"_____ - .byte $00 ; 35/23 _____#_____ - .byte $00 ; 36/24 _____$_____ - .byte $00 ; 37/25 _____%_____ - .byte $00 ; 38/26 _____&_____ - .byte $00 ; 39/27 _____'_____ - .byte $00 ; 40/28 _____(_____ - .byte $00 ; 41/29 _____)_____ - .byte $00 ; 42/2a _____*_____ - .byte $00 ; 43/2b _____+_____ - .byte $00 ; 44/2c _____,_____ - .byte $00 ; 45/2d _____-_____ - .byte $00 ; 46/2e _____._____ - .byte $00 ; 47/2f _____/_____ - .byte $0C ; 48/30 _____0_____ - .byte $0C ; 49/31 _____1_____ - .byte $0C ; 50/32 _____2_____ - .byte $0C ; 51/33 _____3_____ - .byte $0C ; 52/34 _____4_____ - .byte $0C ; 53/35 _____5_____ - .byte $0C ; 54/36 _____6_____ - .byte $0C ; 55/37 _____7_____ - .byte $0C ; 56/38 _____8_____ - .byte $0C ; 57/39 _____9_____ - .byte $00 ; 58/3a _____:_____ - .byte $00 ; 59/3b _____;_____ - .byte $00 ; 60/3c _____<_____ - .byte $00 ; 61/3d _____=_____ - .byte $00 ; 62/3e _____>_____ - .byte $00 ; 63/3f _____?_____ - - .byte $00 ; 64/40 _____@_____ - .byte $0A ; 65/41 _____A_____ - .byte $0A ; 66/42 _____B_____ - .byte $0A ; 67/43 _____C_____ - .byte $0A ; 68/44 _____D_____ - .byte $0A ; 69/45 _____E_____ - .byte $0A ; 70/46 _____F_____ - .byte $02 ; 71/47 _____G_____ - .byte $02 ; 72/48 _____H_____ - .byte $02 ; 73/49 _____I_____ - .byte $02 ; 74/4a _____J_____ - .byte $02 ; 75/4b _____K_____ - .byte $02 ; 76/4c _____L_____ - .byte $02 ; 77/4d _____M_____ - .byte $02 ; 78/4e _____N_____ - .byte $02 ; 79/4f _____O_____ - .byte $02 ; 80/50 _____P_____ - .byte $02 ; 81/51 _____Q_____ - .byte $02 ; 82/52 _____R_____ - .byte $02 ; 83/53 _____S_____ - .byte $02 ; 84/54 _____T_____ - .byte $02 ; 85/55 _____U_____ - .byte $02 ; 86/56 _____V_____ - .byte $02 ; 87/57 _____W_____ - .byte $02 ; 88/58 _____X_____ - .byte $02 ; 89/59 _____Y_____ - .byte $02 ; 90/5a _____Z_____ - .byte $00 ; 91/5b _____[_____ - .byte $00 ; 92/5c _____\_____ - .byte $00 ; 93/5d _____]_____ - .byte $00 ; 94/5e _____^_____ - .byte $00 ; 95/5f _UNDERLINE_ - .byte $00 ; 96/60 ___grave___ - .byte $09 ; 97/61 _____a_____ - .byte $09 ; 98/62 _____b_____ - .byte $09 ; 99/63 _____c_____ - .byte $09 ; 100/64 _____d_____ - .byte $09 ; 101/65 _____e_____ - .byte $09 ; 102/66 _____f_____ - .byte $01 ; 103/67 _____g_____ - .byte $01 ; 104/68 _____h_____ - .byte $01 ; 105/69 _____i_____ - .byte $01 ; 106/6a _____j_____ - .byte $01 ; 107/6b _____k_____ - .byte $01 ; 108/6c _____l_____ - .byte $01 ; 109/6d _____m_____ - .byte $01 ; 110/6e _____n_____ - .byte $01 ; 111/6f _____o_____ - .byte $01 ; 112/70 _____p_____ - .byte $01 ; 113/71 _____q_____ - .byte $01 ; 114/72 _____r_____ - .byte $01 ; 115/73 _____s_____ - .byte $01 ; 116/74 _____t_____ - .byte $01 ; 117/75 _____u_____ - .byte $01 ; 118/76 _____v_____ - .byte $01 ; 119/77 _____w_____ - .byte $01 ; 120/78 _____x_____ - .byte $01 ; 121/79 _____y_____ - .byte $01 ; 122/7a _____z_____ - .byte $00 ; 123/7b _____{_____ - .byte $00 ; 124/7c _____|_____ - .byte $00 ; 125/7d _____}_____ - .byte $00 ; 126/7e _____~_____ - .byte $40 ; 127/7f ____DEL____ - - .byte $00 ; 128/80 ___________ - .byte $00 ; 129/81 ___________ - .byte $00 ; 130/82 ___________ - .byte $00 ; 131/83 ___________ - .byte $00 ; 132/84 ___________ - .byte $00 ; 133/85 ___________ - .byte $00 ; 134/86 ___________ - .byte $00 ; 135/87 ___________ - .byte $00 ; 136/88 ___________ - .byte $00 ; 137/89 ___________ - .byte $00 ; 138/8a ___________ - .byte $00 ; 139/8b ___________ - .byte $00 ; 140/8c ___________ - .byte $00 ; 141/8d ___________ - .byte $00 ; 142/8e ___________ - .byte $00 ; 143/8f ___________ - .byte $00 ; 144/90 ___________ - .byte $00 ; 145/91 ___________ - .byte $00 ; 146/92 ___________ - .byte $10 ; 147/93 ___________ - .byte $00 ; 148/94 ___________ - .byte $00 ; 149/95 ___________ - .byte $00 ; 150/96 ___________ - .byte $00 ; 151/97 ___________ - .byte $00 ; 152/98 ___________ - .byte $00 ; 153/99 ___________ - .byte $00 ; 154/9a ___________ - .byte $00 ; 155/9b ___________ - .byte $00 ; 156/9c ___________ - .byte $00 ; 157/9d ___________ - .byte $00 ; 158/9e ___________ - .byte $00 ; 159/9f ___________ - - .byte $00 ; 160/a0 ___________ - .byte $00 ; 161/a1 ___________ - .byte $00 ; 162/a2 ___________ - .byte $00 ; 163/a3 ___________ - .byte $00 ; 164/a4 ___________ - .byte $00 ; 165/a5 ___________ - .byte $00 ; 166/a6 ___________ - .byte $00 ; 167/a7 ___________ - .byte $00 ; 168/a8 ___________ - .byte $00 ; 169/a9 ___________ - .byte $00 ; 170/aa ___________ - .byte $00 ; 171/ab ___________ - .byte $00 ; 172/ac ___________ - .byte $00 ; 173/ad ___________ - .byte $00 ; 174/ae ___________ - .byte $00 ; 175/af ___________ - .byte $00 ; 176/b0 ___________ - .byte $00 ; 177/b1 ___________ - .byte $00 ; 178/b2 ___________ - .byte $00 ; 179/b3 ___________ - .byte $00 ; 180/b4 ___________ - .byte $00 ; 181/b5 ___________ - .byte $00 ; 182/b6 ___________ - .byte $00 ; 183/b7 ___________ - .byte $00 ; 184/b8 ___________ - .byte $00 ; 185/b9 ___________ - .byte $00 ; 186/ba ___________ - .byte $00 ; 187/bb ___________ - .byte $00 ; 188/bc ___________ - .byte $00 ; 189/bd ___________ - .byte $00 ; 190/be ___________ - .byte $00 ; 191/bf ___________ - - .byte $02 ; 192/c0 ___________ - .byte $02 ; 193/c1 ___________ - .byte $02 ; 194/c2 ___________ - .byte $02 ; 195/c3 ___________ - .byte $02 ; 196/c4 ___________ - .byte $02 ; 197/c5 ___________ - .byte $02 ; 198/c6 ___________ - .byte $02 ; 199/c7 ___________ - .byte $02 ; 200/c8 ___________ - .byte $02 ; 201/c9 ___________ - .byte $02 ; 202/ca ___________ - .byte $02 ; 203/cb ___________ - .byte $02 ; 204/cc ___________ - .byte $02 ; 205/cd ___________ - .byte $02 ; 206/ce ___________ - .byte $02 ; 207/cf ___________ - .byte $02 ; 208/d0 ___________ - .byte $02 ; 209/d1 ___________ - .byte $02 ; 210/d2 ___________ - .byte $02 ; 211/d3 ___________ - .byte $02 ; 212/d4 ___________ - .byte $02 ; 213/d5 ___________ - .byte $02 ; 214/d6 ___________ - .byte $02 ; 215/d7 ___________ - .byte $02 ; 216/d8 ___________ - .byte $02 ; 217/d9 ___________ - .byte $02 ; 218/da ___________ - .byte $02 ; 219/db ___________ - .byte $02 ; 220/dc ___________ - .byte $02 ; 221/dd ___________ - .byte $02 ; 222/de ___________ - .byte $00 ; 223/df ___________ - .byte $01 ; 224/e0 ___________ - .byte $01 ; 225/e1 ___________ - .byte $01 ; 226/e2 ___________ - .byte $01 ; 227/e3 ___________ - .byte $01 ; 228/e4 ___________ - .byte $01 ; 229/e5 ___________ - .byte $01 ; 230/e6 ___________ - .byte $01 ; 231/e7 ___________ - .byte $01 ; 232/e8 ___________ - .byte $01 ; 233/e9 ___________ - .byte $01 ; 234/ea ___________ - .byte $01 ; 235/eb ___________ - .byte $01 ; 236/ec ___________ - .byte $01 ; 237/ed ___________ - .byte $01 ; 238/ee ___________ - .byte $01 ; 239/ef ___________ - .byte $01 ; 240/f0 ___________ - .byte $01 ; 241/f1 ___________ - .byte $01 ; 242/f2 ___________ - .byte $01 ; 243/f3 ___________ - .byte $01 ; 244/f4 ___________ - .byte $01 ; 245/f5 ___________ - .byte $01 ; 246/f6 ___________ - .byte $01 ; 247/f7 ___________ - .byte $01 ; 248/f8 ___________ - .byte $01 ; 249/f9 ___________ - .byte $01 ; 250/fa ___________ - .byte $01 ; 251/fb ___________ - .byte $01 ; 252/fc ___________ - .byte $01 ; 253/fd ___________ - .byte $01 ; 254/fe ___________ - .byte $00 ; 255/ff ___________ - diff --git a/libsrc/telemon30/graphics.s b/libsrc/telemon30/graphics.s deleted file mode 100644 index 4f2b09162..000000000 --- a/libsrc/telemon30/graphics.s +++ /dev/null @@ -1,54 +0,0 @@ - .export _paper,_hires,_text,_circle,_curset, _switchOffCursor - .importzp sp,tmp2,tmp3,tmp1 - .import popa - .include "telemon30.inc" - -.proc _paper - ldx #0 ; First window - ; A contains the paper - BRK_TELEMON XPAPER - rts -.endproc - -; XINK is bugged, it corrupt memory : removing from export -.proc _ink - ldx #0 ; First window - ; A contains the ink - BRK_TELEMON XINK - rts -.endproc - -; can be optimized with a macro -.proc _hires - BRK_TELEMON XHIRES - rts -.endproc - -.proc _text - BRK_TELEMON XTEXT - rts -.endproc - -.proc _curset - jsr popa ; Pixel - jsr popa - sta HRSX - jsr popa - sta HRSY - BRK_TELEMON XCURSE - rts -.endproc - -.proc _circle - sta HRS1 - BRK_TELEMON XCIRCL - rts -.endproc - -.proc _switchOffCursor - ldx #0 - BRK_TELEMON XCOSCR - rts -.endproc - - diff --git a/libsrc/telemon30/keyboard.s b/libsrc/telemon30/keyboard.s deleted file mode 100644 index 974f841e6..000000000 --- a/libsrc/telemon30/keyboard.s +++ /dev/null @@ -1,13 +0,0 @@ - .export _key - .importzp sp,tmp2,tmp3,tmp1 - - .include "telemon30.inc" - - -; char key(void); - -.proc _key - BRK_TELEMON XRDW0 ; read keyboard - rts -.endproc - diff --git a/libsrc/telemon30/oserrlist.s b/libsrc/telemon30/oserrlist.s deleted file mode 100644 index 8ec41de6d..000000000 --- a/libsrc/telemon30/oserrlist.s +++ /dev/null @@ -1,75 +0,0 @@ -; -; Stefan Haubenthal, 2004-05-25 -; Ullrich von Bassewitz, 18.07.2002 -; -; Defines the platform specific error list. -; -; The table is built as a list of entries -; -; .byte entrylen -; .byte errorcode -; .asciiz errormsg -; -; and terminated by an entry with length zero that is returned if the -; error code could not be found. -; - - .export __sys_oserrlist - -;---------------------------------------------------------------------------- -; Macros used to generate the list (may get moved to an include file?) - -; Regular entry -.macro sys_oserr_entry code, msg - .local Start, End -Start: .byte End - Start - .byte code - .asciiz msg -End: -.endmacro - -; Sentinel entry -.macro sys_oserr_sentinel msg - .byte 0 ; Length is always zero - .byte 0 ; Code is unused - .asciiz msg -.endmacro - -;---------------------------------------------------------------------------- -; The error message table - -.rodata - -__sys_oserrlist: - sys_oserr_entry 1, "File not found" - sys_oserr_entry 2, "Invalid command end" - sys_oserr_entry 3, "No drive number" - sys_oserr_entry 4, "Bad drive number" - sys_oserr_entry 5, "Invalid filename" - sys_oserr_entry 6, "fderr=(error number)" - sys_oserr_entry 7, "Illegal attribute" - sys_oserr_entry 8, "Wildcard(s) not allowed" - sys_oserr_entry 9, "File already exists" - sys_oserr_entry 10, "Insufficient disc space" - sys_oserr_entry 11, "File open" - sys_oserr_entry 12, "Illegal quantity" - sys_oserr_entry 13, "End address missing" - sys_oserr_entry 14, "Start address > end address" - sys_oserr_entry 15, "Missing 'to'" - sys_oserr_entry 16, "Renamed file not on same disc" - sys_oserr_entry 17, "Unknown array" - sys_oserr_entry 18, "Target drive not source drive" - sys_oserr_entry 19, "Destination not specified" - sys_oserr_entry 20, "Cannot merge and overwrite" - sys_oserr_entry 21, "Single target file illegal" - sys_oserr_entry 22, "Syntax" - sys_oserr_entry 23, "Filename missing" - sys_oserr_entry 24, "Source file missing" - sys_oserr_entry 25, "Type mismatch" - sys_oserr_entry 26, "Disc write-protected" - sys_oserr_entry 27, "Incompatible drives" - sys_oserr_entry 28, "File not open" - sys_oserr_entry 29, "File end" - sys_oserr_sentinel "Unknown error" - - diff --git a/libsrc/telemon30/oserror.s b/libsrc/telemon30/oserror.s deleted file mode 100644 index 37c9bd7fc..000000000 --- a/libsrc/telemon30/oserror.s +++ /dev/null @@ -1,17 +0,0 @@ -; -; Stefan Haubenthal, 2011-04-18 -; -; int __fastcall__ _osmaperrno (unsigned char oserror); -; /* Map a system specific error into a system independent code */ -; - - .include "errno.inc" - .export __osmaperrno - -.proc __osmaperrno - - lda #<EUNKNOWN - ldx #>EUNKNOWN - rts - -.endproc diff --git a/libsrc/telemon30/print.s b/libsrc/telemon30/print.s deleted file mode 100644 index 56c513fd6..000000000 --- a/libsrc/telemon30/print.s +++ /dev/null @@ -1,21 +0,0 @@ -; -; Jede -; -; print (char * str); -; -; This function is a hack! -; - - .export _print - .import popax - .importzp tmp1 - .include "telemon30.inc" - -.proc _print - stx tmp1 - ldy tmp1 - BRK_TELEMON XWSTR0 - rts -.endproc - - diff --git a/libsrc/telemon30/sound.s b/libsrc/telemon30/sound.s deleted file mode 100644 index 2df18f4a0..000000000 --- a/libsrc/telemon30/sound.s +++ /dev/null @@ -1,45 +0,0 @@ - .export _kbdclick1,_oups,_ping,_explode,_shoot,_zap - .include "telemon30.inc" - -.proc _kbdclick1 - LDX #<sound_bip_keyboard - LDY #>sound_bip_keyboard - BRK_TELEMON XSONPS - rts -sound_bip_keyboard: - .byte $1f,$00,$00,$00,$00,$00,$00,$3e,$10,$00,$00,$1f,$00,$00 -.endproc - -.proc _explode - BRK_TELEMON XEXPLO - rts -.endproc - -.proc _oups - BRK_TELEMON XOUPS - rts -.endproc - -.proc _ping - BRK_TELEMON XPING - rts -.endproc - -.proc _shoot - BRK_TELEMON XSHOOT - rts -.endproc - -.proc _zap - BRK_TELEMON XZAP - rts -.endproc - - - -; XPLAY := $43 -; XSOUND := $44 -; XMUSIC := $45 - - - diff --git a/libsrc/telemon30/sysuname.s b/libsrc/telemon30/sysuname.s deleted file mode 100644 index 51af1d8fe..000000000 --- a/libsrc/telemon30/sysuname.s +++ /dev/null @@ -1,46 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-08-12 -; -; unsigned char __fastcall__ _sysuname (struct utsname* buf); -; - - .export __sysuname, utsdata - - .import utscopy - - __sysuname = utscopy - -;-------------------------------------------------------------------------- -; Data. We define a fixed utsname struct here and just copy it. - -.rodata - -utsdata: - ; sysname - .asciiz "cc65" - - ; nodename - .asciiz "" - - ; release - .byte ((.VERSION >> 8) & $0F) + '0' - .byte '.' - .if ((.VERSION >> 4) & $0F) > 9 - .byte ((.VERSION >> 4) & $0F) / 10 + '0' - .byte ((.VERSION >> 4) & $0F) .MOD 10 + '0' - .else - .byte ((.VERSION >> 4) & $0F) + '0' - .endif - .byte $00 - - ; version - .if (.VERSION & $0F) > 9 - .byte (.VERSION & $0F) / 10 + '0' - .byte (.VERSION & $0F) .MOD 10 + '0' - .else - .byte (.VERSION & $0F) + '0' - .endif - .byte $00 - - ; machine - .asciiz "Oric Telestrat" diff --git a/libsrc/telestrat/ch376.s b/libsrc/telestrat/ch376.s new file mode 100644 index 000000000..fbfa16017 --- /dev/null +++ b/libsrc/telestrat/ch376.s @@ -0,0 +1,344 @@ + +; jede jede@oric.org 2017-01-22 + + ; For XA65 compatibily in the future + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term + .export _ch376_set_file_name + .export _ch376_file_open + .export _ch376_ic_get_version + .export _ch376_reset + .export _ch376_check_exist + .export _ch376_disk_mount + .export _ch376_set_usb_mode + .export _ch376_file_close + .export _ch376_seek_file + .export _ch376_file_create + .export _ch376_fwrite + + .import popax + .include "zeropage.inc" + .include "telestrat.inc" + + + + + +CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY = $06 + +CH376_USB_INT_SUCCESS = $14 +CH376_USB_INT_CONNECT = $15 +CH376_USB_INT_DISCONNECT = $16 +CH376_USB_INT_BUF_OVER = $17 +CH376_USB_INT_USB_READY = $18 +CH376_USB_INT_DISK_READ = $1D +CH376_USB_INT_DISK_WRITE = $1E +CH376_USB_INT_DISK_ERR = $1F + + +CH376_ERR_OPEN_DIR = $41 +CH376_ERR_MISS_FILE = $42 +CH376_ERR_FOUND_NAME = $43 +CH376_ERR_DISK_DISCON = $82 +CH376_ERR_LARGE_SECTOR = $84 +CH376_ERR_TYPE_ERROR = $92 +CH376_ERR_BPB_ERROR = $A1 +CH376_ERR_DISK_FULL = $B1 +CH376_ERR_FDT_OVER = $B2 +CH376_ERR_FILE_CLOSE = $B4 + +CH376_GET_IC_VER = $01 +CH376_SET_BAUDRATE = $02 +CH376_GET_ENTER_SLEEP = $03 +CH376_RESET_ALL = $05 +CH376_CHECK_EXIST = $06 +CH376_GET_FILE_SIZE = $0C + +CH376_SET_USB_MODE = $15 +CH376_GET_STATUS = $22 +CH376_RD_USB_DATA0 = $27 +CH376_CMD_WR_REQ_DATA = $2D +CH376_SET_FILE_NAME = $2F + +CH376_DISK_CONNECT = $30 ; check the disk connection status +CH376_DISK_MOUNT = $31 +CH376_FILE_OPEN = $32 +CH376_FILE_ENUM_GO = $33 +CH376_FILE_CREATE = $34 +CH376_FILE_CLOSE = $36 +CH376_BYTE_LOCATE = $39 +CH376_BYTE_READ = $3A +CH376_BYTE_RD_GO = $3B +CH376_BYTE_WRITE = $3C +CH376_BYTE_WR_GO = $3D +CH376_DISK_CAPACITY = $3E +CH376_DISK_RD_GO = $55 + +.proc _ch376_file_close + lda #CH376_FILE_CLOSE + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc + +.proc _ch376_seek_file + ldx #CH376_BYTE_LOCATE + stx CH376_COMMAND + sta CH376_DATA + sty CH376_DATA + lda #$00 ; Don't manage 32 bits length + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +; void ch376_set_file_name(char *filename) +.proc _ch376_set_file_name + sta ptr1 + stx ptr1+1 + lda #CH376_SET_FILE_NAME ;$2f + sta CH376_COMMAND + ldy #0 +loop: + lda (ptr1),y ; replace by bufnom + beq end ; we reached 0 value + BRK_TELEMON XMINMA + sta CH376_DATA + iny + cpy #13 ; because we don't manage longfilename shortname =11 + bne loop +end: + sta CH376_DATA + rts +.endproc + +; char _ch376_file_open(); +.proc _ch376_file_open + lda #CH376_FILE_OPEN ; $32 + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc + +.proc _ch376_get_file_size + lda #CH376_GET_FILE_SIZE + sta CH376_COMMAND + lda #$68 + sta CH376_DATA + ; store file length 32 bits + lda CH376_DATA + sta tmp1 + lda CH376_DATA + sta tmp1+1 + lda CH376_DATA + sta tmp2 + lda CH376_DATA + sta tmp2+1 + rts +.endproc + +; void ch376_reset(); +.proc _ch376_reset + lda #CH376_RESET_ALL ; 5 + sta CH376_COMMAND + ; waiting + ldy #0 + ldx #0 +loop: + nop + inx + bne loop + iny + bne loop + rts +.endproc + +; char ch376_check_exist(char value); + +.proc _ch376_check_exist + sta tmp1 + lda #CH376_CHECK_EXIST ; + sta CH376_COMMAND + lda tmp1 + sta CH376_DATA + lda CH376_DATA + rts +.endproc + +; char ch376_ic_get_version(void) +.proc _ch376_ic_get_version + lda #CH376_GET_IC_VER + sta CH376_COMMAND + ldx #0 + lda CH376_DATA + rts +.endproc + +; void ch376_set_usb_mode(char mode) +.proc _ch376_set_usb_mode + ldx #CH376_SET_USB_MODE ; $15 + stx CH376_COMMAND + sta CH376_DATA + rts +.endproc + +; void ch376_set_bytes_write(int value); +.proc _ch376_set_bytes_write + ldy #CH376_BYTE_WRITE + sty CH376_COMMAND + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +.proc _ch376_set_bytes_read + ldy #CH376_BYTE_READ + sty CH376_COMMAND + ; Storing 32 bits value + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +; char ch376_disk_mount(); +.proc _ch376_disk_mount + lda #CH376_DISK_MOUNT ; $31 + sta CH376_COMMAND + jsr _ch376_wait_response + ; if we read data value, we have then length of the volume name + ldx #0 + rts +.endproc + + +; char ch376_wait_response(); +.proc _ch376_wait_response +; return 1 if usb controller does not respond +; else A contains answer of the controller + ldy #$FF ; We have to wait 35 ms, but well, this loop is broken when controler is OK +loop3: + ldx #$FF ; don't decrease this counter. Because ch376 won't respond if there is a lower value +loop: + lda CH376_COMMAND + and #%10000000 + cmp #128 + bne no_error + dex + bne loop + dey + bne loop3 + ; error is here + rts +no_error: + lda #CH376_GET_STATUS + sta CH376_COMMAND + lda CH376_DATA + rts +.endproc + +.proc _ch376_fread + ; use ptr1 to count bytes + jsr _ch376_set_bytes_read +continue: + cmp #CH376_USB_INT_DISK_READ ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished + ; TODO in A : $ff X: $ff + lda #0 + tax + rts +we_read: + lda #CH376_RD_USB_DATA0 + sta CH376_COMMAND + + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read + + ldy #0 +loop: + lda CH376_DATA ; read the data + sta (PTR_READ_DEST),y + iny + cpy tmp2 + bne loop + tya + clc + adc PTR_READ_DEST + bcc next + inc PTR_READ_DEST+1 +next: + sta PTR_READ_DEST + + lda #CH376_BYTE_RD_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue +finished: + ; TODO return bytes read + lda tmp1 + ldx tmp1+1 + rts +.endproc + +; void _ch376_fwrite(void *ptr,int number) +.proc _ch376_fwrite + ; use ptr1 to count bytes + sta ptr2 + stx ptr2+1 + + jsr popax + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + + lda ptr2 + ldx ptr2+1 + jsr _ch376_set_bytes_write +continue: + cmp #CH376_USB_INT_DISK_WRITE ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished + + lda #0 + tax + rts +we_read: + lda #CH376_CMD_WR_REQ_DATA + sta CH376_COMMAND + + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read + + ldy #0 +loop: + lda (PTR_READ_DEST),y + sta CH376_DATA ; read the data + dec tmp2 + bne loop + + + lda #CH376_BYTE_WR_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue +finished: + lda tmp1 + ldx tmp1+1 + rts +.endproc + +.proc _ch376_file_create + lda #CH376_FILE_CREATE + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc diff --git a/libsrc/telestrat/close.s b/libsrc/telestrat/close.s new file mode 100644 index 000000000..881d0897f --- /dev/null +++ b/libsrc/telestrat/close.s @@ -0,0 +1,18 @@ +; jede jede@oric.org 2017-01-22 + + .export _close + + .import addysp,popax + + .include "zeropage.inc" + .include "telestrat.inc" + .include "errno.inc" + .include "fcntl.inc" + +; int open (const char* name, int flags, ...); /* May take a mode argument */ +.proc _close + BRK_TELEMON XCLOSE ; launch primitive ROM + rts +.endproc + + \ No newline at end of file diff --git a/libsrc/telemon30/crt0.s b/libsrc/telestrat/crt0.s similarity index 85% rename from libsrc/telemon30/crt0.s rename to libsrc/telestrat/crt0.s index 72bad5f24..59b1ea642 100644 --- a/libsrc/telemon30/crt0.s +++ b/libsrc/telestrat/crt0.s @@ -2,7 +2,6 @@ ; Startup code for cc65 (Oric version) ; ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org> -; 2016-03-18, Greg King ; .export _exit @@ -13,7 +12,7 @@ .import __MAIN_START__, __MAIN_SIZE__ .include "zeropage.inc" - .include "telemon30.inc" + .include "telestrat.inc" ; ------------------------------------------------------------------------ ; Place the startup code in a special segment. @@ -44,8 +43,6 @@ _exit: jsr donelib ldx spsave txs -; lda stsave - ; sta STATUS ; Copy back the zero-page stuff. @@ -73,13 +70,6 @@ L1: lda sp,x dex bpl L1 -; Currently, color isn't supported on the text screen. -; Unprotect screen columns 0 and 1 (where each line's color codes would sit). - - ; lda STATUS - ; sta stsave - ; and #%11011111 - ; sta STATUS ; Set up the C stack. diff --git a/libsrc/telemon24/ctype.s b/libsrc/telestrat/ctype.s similarity index 100% rename from libsrc/telemon24/ctype.s rename to libsrc/telestrat/ctype.s diff --git a/libsrc/telestrat/graphics.s b/libsrc/telestrat/graphics.s new file mode 100644 index 000000000..9984036bb --- /dev/null +++ b/libsrc/telestrat/graphics.s @@ -0,0 +1,58 @@ +; jede jede@oric.org 2017-01-22 + + .export _paper,_hires,_text,_circle,_curset, _switchOffCursor + + .include "zeropage.inc" + .include "telestrat.inc" + .import popa + + +.proc _paper + ldx #0 ; First window + ; A contains the paper + BRK_TELEMON XPAPER + rts +.endproc + +; XINK is bugged, it corrupt memory : removing from export +.proc _ink + ldx #0 ; First window + ; A contains the ink + BRK_TELEMON XINK + rts +.endproc + +; can be optimized with a macro +.proc _hires + BRK_TELEMON XHIRES + rts +.endproc + +.proc _text + BRK_TELEMON XTEXT + rts +.endproc + +.proc _curset + jsr popa ; Pixel + jsr popa + sta HRSX + jsr popa + sta HRSY + BRK_TELEMON XCURSE + rts +.endproc + +.proc _circle + sta HRS1 + BRK_TELEMON XCIRCL + rts +.endproc + +.proc _switchOffCursor + ldx #0 + BRK_TELEMON XCOSCR + rts +.endproc + + diff --git a/libsrc/telestrat/keyboard.s b/libsrc/telestrat/keyboard.s new file mode 100644 index 000000000..7069d1003 --- /dev/null +++ b/libsrc/telestrat/keyboard.s @@ -0,0 +1,14 @@ +; jede jede@oric.org 2017-01-22 + + .export _key + + .include "zeropage.inc" + .include "telestrat.inc" + +; char key(void); + +.proc _key + BRK_TELEMON XRDW0 ; read keyboard + rts +.endproc + diff --git a/libsrc/telemon30/mainargs.s b/libsrc/telestrat/mainargs.s similarity index 90% rename from libsrc/telemon30/mainargs.s rename to libsrc/telestrat/mainargs.s index 452d0d6d6..b41e2a96d 100644 --- a/libsrc/telemon30/mainargs.s +++ b/libsrc/telestrat/mainargs.s @@ -9,7 +9,7 @@ .constructor initmainargs, 24 .import __argc, __argv .import ptr1 - .include "telemon30.inc" + .include "telestrat.inc" .macpack generic MAXARGS = 10 ; Maximum number of arguments allowed @@ -23,8 +23,6 @@ MAXARGS = 10 ; Maximum number of arguments allowed initmainargs: ldx #0 ; Limit the length - ; lda #0 ; The terminating NUL character - ; beq L1 ; Branch always L0: lda BUFEDT,x beq L3 cmp #' ' @@ -40,9 +38,6 @@ L3: sta name,x inc __argc ; argc always is equal to, at least, 1 - - - ldy #1 * 2 ; Point to second argv slot @@ -52,31 +47,24 @@ next: lda BUFEDT,x cmp #' ' ; Skip leading spaces beq next - - - - found: cmp #'"' ; Is the argument quoted? beq setterm ; Jump if so dex ; Reset pointer to first argument character - - + lda #' ' ; A space ends the argument setterm:sta term ; Set end of argument marker ; Now, store a pointer, to the argument, into the next slot. txa ; Get low byte - clc - adc #<BUFEDT - bcc L4 + clc + adc #<BUFEDT + bcc L4 inc L5+1 -L4: - ;add #<args +L4: sta argv,y ; argv[y]=&arg L5: lda #>BUFEDT - ;adc #>args sta argv+1,y iny iny @@ -106,8 +94,6 @@ argloop:lda BUFEDT,x cmp #MAXARGS ; Maximum number of arguments reached? bcc next ; Parse next one if not - - done: lda #<argv ldx #>argv @@ -116,7 +102,6 @@ done: lda #<argv rts - .segment "INIT" term: .res 1 @@ -127,8 +112,6 @@ term: .res 1 name: .res FNAME_LEN + 1 args: .res SCREEN_XSIZE * 2 - 1 -ptr_current: - .res 2 param_found: .res 1 ; char* argv[MAXARGS+1]={name}; diff --git a/libsrc/telemon30/mym.s b/libsrc/telestrat/mym.s similarity index 99% rename from libsrc/telemon30/mym.s rename to libsrc/telestrat/mym.s index f387f9d64..009ccf53b 100644 --- a/libsrc/telemon30/mym.s +++ b/libsrc/telestrat/mym.s @@ -1,7 +1,7 @@ .export _Mym_MusicStart .importzp sp,tmp2,tmp3,tmp1,ptr1 - .include "telemon30.inc" + .include "telestrat.inc" ; To check: AYC ; http://cpcwiki.eu/index.php/AYC diff --git a/libsrc/telemon30/_open.s b/libsrc/telestrat/open.s similarity index 65% rename from libsrc/telemon30/_open.s rename to libsrc/telestrat/open.s index 7ea2d8310..9455855da 100644 --- a/libsrc/telemon30/_open.s +++ b/libsrc/telestrat/open.s @@ -1,12 +1,13 @@ .export _open - .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 + .import addysp,popax + .importzp sp,tmp2,tmp3,tmp1 - ; int open (const char* name, int flags, ...); /* May take a mode argument */ - .include "telemon30.inc" - .include "errno.inc" - .include "fcntl.inc" - + + .include "telestrat.inc" + .include "errno.inc" + .include "fcntl.inc" + +; int open (const char* name, int flags, ...); /* May take a mode argument */ .proc _open ; Throw away any additional parameters passed through the ellipsis @@ -24,9 +25,9 @@ parmok: jsr popax ; Get flagss ; Get the filename from stack and parse it. Bail out if is not ok jsr popax ; Get name - ldy tmp3 ; Get flags again - BRK_TELEMON XOPEN ; launch primitive ROM - rts + ldy tmp3 ; Get flags again + BRK_TELEMON XOPEN ; launch primitive ROM + rts .endproc \ No newline at end of file diff --git a/libsrc/telemon30/orixhdr.s b/libsrc/telestrat/orixhdr.s similarity index 56% rename from libsrc/telemon30/orixhdr.s rename to libsrc/telestrat/orixhdr.s index 1b0351885..c2a65d9fa 100644 --- a/libsrc/telemon30/orixhdr.s +++ b/libsrc/telestrat/orixhdr.s @@ -1,6 +1,6 @@ ; -; Based on code by Debrune Jérôme <jede@oric.org> -; 2016-03-17, Greg King +; By Debrune Jérôme <jede@oric.org> + ; ; The following symbol is used by the linker config. file @@ -13,23 +13,23 @@ ; ------------------------------------------------------------------------ -; Oric cassette-tape header +; Orix header see http://orix.oric.org/doku.php?id=orix:header for specs .segment "ORIXHDR" .byte $01, $00 ; - .byte "ori" + .byte "ori" - .byte $01 ; version - .byte $00,%00000000 ; 6502 only - .byte $00,$00 ; Extends - .byte $00,$00 ; OS + .byte $01 ; version + .byte $00,%00000000 ; 6502 only + .byte $00,$00 ; Extends + .byte $00,$00 ; OS .byte $00 ; reserved .byte $00 ; auto - .word __BASHEAD_START__ ; Address of start of file - .word __MAIN_LAST__ - 1 ; Address of end of file - .word __BASHEAD_START__ ; Address of start of file + .word __BASHEAD_START__ ; Address of start of file + .word __MAIN_LAST__ - 1 ; Address of end of file + .word __BASHEAD_START__ ; Address of start of file diff --git a/libsrc/telemon24/oserrlist.s b/libsrc/telestrat/oserrlist.s similarity index 100% rename from libsrc/telemon24/oserrlist.s rename to libsrc/telestrat/oserrlist.s diff --git a/libsrc/telemon24/oserror.s b/libsrc/telestrat/oserror.s similarity index 100% rename from libsrc/telemon24/oserror.s rename to libsrc/telestrat/oserror.s diff --git a/libsrc/telestrat/print.s b/libsrc/telestrat/print.s new file mode 100644 index 000000000..9942e3ad9 --- /dev/null +++ b/libsrc/telestrat/print.s @@ -0,0 +1,16 @@ +; jede jede@oric.org 2017-01-22 + +; void print (char * str); + .export _print + .import popax + .importzp tmp1 + .include "telestrat.inc" + +.proc _print + stx tmp1 + ldy tmp1 + BRK_TELEMON XWSTR0 + rts +.endproc + + diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s new file mode 100644 index 000000000..4bccbfc48 --- /dev/null +++ b/libsrc/telestrat/read.s @@ -0,0 +1,43 @@ +; +; jede jede@oric.org 2017-01-22 +; + + + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term + .export _read + + .import popax + + .include "zeropage.inc" + .include "telestrat.inc" + +; int read (int fd, void* buf, unsigned count); + +.proc _read + sta ptr1 ; count + stx ptr1+1 ; count + jsr popax ; get buf + + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + sta ptr2 ; in order to calculate nb of bytes read + stx ptr2+1 ; + + ; jsr popax ; fp pointer don't care in this version + + lda ptr1 ; + ldy ptr1+1 ; + BRK_TELEMON XFREAD ; calls telemon30 routine + ; compute nb of bytes read + lda PTR_READ_DEST+1 + sec + sbc ptr2+1 + tax + lda PTR_READ_DEST + sec + sbc ptr2 + ; Here A and X contains number of bytes read + rts +.endproc + + diff --git a/libsrc/telemon24/_scrsize.s b/libsrc/telestrat/scrsize.s similarity index 85% rename from libsrc/telemon24/_scrsize.s rename to libsrc/telestrat/scrsize.s index 305e41c46..75bd456ce 100644 --- a/libsrc/telemon24/_scrsize.s +++ b/libsrc/telestrat/scrsize.s @@ -6,7 +6,7 @@ ; .export screensize - .include "telemon24.inc" + .include "telestrat.inc" .proc screensize diff --git a/libsrc/telestrat/sound.s b/libsrc/telestrat/sound.s new file mode 100644 index 000000000..3718debd4 --- /dev/null +++ b/libsrc/telestrat/sound.s @@ -0,0 +1,42 @@ +; +; jede jede@oric.org 2017-01-22 + + .export _kbdclick1,_oups,_ping,_explode,_shoot,_zap + .include "telestrat.inc" + +.proc _kbdclick1 + ldx #<sound_bip_keyboard + ldy #>sound_bip_keyboard + BRK_TELEMON XSONPS + rts +sound_bip_keyboard: + .byte $1f,$00,$00,$00,$00,$00,$00,$3e,$10,$00,$00,$1f,$00,$00 +.endproc + +.proc _explode + BRK_TELEMON XEXPLO + rts +.endproc + +.proc _oups + BRK_TELEMON XOUPS + rts +.endproc + +.proc _ping + BRK_TELEMON XPING + rts +.endproc + +.proc _shoot + BRK_TELEMON XSHOOT + rts +.endproc + +.proc _zap + BRK_TELEMON XZAP + rts +.endproc + + + diff --git a/libsrc/telemon24/sysuname.s b/libsrc/telestrat/sysuname.s similarity index 100% rename from libsrc/telemon24/sysuname.s rename to libsrc/telestrat/sysuname.s diff --git a/libsrc/telemon30/write.s b/libsrc/telestrat/write.s similarity index 86% rename from libsrc/telemon30/write.s rename to libsrc/telestrat/write.s index d762eb92c..1c0190531 100644 --- a/libsrc/telemon30/write.s +++ b/libsrc/telestrat/write.s @@ -1,17 +1,13 @@ ; -; Ullrich von Bassewitz, 2003-04-13 -; -; int write (int fd, const void* buf, int count); -; -; This function is a hack! -; +; jede jede@oric.org 2017-01-22 .export _write .import popax .importzp ptr1, ptr2, ptr3, tmp1 - .include "telemon30.inc" + .include "telestrat.inc" +; int write (int fd, const void* buf, int count); .proc _write sta ptr3 @@ -58,8 +54,8 @@ L2: ldy #0 tax cpx #$0A ; Check for \n bne L3 - BRK_TELEMON XWR0 ; Macro - lda #$0d ; return to the beggining of the line + BRK_TELEMON XWR0 ; Macro send char to screen (channel 0 in telemon terms) + lda #$0D ; return to the beggining of the line BRK_TELEMON XWR0 ; Macro ; diff --git a/src/ca65/main.c b/src/ca65/main.c index 1e0c5996f..471afbbe8 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -291,12 +291,8 @@ static void SetSys (const char* Sys) NewSymbol ("__ATMOS__", 1); break; - case TGT_TELEMON24: - NewSymbol ("__TELEMON24__", 1); - break; - - case TGT_TELEMON30: - NewSymbol ("__TELEMON30__", 1); + case TGT_TELESTRAT: + NewSymbol ("__TELESTRAT__", 1); break; case TGT_NES: diff --git a/src/cc65/main.c b/src/cc65/main.c index b0c9261fe..872f66aff 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -243,14 +243,10 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__ATMOS__", 1); break; - case TGT_TELEMON24: - DefineNumericMacro ("__TELEMON24__", 1); + case TGT_TELESTRAT: + DefineNumericMacro ("__TELESTRAT__", 1); break; - case TGT_TELEMON30: - DefineNumericMacro ("__TELEMON30__", 1); - break; - case TGT_NES: DefineNumericMacro ("__NES__", 1); break; diff --git a/src/common/target.c b/src/common/target.c index 67e4ad51b..219afc809 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -171,8 +171,7 @@ static const TargetEntry TargetMap[] = { { "sim6502", TGT_SIM6502 }, { "sim65c02", TGT_SIM65C02 }, { "supervision", TGT_SUPERVISION }, - { "telemon24", TGT_TELEMON24 }, - { "telemon30", TGT_TELEMON30 }, + { "telestrat", TGT_TELESTRAT }, { "vic20", TGT_VIC20 }, }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) @@ -201,8 +200,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, - { "telemon24", CPU_6502, BINFMT_BINARY, CTNone }, - { "telemon30", CPU_6502, BINFMT_BINARY, CTNone }, + { "telestrat", CPU_6502, BINFMT_BINARY, CTNone }, { "nes", CPU_6502, BINFMT_BINARY, CTNone }, { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, { "lynx", CPU_65SC02, BINFMT_BINARY, CTNone }, diff --git a/src/common/target.h b/src/common/target.h index 68c0953fe..7409505bf 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -73,8 +73,7 @@ typedef enum { TGT_GEOS_APPLE, TGT_LUNIX, TGT_ATMOS, - TGT_TELEMON24, - TGT_TELEMON30, + TGT_TELESTRAT, TGT_NES, TGT_SUPERVISION, TGT_LYNX, From 6f58b9a22d255429aaba8c45972c09d39f2256c2 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Tue, 31 Jan 2017 22:20:19 +0100 Subject: [PATCH 200/407] Correcting comments alignment Correcting an address error in telestrat.inc when cleaning files which broke read.s primitive --- asminc/telestrat.inc | 14 +++++++------- libsrc/telestrat/read.s | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index fedda1946..24a1aa538 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -27,7 +27,7 @@ RESB := $02 TR0 := $0C TR1 := $0D -PTR_READ_DEST := $2D ; used for XFREAD and XWRITE only in telemon 3.0 +PTR_READ_DEST := $2C ; used for XFREAD and XWRITE only in telemon 3.0 HRSX := $46 HRSY := $47 @@ -108,12 +108,12 @@ XWSTR0 = $14 XTEXT = $19 XHIRES = $1A XMINMA = $1F -XFREAD = $27 ; only in TELEMON 3.0 -XOPEN = $30 ; only in TELEMON 3.0 -XCOSCR = $34 ; switch off cursor -XCSSCR = $35 ; switch on cursor -XCLOSE = $3A ; only in TELEMON 3.0 Close file -XFWRITE = $3B ; only in TELEMON 3.0 write file +XFREAD = $27 ; only in TELEMON 3.0 +XOPEN = $30 ; only in TELEMON 3.0 +XCOSCR = $34 ; switch off cursor +XCSSCR = $35 ; switch on cursor +XCLOSE = $3A ; only in TELEMON 3.0 Close file +XFWRITE = $3B ; only in TELEMON 3.0 write file XSONPS = $40 XOUPS = $42 XPLAY = $43 diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s index 4bccbfc48..85a6132eb 100644 --- a/libsrc/telestrat/read.s +++ b/libsrc/telestrat/read.s @@ -3,13 +3,13 @@ ; - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term - .export _read - - .import popax - - .include "zeropage.inc" - .include "telestrat.inc" + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term + .export _read + + .import popax + + .include "zeropage.inc" + .include "telestrat.inc" ; int read (int fd, void* buf, unsigned count); From 37185b20dd354d22fc6591c204830d780b657610 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Tue, 31 Jan 2017 22:21:53 +0100 Subject: [PATCH 201/407] correcting README.md to add telestrat target --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b62ac761d..26ca98cef 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ including - the Nintendo Entertainment System (NES) console. - the Watara Supervision console. - the Oric Atmos. +- the Oric telestrat. - the Lynx console. - the Ohio Scientific Challenger 1P. From d9778994fab808b829cc15dd612fd48a18271c0f Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Tue, 31 Jan 2017 22:33:19 +0100 Subject: [PATCH 202/407] Correcting some spaces --- libsrc/telestrat/ch376.s | 48 ++++++++++++++++++------------------- libsrc/telestrat/close.s | 4 ++-- libsrc/telestrat/graphics.s | 2 +- libsrc/telestrat/mainargs.s | 6 ++--- libsrc/telestrat/open.s | 35 +++++++++++++-------------- 5 files changed, 47 insertions(+), 48 deletions(-) diff --git a/libsrc/telestrat/ch376.s b/libsrc/telestrat/ch376.s index fbfa16017..49aefad92 100644 --- a/libsrc/telestrat/ch376.s +++ b/libsrc/telestrat/ch376.s @@ -29,49 +29,49 @@ CH376_USB_INT_SUCCESS = $14 CH376_USB_INT_CONNECT = $15 CH376_USB_INT_DISCONNECT = $16 CH376_USB_INT_BUF_OVER = $17 -CH376_USB_INT_USB_READY = $18 -CH376_USB_INT_DISK_READ = $1D +CH376_USB_INT_USB_READY = $18 +CH376_USB_INT_DISK_READ = $1D CH376_USB_INT_DISK_WRITE = $1E CH376_USB_INT_DISK_ERR = $1F -CH376_ERR_OPEN_DIR = $41 -CH376_ERR_MISS_FILE = $42 +CH376_ERR_OPEN_DIR = $41 +CH376_ERR_MISS_FILE = $42 CH376_ERR_FOUND_NAME = $43 CH376_ERR_DISK_DISCON = $82 CH376_ERR_LARGE_SECTOR = $84 CH376_ERR_TYPE_ERROR = $92 -CH376_ERR_BPB_ERROR = $A1 -CH376_ERR_DISK_FULL = $B1 -CH376_ERR_FDT_OVER = $B2 +CH376_ERR_BPB_ERROR = $A1 +CH376_ERR_DISK_FULL = $B1 +CH376_ERR_FDT_OVER = $B2 CH376_ERR_FILE_CLOSE = $B4 -CH376_GET_IC_VER = $01 -CH376_SET_BAUDRATE = $02 +CH376_GET_IC_VER = $01 +CH376_SET_BAUDRATE = $02 CH376_GET_ENTER_SLEEP = $03 -CH376_RESET_ALL = $05 -CH376_CHECK_EXIST = $06 +CH376_RESET_ALL = $05 +CH376_CHECK_EXIST = $06 CH376_GET_FILE_SIZE = $0C CH376_SET_USB_MODE = $15 CH376_GET_STATUS = $22 CH376_RD_USB_DATA0 = $27 -CH376_CMD_WR_REQ_DATA = $2D -CH376_SET_FILE_NAME = $2F +CH376_CMD_WR_REQ_DATA = $2D +CH376_SET_FILE_NAME = $2F CH376_DISK_CONNECT = $30 ; check the disk connection status -CH376_DISK_MOUNT = $31 -CH376_FILE_OPEN = $32 -CH376_FILE_ENUM_GO = $33 -CH376_FILE_CREATE = $34 +CH376_DISK_MOUNT = $31 +CH376_FILE_OPEN = $32 +CH376_FILE_ENUM_GO = $33 +CH376_FILE_CREATE = $34 CH376_FILE_CLOSE = $36 -CH376_BYTE_LOCATE = $39 -CH376_BYTE_READ = $3A -CH376_BYTE_RD_GO = $3B -CH376_BYTE_WRITE = $3C -CH376_BYTE_WR_GO = $3D -CH376_DISK_CAPACITY = $3E -CH376_DISK_RD_GO = $55 +CH376_BYTE_LOCATE = $39 +CH376_BYTE_READ = $3A +CH376_BYTE_RD_GO = $3B +CH376_BYTE_WRITE = $3C +CH376_BYTE_WR_GO = $3D +CH376_DISK_CAPACITY = $3E +CH376_DISK_RD_GO = $55 .proc _ch376_file_close lda #CH376_FILE_CLOSE diff --git a/libsrc/telestrat/close.s b/libsrc/telestrat/close.s index 881d0897f..240ebb063 100644 --- a/libsrc/telestrat/close.s +++ b/libsrc/telestrat/close.s @@ -2,9 +2,9 @@ .export _close - .import addysp,popax + .import addysp,popax - .include "zeropage.inc" + .include "zeropage.inc" .include "telestrat.inc" .include "errno.inc" .include "fcntl.inc" diff --git a/libsrc/telestrat/graphics.s b/libsrc/telestrat/graphics.s index 9984036bb..e0b002d3c 100644 --- a/libsrc/telestrat/graphics.s +++ b/libsrc/telestrat/graphics.s @@ -4,7 +4,7 @@ .include "zeropage.inc" .include "telestrat.inc" - .import popa + .import popa .proc _paper diff --git a/libsrc/telestrat/mainargs.s b/libsrc/telestrat/mainargs.s index b41e2a96d..fa388cbfa 100644 --- a/libsrc/telestrat/mainargs.s +++ b/libsrc/telestrat/mainargs.s @@ -24,8 +24,8 @@ initmainargs: ldx #0 ; Limit the length L0: lda BUFEDT,x - beq L3 - cmp #' ' + beq L3 + cmp #' ' bne L1 lda #0 beq L3 @@ -35,7 +35,7 @@ L1: sta name,x bne L0 lda #0 L3: - sta name,x + sta name,x inc __argc ; argc always is equal to, at least, 1 diff --git a/libsrc/telestrat/open.s b/libsrc/telestrat/open.s index 9455855da..b3b390003 100644 --- a/libsrc/telestrat/open.s +++ b/libsrc/telestrat/open.s @@ -1,33 +1,32 @@ - .export _open - .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 + .export _open + .import addysp,popax + .importzp sp,tmp2,tmp3,tmp1 - .include "telestrat.inc" - .include "errno.inc" - .include "fcntl.inc" + .include "telestrat.inc" + .include "errno.inc" + .include "fcntl.inc" ; int open (const char* name, int flags, ...); /* May take a mode argument */ .proc _open ; Throw away any additional parameters passed through the ellipsis - dey ; Parm count < 4 shouldn't be needed to be... - dey ; ...checked (it generates a c compiler warning) - dey - dey - beq parmok ; Branch if parameter count ok - jsr addysp ; Fix stack, throw away unused parameters + dey ; Parm count < 4 shouldn't be needed to be... + dey ; ...checked (it generates a c compiler warning) + dey + dey + beq parmok ; Branch if parameter count ok + jsr addysp ; Fix stack, throw away unused parameters ; Parameters ok. Pop the flags and save them into tmp3 parmok: jsr popax ; Get flagss - sta tmp3 ; save flags + sta tmp3 ; save flags ; Get the filename from stack and parse it. Bail out if is not ok - - jsr popax ; Get name - ldy tmp3 ; Get flags again - BRK_TELEMON XOPEN ; launch primitive ROM - rts + jsr popax ; Get name + ldy tmp3 ; Get flags again + BRK_TELEMON XOPEN ; launch primitive ROM + rts .endproc \ No newline at end of file From 034c668b15567c3c90034b878aaeb1fbb1d864dd Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 1 Feb 2017 17:52:30 +0100 Subject: [PATCH 203/407] pce/memcpy.s: remove superfluous comma in comment --- libsrc/pce/memcpy.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/pce/memcpy.s b/libsrc/pce/memcpy.s index 40f831e30..14977dee0 100644 --- a/libsrc/pce/memcpy.s +++ b/libsrc/pce/memcpy.s @@ -97,7 +97,7 @@ memcpy_getparams: ; ---------------------------------------------------------------------- ; The transfer instructions use inline arguments. -; Therefore, we must build the instruction, in the DATA segment. +; Therefore, we must build the instruction in the DATA segment. .data From a08f90522459634aace3f5db9f81045bce204d38 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 1 Feb 2017 19:46:04 +0100 Subject: [PATCH 204/407] Cleanups for Creativision. --- cfg/creativision.cfg | 1 + libsrc/creativision/_scrsize.s | 10 +-- libsrc/creativision/boxchars.inc | 112 +++++++++++++++---------------- libsrc/creativision/cclear.s | 43 ++++++------ libsrc/creativision/cgetc.s | 25 +++---- libsrc/creativision/chline.s | 2 +- libsrc/creativision/clrscr.s | 66 +++++++++--------- libsrc/creativision/color.s | 14 ++-- libsrc/creativision/cputc.s | 54 +++++++-------- libsrc/creativision/gotox.s | 2 +- libsrc/creativision/gotoxy.s | 6 +- libsrc/creativision/joy.s | 28 ++++---- libsrc/creativision/libref.s | 4 +- libsrc/creativision/mainargs.s | 2 - libsrc/creativision/psg.s | 91 ++++++++++++------------- libsrc/creativision/sysuname.s | 3 - libsrc/creativision/wherex.s | 3 - libsrc/creativision/wherey.s | 3 - src/ca65/main.c | 28 ++++---- src/cc65/main.c | 28 ++++---- src/common/target.c | 70 ++++++++++--------- src/common/target.h | 10 +-- 22 files changed, 291 insertions(+), 314 deletions(-) diff --git a/cfg/creativision.cfg b/cfg/creativision.cfg index 9122ccd42..06e39b36f 100644 --- a/cfg/creativision.cfg +++ b/cfg/creativision.cfg @@ -12,6 +12,7 @@ SEGMENTS { VECTORS: load = ROM, run = RAM, type = rw, define = yes; DATA: load = ROM, run = RAM, type = rw, define = yes, start = $0204; BSS: load = RAM, type = bss, define = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro; INIT: load = ROM, type = ro; RODATA: load = ROM, type = ro; diff --git a/libsrc/creativision/_scrsize.s b/libsrc/creativision/_scrsize.s index fdcc7fc60..9e4ce53c7 100644 --- a/libsrc/creativision/_scrsize.s +++ b/libsrc/creativision/_scrsize.s @@ -2,14 +2,14 @@ ;** _scrsize.s ;* - .export screensize + .export screensize - .include "creativision.inc" + .include "creativision.inc" .proc screensize - ldx #SCREEN_COLS - ldy #SCREEN_ROWS - rts + ldx #SCREEN_COLS + ldy #SCREEN_ROWS + rts .endproc diff --git a/libsrc/creativision/boxchars.inc b/libsrc/creativision/boxchars.inc index 0916d49ce..45484a5d2 100644 --- a/libsrc/creativision/boxchars.inc +++ b/libsrc/creativision/boxchars.inc @@ -1,62 +1,62 @@ ; Boxchars boxchars: - ; Vertical Line - .byte $18 - .byte $18 - .byte $18 - .byte $18 - .byte $18 - .byte $18 - .byte $18 - .byte $18 + ; Vertical Line + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 - ; Horizontal Line - .byte 0 - .byte 0 - .byte 0 - .byte $ff - .byte 0 - .byte 0 - .byte 0 - .byte 0 - - ; Top Left - .byte 0 - .byte 0 - .byte 0 - .byte $1f - .byte $18 - .byte $18 - .byte $18 - .byte $18 - - ; Top Right - .byte 0 - .byte 0 - .byte 0 - .byte $F8 - .byte $18 - .byte $18 - .byte $18 - .byte $18 + ; Horizontal Line + .byte $00 + .byte $00 + .byte $00 + .byte $FF + .byte $00 + .byte $00 + .byte $00 + .byte $00 - ; Bottom Left - .byte $18 - .byte $18 - .byte $18 - .byte $1F - .byte 0 - .byte 0 - .byte 0 - .byte 0 + ; Top Left + .byte $00 + .byte $00 + .byte $00 + .byte $1F + .byte $18 + .byte $18 + .byte $18 + .byte $18 - ; Bottom Right - .byte $18 - .byte $18 - .byte $18 - .byte $F8 - .byte 0 - .byte 0 - .byte 0 - .byte 0 + ; Top Right + .byte $00 + .byte $00 + .byte $00 + .byte $F8 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + + ; Bottom Left + .byte $18 + .byte $18 + .byte $18 + .byte $1F + .byte $00 + .byte $00 + .byte $00 + .byte $00 + + ; Bottom Right + .byte $18 + .byte $18 + .byte $18 + .byte $F8 + .byte $00 + .byte $00 + .byte $00 + .byte $00 diff --git a/libsrc/creativision/cclear.s b/libsrc/creativision/cclear.s index 507c072bd..953ec8ce8 100644 --- a/libsrc/creativision/cclear.s +++ b/libsrc/creativision/cclear.s @@ -3,27 +3,24 @@ ;* void cclear (unsigned char length); ;* - .export _cclearxy, _cclear - .import popa, _gotoxy, cputdirect - .importzp tmp1 - -_cclearxy: - pha ; Save length - jsr popa ; get Y - jsr _gotoxy - pla - -_cclear: - cmp #0 ; Zero length? - beq L2 - sta tmp1 - -L1: - lda #$20 ; Space - jsr cputdirect - dec tmp1 - bne L1 - -L2: rts + .export _cclearxy, _cclear + .import popa, _gotoxy, cputdirect + .importzp tmp1 - +_cclearxy: + pha ; Save length + jsr popa ; get Y + jsr _gotoxy + pla + +_cclear: + cmp #0 ; Zero length? + beq L2 + sta tmp1 + +L1: lda #$20 ; Space + jsr cputdirect + dec tmp1 + bne L1 + +L2: rts diff --git a/libsrc/creativision/cgetc.s b/libsrc/creativision/cgetc.s index f1e89942a..12831b4b9 100644 --- a/libsrc/creativision/cgetc.s +++ b/libsrc/creativision/cgetc.s @@ -1,17 +1,14 @@ ;* cgetc - .export _cgetc - .include "creativision.inc" - + .export _cgetc + .include "creativision.inc" + _cgetc: - lda #$80 - -L1: - bit ZP_KEYBOARD - bpl L1 - - lda ZP_KEYBOARD - and #$7f - rts - - + lda #$80 + +L1: bit ZP_KEYBOARD + bpl L1 + + lda ZP_KEYBOARD + and #$7F + rts diff --git a/libsrc/creativision/chline.s b/libsrc/creativision/chline.s index c206180e0..bef36e1fe 100644 --- a/libsrc/creativision/chline.s +++ b/libsrc/creativision/chline.s @@ -6,7 +6,7 @@ .importzp tmp1 .include "creativision.inc" - + _chlinexy: pha ; Save the length jsr popa ; Get y diff --git a/libsrc/creativision/clrscr.s b/libsrc/creativision/clrscr.s index ef800a9bd..9e7238345 100644 --- a/libsrc/creativision/clrscr.s +++ b/libsrc/creativision/clrscr.s @@ -4,38 +4,38 @@ ;* NB: All screen functions assume Graphics Mode 1 in a default configuration. ;* Therefore, this is hard coded to use $1000-$12FF as screen VRAM. - .export _clrscr - .include "creativision.inc" - + .export _clrscr + .include "creativision.inc" + _clrscr: - sei ; Disable interrupts. Default INT handler reads VDP_STATUS - ; and would lose any setup done here. - - lda #$00 ; VRAM offset low - sta VDP_CONTROL_W - - lda #$50 ; VRAM offset high ($10 OR $40) - sta VDP_CONTROL_W - - lda #$C0 ; Space from ROM setup - - ldx #0 - ldy #3 - -L1: sta VDP_DATA_W - inx - bne L1 - dey - bne L1 - - cli ; Let interrupts go again - - lda #0 - sta CURSOR_X - sta CURSOR_Y - sta <SCREEN_PTR - lda #$10 - sta >SCREEN_PTR - - rts + sei ; Disable interrupts. Default INT handler reads VDP_STATUS + ; and would lose any setup done here. + + lda #$00 ; VRAM offset low + sta VDP_CONTROL_W + + lda #$50 ; VRAM offset high ($10 OR $40) + sta VDP_CONTROL_W + + lda #$C0 ; Space from ROM setup + + ldx #0 + ldy #3 + +L1: sta VDP_DATA_W + inx + bne L1 + dey + bne L1 + + cli ; Let interrupts go again + + lda #0 + sta CURSOR_X + sta CURSOR_Y + sta <SCREEN_PTR + lda #$10 + sta >SCREEN_PTR + + rts diff --git a/libsrc/creativision/color.s b/libsrc/creativision/color.s index b6fd360b4..8e86719d2 100644 --- a/libsrc/creativision/color.s +++ b/libsrc/creativision/color.s @@ -4,10 +4,10 @@ ;* unsigned char __fastcall__ bordercolor (unsigned char color); ;* - .export _textcolor, _bgcolor, _bordercolor - .import return0 - .include "creativision.inc" - -_bordercolor = return0; -_textcolor = return0; -_bgcolor = return0; + .export _textcolor, _bgcolor, _bordercolor + .import return0 + .include "creativision.inc" + +_bordercolor = return0; +_textcolor = return0; +_bgcolor = return0; diff --git a/libsrc/creativision/cputc.s b/libsrc/creativision/cputc.s index 902caf277..208009ebd 100644 --- a/libsrc/creativision/cputc.s +++ b/libsrc/creativision/cputc.s @@ -29,13 +29,13 @@ _cputcxy: ; Plot a character - also used as internal function -_cputc: cmp #$0d ; CR? +_cputc: cmp #$0D ; CR? bne L1 lda #0 sta CURSOR_X beq plot ; Recalculate pointers -L1: cmp #$0a ; LF? +L1: cmp #$0A ; LF? beq newline ; Recalculate pointers ; Printable char of some sort @@ -82,19 +82,19 @@ IS_UPPER: pha lda SCREEN_PTR sei - sta VDP_CONTROL_W + sta VDP_CONTROL_W lda SCREEN_PTR+1 - ora #$40 - sta VDP_CONTROL_W + ora #$40 + sta VDP_CONTROL_W pla clc - adc #160 - sta VDP_DATA_W + adc #160 + sta VDP_DATA_W cli BAD_CHAR: jmp plot - + ;----------------------------------------------------------------------------- ; Initialize the conio subsystem. Code goes into the INIT segment, which may ; be reused after startup. @@ -102,24 +102,24 @@ BAD_CHAR: .segment "INIT" initconio: - lda #$0 - sta SCREEN_PTR - lda #$10 - sta SCREEN_PTR+1 + lda #$0 + sta SCREEN_PTR + lda #$10 + sta SCREEN_PTR+1 - ; Copy box characters to slot - sei - lda #08 - sta VDP_CONTROL_W - lda #$46 - sta VDP_CONTROL_W - ldx #0 -LL: - lda boxchars,x - sta VDP_DATA_W - inx - cpx #48 - bne LL + ; Copy box characters to slot + sei + lda #08 + sta VDP_CONTROL_W + lda #$46 + sta VDP_CONTROL_W + ldx #0 - cli - jmp plot +LL: lda boxchars,x + sta VDP_DATA_W + inx + cpx #48 + bne LL + + cli + jmp plot diff --git a/libsrc/creativision/gotox.s b/libsrc/creativision/gotox.s index 6970e5d24..f65e923b5 100644 --- a/libsrc/creativision/gotox.s +++ b/libsrc/creativision/gotox.s @@ -11,7 +11,7 @@ .proc _gotox - sta CURSOR_X ; Set new position + sta CURSOR_X ; Set new position tay ldx CURSOR_Y jmp setcursor ; Set the cursor to the new position diff --git a/libsrc/creativision/gotoxy.s b/libsrc/creativision/gotoxy.s index 6c0cf932f..12ce0abea 100644 --- a/libsrc/creativision/gotoxy.s +++ b/libsrc/creativision/gotoxy.s @@ -12,9 +12,9 @@ .proc _gotoxy - sta CURSOR_Y ; Set Y - jsr popa ; Get X - sta CURSOR_X ; Set X + sta CURSOR_Y ; Set Y + jsr popa ; Get X + sta CURSOR_X ; Set X tay ldx CURSOR_Y jmp setcursor ; Set the cursor position diff --git a/libsrc/creativision/joy.s b/libsrc/creativision/joy.s index f1c9b09f7..eb0bc6594 100644 --- a/libsrc/creativision/joy.s +++ b/libsrc/creativision/joy.s @@ -1,6 +1,6 @@ ;* ;* Creativision Joystick Function -;* +;* ;* unsigned char __fastcall__ joystate(unsigned char joy); ;* ;* JOY_1 -> Return Left Joystick direction @@ -12,47 +12,47 @@ .export _joystate .include "creativision.inc" - + _joystate: cmp #1 ; Left Direction bne l1 - + lda $11 beq l5 - and #$f + and #$0F lsr a tax inx txa rts - + l1: cmp #2 ; Right Direction bne l2 - + lda $13 beq l5 - and #$f + and #$0F lsr a tax inx txa rts - + l2: cmp #3 ; Left Buttons bne l3 - + lda $16 beq l5 - and #$f + and #$0F rts - + l3: cmp #4 bne l4 - + lda $17 beq l5 - and #$f + and #$0F rts - + l4: lda #0 l5: rts diff --git a/libsrc/creativision/libref.s b/libsrc/creativision/libref.s index d947c1aa4..b642da80a 100644 --- a/libsrc/creativision/libref.s +++ b/libsrc/creativision/libref.s @@ -5,5 +5,5 @@ .export joy_libref, tgi_libref .import _exit -joy_libref := _exit -tgi_libref := _exit +joy_libref := _exit +tgi_libref := _exit diff --git a/libsrc/creativision/mainargs.s b/libsrc/creativision/mainargs.s index 7ed8d46f4..cda76d8d0 100644 --- a/libsrc/creativision/mainargs.s +++ b/libsrc/creativision/mainargs.s @@ -20,5 +20,3 @@ rts .endproc - - diff --git a/libsrc/creativision/psg.s b/libsrc/creativision/psg.s index 12b474339..a32e87f02 100644 --- a/libsrc/creativision/psg.s +++ b/libsrc/creativision/psg.s @@ -3,40 +3,37 @@ ; void __fastcall__ bios_playsound( void *b, unsigned char c); ; void psg_silence( void ); - .export _psg_outb, _psg_silence, _psg_delay - .export _bios_playsound - .import popa - .include "creativision.inc" - + .export _psg_outb, _psg_silence, _psg_delay + .export _bios_playsound + .import popa + .include "creativision.inc" + _psg_outb: - ;* Let BIOS output the value - jmp $FE77 - + ;* Let BIOS output the value + jmp $FE77 + _psg_silence: - jmp $FE54 - - + jmp $FE54 + + _psg_delay: - tay -l1: - lda #200 -l2: - sbc #1 - bne l2 - - lda #200 -l3: - sbc #1 - bne l3 - - dey - bne l1 - - rts - + tay +l1: lda #200 +l2: sbc #1 + bne l2 + + lda #200 +l3: sbc #1 + bne l3 + + dey + bne l1 + + rts + ;* Creativision Sound Player ;* @@ -46,23 +43,21 @@ l3: _bios_playsound: - pha ; Save Length Byte - - sei - - lda #$D5 ; BIOS volume table low - sta $4 - lda #$FC ; BIOS volume table high - sta $5 - - jsr popa ; Get Sound table pointer low - sta $0 - jsr popa ; Get Sound table pointer high - sta $1 - - pla - tay ; Put length in Y - dey - php - jmp $fbed ; Let BIOS do it's thing - + pha ; Save Length Byte + sei + + lda #$D5 ; BIOS volume table low + sta $4 + lda #$FC ; BIOS volume table high + sta $5 + + jsr popa ; Get Sound table pointer low + sta $0 + jsr popa ; Get Sound table pointer high + sta $1 + + pla + tay ; Put length in Y + dey + php + jmp $FBED ; Let BIOS do it's thing diff --git a/libsrc/creativision/sysuname.s b/libsrc/creativision/sysuname.s index df1a81b67..725cb2a62 100644 --- a/libsrc/creativision/sysuname.s +++ b/libsrc/creativision/sysuname.s @@ -34,6 +34,3 @@ utsdata: ; machine .asciiz "CREATIVISION" - - - diff --git a/libsrc/creativision/wherex.s b/libsrc/creativision/wherex.s index f9df2d1a1..a2e6fdfc5 100644 --- a/libsrc/creativision/wherex.s +++ b/libsrc/creativision/wherex.s @@ -5,7 +5,6 @@ ; .export _wherex - .include "creativision.inc" .proc _wherex @@ -15,5 +14,3 @@ rts .endproc - - diff --git a/libsrc/creativision/wherey.s b/libsrc/creativision/wherey.s index 6d7b056f5..fa50177c4 100644 --- a/libsrc/creativision/wherey.s +++ b/libsrc/creativision/wherey.s @@ -5,7 +5,6 @@ ; .export _wherey - .include "creativision.inc" .proc _wherey @@ -15,5 +14,3 @@ rts .endproc - - diff --git a/src/ca65/main.c b/src/ca65/main.c index 1da0ff36d..a83cab5b6 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -259,6 +259,10 @@ static void SetSys (const char* Sys) CBMSystem ("__PET__"); break; + case TGT_BBC: + NewSymbol ("__BBC__", 1); + break; + case TGT_APPLE2: NewSymbol ("__APPLE2__", 1); break; @@ -278,14 +282,6 @@ static void SetSys (const char* Sys) NewSymbol ("__GEOS_CBM__", 1); break; - case TGT_ATMOS: - NewSymbol ("__ATMOS__", 1); - break; - - case TGT_BBC: - NewSymbol ("__BBC__", 1); - break; - case TGT_CREATIVISION: NewSymbol ("__CREATIVISION__", 1); break; @@ -299,14 +295,22 @@ static void SetSys (const char* Sys) NewSymbol ("__LUNIX__", 1); break; - case TGT_LYNX: - NewSymbol ("__LYNX__", 1); + case TGT_ATMOS: + NewSymbol ("__ATMOS__", 1); break; case TGT_NES: NewSymbol ("__NES__", 1); break; + case TGT_SUPERVISION: + NewSymbol ("__SUPERVISION__", 1); + break; + + case TGT_LYNX: + NewSymbol ("__LYNX__", 1); + break; + case TGT_SIM6502: NewSymbol ("__SIM6502__", 1); break; @@ -323,10 +327,6 @@ static void SetSys (const char* Sys) NewSymbol ("__PCE__", 1); break; - case TGT_SUPERVISION: - NewSymbol ("__SUPERVISION__", 1); - break; - default: AbEnd ("Invalid target name: `%s'", Sys); diff --git a/src/cc65/main.c b/src/cc65/main.c index c273d8160..780c52b57 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -211,6 +211,10 @@ static void SetSys (const char* Sys) cbmsys ("__PET__"); break; + case TGT_BBC: + DefineNumericMacro ("__BBC__", 1); + break; + case TGT_APPLE2: DefineNumericMacro ("__APPLE2__", 1); break; @@ -230,14 +234,6 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__GEOS_CBM__", 1); break; - case TGT_ATMOS: - DefineNumericMacro ("__ATMOS__", 1); - break; - - case TGT_BBC: - DefineNumericMacro ("__BBC__", 1); - break; - case TGT_CREATIVISION: DefineNumericMacro ("__CREATIVISION__", 1); break; @@ -251,14 +247,22 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__LUNIX__", 1); break; - case TGT_LYNX: - DefineNumericMacro ("__LYNX__", 1); + case TGT_ATMOS: + DefineNumericMacro ("__ATMOS__", 1); break; case TGT_NES: DefineNumericMacro ("__NES__", 1); break; + case TGT_SUPERVISION: + DefineNumericMacro ("__SUPERVISION__", 1); + break; + + case TGT_LYNX: + DefineNumericMacro ("__LYNX__", 1); + break; + case TGT_SIM6502: DefineNumericMacro ("__SIM6502__", 1); break; @@ -275,10 +279,6 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__PCE__", 1); break; - case TGT_SUPERVISION: - DefineNumericMacro ("__SUPERVISION__", 1); - break; - default: AbEnd ("Unknown target system type %d", Target); } diff --git a/src/common/target.c b/src/common/target.c index bf87b17e0..84559b0e7 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -142,38 +142,38 @@ struct TargetEntry { ** Allows multiple entries for one target id (target name aliases). */ static const TargetEntry TargetMap[] = { - { "apple2", TGT_APPLE2 }, - { "apple2enh", TGT_APPLE2ENH }, - { "atari", TGT_ATARI }, - { "atari2600", TGT_ATARI2600 }, - { "atari5200", TGT_ATARI5200 }, - { "atarixl", TGT_ATARIXL }, - { "atmos", TGT_ATMOS }, - { "bbc", TGT_BBC }, - { "c128", TGT_C128 }, - { "c16", TGT_C16 }, - { "c64", TGT_C64 }, - { "c65", TGT_C65 }, - { "cbm510", TGT_CBM510 }, - { "cbm610", TGT_CBM610 }, - { "creativision", TGT_CREATIVISION}, - { "gamate", TGT_GAMATE }, - { "geos", TGT_GEOS_CBM }, - { "geos-apple", TGT_GEOS_APPLE }, - { "geos-cbm", TGT_GEOS_CBM }, - { "lunix", TGT_LUNIX }, - { "lynx", TGT_LYNX }, - { "module", TGT_MODULE }, - { "nes", TGT_NES }, - { "none", TGT_NONE }, - { "osic1p", TGT_OSIC1P }, - { "pce", TGT_PCENGINE }, - { "pet", TGT_PET }, - { "plus4", TGT_PLUS4 }, - { "sim6502", TGT_SIM6502 }, - { "sim65c02", TGT_SIM65C02 }, - { "supervision", TGT_SUPERVISION }, - { "vic20", TGT_VIC20 }, + { "apple2", TGT_APPLE2 }, + { "apple2enh", TGT_APPLE2ENH }, + { "atari", TGT_ATARI }, + { "atari2600", TGT_ATARI2600 }, + { "atari5200", TGT_ATARI5200 }, + { "atarixl", TGT_ATARIXL }, + { "atmos", TGT_ATMOS }, + { "bbc", TGT_BBC }, + { "c128", TGT_C128 }, + { "c16", TGT_C16 }, + { "c64", TGT_C64 }, + { "c65", TGT_C65 }, + { "cbm510", TGT_CBM510 }, + { "cbm610", TGT_CBM610 }, + { "creativision", TGT_CREATIVISION }, + { "gamate", TGT_GAMATE }, + { "geos", TGT_GEOS_CBM }, + { "geos-apple", TGT_GEOS_APPLE }, + { "geos-cbm", TGT_GEOS_CBM }, + { "lunix", TGT_LUNIX }, + { "lynx", TGT_LYNX }, + { "module", TGT_MODULE }, + { "nes", TGT_NES }, + { "none", TGT_NONE }, + { "osic1p", TGT_OSIC1P }, + { "pce", TGT_PCENGINE }, + { "pet", TGT_PET }, + { "plus4", TGT_PLUS4 }, + { "sim6502", TGT_SIM6502 }, + { "sim65c02", TGT_SIM65C02 }, + { "supervision", TGT_SUPERVISION }, + { "vic20", TGT_VIC20 }, }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) @@ -195,13 +195,12 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "cbm610", CPU_6502, BINFMT_BINARY, CTPET }, { "osic1p", CPU_6502, BINFMT_BINARY, CTOSI }, { "pet", CPU_6502, BINFMT_BINARY, CTPET }, + { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2enh", CPU_65C02, BINFMT_BINARY, CTNone }, - { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, - { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, + { "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone }, { "creativision", CPU_6502, BINFMT_BINARY, CTNone }, { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, - { "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone }, { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, { "nes", CPU_6502, BINFMT_BINARY, CTNone }, @@ -211,7 +210,6 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, - { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, { "c65", CPU_4510, BINFMT_BINARY, CTPET }, }; diff --git a/src/common/target.h b/src/common/target.h index 1e54784b1..054c4f2ba 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -67,21 +67,21 @@ typedef enum { TGT_CBM610, TGT_OSIC1P, TGT_PET, + TGT_BBC, TGT_APPLE2, TGT_APPLE2ENH, - TGT_ATMOS, - TGT_BBC, + TGT_GEOS_CBM, TGT_CREATIVISION, TGT_GEOS_APPLE, - TGT_GEOS_CBM, TGT_LUNIX, - TGT_LYNX, + TGT_ATMOS, TGT_NES, + TGT_SUPERVISION, + TGT_LYNX, TGT_SIM6502, TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, - TGT_SUPERVISION, TGT_C65, TGT_COUNT /* Number of target systems */ } target_t; From 0e649f24eae9812bd1cfa3f9955caecb8ceb7b9e Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Wed, 1 Feb 2017 23:58:33 +0100 Subject: [PATCH 205/407] Correcting some code from github comments --- README.md | 2 +- asminc/telestrat.inc | 9 +- cfg/telestrat.cfg | 3 - doc/telestrat.sgml | 57 ++-- include/telestrat.h | 4 +- libsrc/telestrat/ch376.s | 344 ------------------- libsrc/telestrat/graphics.s | 58 ---- libsrc/telestrat/keyboard.s | 14 - libsrc/telestrat/mym.s | 626 ----------------------------------- libsrc/telestrat/orixhdr.s | 26 +- libsrc/telestrat/oserrlist.s | 75 ----- libsrc/telestrat/oserror.s | 17 - libsrc/telestrat/print.s | 16 - 13 files changed, 51 insertions(+), 1200 deletions(-) delete mode 100644 libsrc/telestrat/ch376.s delete mode 100644 libsrc/telestrat/graphics.s delete mode 100644 libsrc/telestrat/keyboard.s delete mode 100644 libsrc/telestrat/mym.s delete mode 100644 libsrc/telestrat/oserrlist.s delete mode 100644 libsrc/telestrat/oserror.s delete mode 100644 libsrc/telestrat/print.s diff --git a/README.md b/README.md index 26ca98cef..16e92e878 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ including - the Nintendo Entertainment System (NES) console. - the Watara Supervision console. - the Oric Atmos. -- the Oric telestrat. +- the Oric Telestrat. - the Lynx console. - the Ohio Scientific Challenger 1P. diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index 24a1aa538..2c3502ba8 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -24,8 +24,8 @@ FNAME_LEN = 11 ; maximum length of file-name RES := $00 RESB := $02 -TR0 := $0C -TR1 := $0D +TR0 := $0C +TR1 := $0D PTR_READ_DEST := $2C ; used for XFREAD and XWRITE only in telemon 3.0 @@ -123,10 +123,11 @@ XZAP = $46 XSHOOT = $47 XCIRCL = $8F XCURSE = $90 -XEXPLO = $9C -XPING = $9D XPAPER = $92 XINK = $93 +XEXPLO = $9C +XPING = $9D + ; --------------------------------------------------------------------------- ; Page $500 diff --git a/cfg/telestrat.cfg b/cfg/telestrat.cfg index b9f0b4026..395a936e1 100644 --- a/cfg/telestrat.cfg +++ b/cfg/telestrat.cfg @@ -1,9 +1,6 @@ SYMBOLS { - __ORIXHDR__: type = import; - __STACKSIZE__: type = weak, value = $0800; # 2K stack - __RAMEND__: type = weak, value = $9800; } MEMORY { diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index ce9e044b4..b981fbfaf 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -10,7 +10,7 @@ <abstract> An overview over the Telestrat (telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C -compiler. +compiler.) </abstract> <!-- Table of contents --> @@ -21,21 +21,35 @@ compiler. <sect>Overview<p> This file contains an overview of the Telestrat runtime system as it comes with the -cc65 C compiler. It describes the memory layout, Telemon3.0-specific header files, +cc65 C compiler. It describes the memory layout, Telestrat-specific header files, available drivers, and any pitfalls specific to that platform. -Please note that Telemon3.0-specific functions are just mentioned here, they are +Please note that Telestrat-specific functions are just mentioned here, they are described in detail in the separate <url url="funcref.html" name="function reference">. Even functions marked as "platform dependent" may be available on more than one platform. Please see the function reference for more information. - - <sect>Binary format<p> -The standard binary output format generated by the linker for the Telemon 3.0 target -is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header +The standard binary output format generated the linker for the Telestrat target +is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header + +This header is used for Telemon 3.0. + +Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in telemon, there is no way to load a binary easiy. + +Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. + +There is no tool to insert a binary in a Stratsed floppy disk. + +The only way to load a binary (for Telemon 2.4) is to : +<itemize> +<item>remove the 20 bytes header +<item>download osdk : http://osdk.defence-force.org/index?page=download +<item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when telestrat starts) +</itemize> + @@ -64,12 +78,12 @@ Special locations: <sect>Platform-specific header files<p> -Programs containing Telemon 3.0 -specific code may use the <tt/telemon.h/ header file. +Programs containing Telestrat -specific code may use the <tt/telestrat.h/ header file. -<sect1>Telemon 3.0-specific functions<p> +<sect1>Telestrat-specific functions<p> -The functions listed below are special for the Telemon 3.0. See the <url +The functions listed below are special for the Telestrat. See the <url url="funcref.html" name="function reference"> for declaration and usage. <itemize> @@ -77,13 +91,13 @@ url="funcref.html" name="function reference"> for declaration and usage. <item>ping <item>shoot <item>zap -<item>oupsx +<item>oups </itemize> <sect1>Hardware access<p> -The following pseudo variables declared in the <tt/atmos.h/ header file do allow +The following pseudo variables declared in the <tt/telestrat.h/ header file do allow access to hardware located in the address space. Some variables are structures; accessing the struct fields will access the chip registers. @@ -99,30 +113,23 @@ structures; accessing the struct fields will access the chip registers. <sect>Loadable drivers<p> -<em>Note:</em> Since the Atmos doesn't have working disk I/O -(see <ref id="limitations" name="section "Limitations"">), the -available drivers cannot be loaded at runtime (so the term "loadable drivers" -is somewhat misleading). Instead, the drivers have to be statically linked. While -this may seem overhead, it has two advantages: - - <sect1>Extended memory drivers<p> -No extended memory drivers are currently available for the Atmos. +No extended memory drivers are currently available for the Telestrat. <sect1>Joystick drivers<p> <descrip> -telemon 3.0 manages joysticks but it had been handled yet. +telemon 2.4 & 3.0 manages joysticks but it had been handled yet. </descrip><p> <sect1>Mouse drivers<p> -Telemon 3.0 manages also mouse, but it had been no handled yet in this version. +Telestrat manages also mouse, but it had been no handled yet in this version. <sect1>RS232 device drivers<p> @@ -132,14 +139,12 @@ not done </descrip><p> - - <sect>Limitations<label id="limitations"><p> <sect1>Disk I/O<p> -This version handles fopen, fread, fclose primitives. Because Telemon 3.0 handles these two primitives. By the way, -it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. +This version handles fopen, fread, fclose primitives. Because Telemon 3.0 handles these three primitives. By the way, +it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives. <itemize> <item>fclose diff --git a/include/telestrat.h b/include/telestrat.h index 73b018444..85da8df60 100644 --- a/include/telestrat.h +++ b/include/telestrat.h @@ -1,5 +1,5 @@ -void print (char *); + void hires(); void text(); @@ -14,8 +14,6 @@ void ink(char color); void kbdclick1(); -void curset(char x,char y, char display, char display); -void circle(char rayon); diff --git a/libsrc/telestrat/ch376.s b/libsrc/telestrat/ch376.s deleted file mode 100644 index 49aefad92..000000000 --- a/libsrc/telestrat/ch376.s +++ /dev/null @@ -1,344 +0,0 @@ - -; jede jede@oric.org 2017-01-22 - - ; For XA65 compatibily in the future - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term - .export _ch376_set_file_name - .export _ch376_file_open - .export _ch376_ic_get_version - .export _ch376_reset - .export _ch376_check_exist - .export _ch376_disk_mount - .export _ch376_set_usb_mode - .export _ch376_file_close - .export _ch376_seek_file - .export _ch376_file_create - .export _ch376_fwrite - - .import popax - .include "zeropage.inc" - .include "telestrat.inc" - - - - - -CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY = $06 - -CH376_USB_INT_SUCCESS = $14 -CH376_USB_INT_CONNECT = $15 -CH376_USB_INT_DISCONNECT = $16 -CH376_USB_INT_BUF_OVER = $17 -CH376_USB_INT_USB_READY = $18 -CH376_USB_INT_DISK_READ = $1D -CH376_USB_INT_DISK_WRITE = $1E -CH376_USB_INT_DISK_ERR = $1F - - -CH376_ERR_OPEN_DIR = $41 -CH376_ERR_MISS_FILE = $42 -CH376_ERR_FOUND_NAME = $43 -CH376_ERR_DISK_DISCON = $82 -CH376_ERR_LARGE_SECTOR = $84 -CH376_ERR_TYPE_ERROR = $92 -CH376_ERR_BPB_ERROR = $A1 -CH376_ERR_DISK_FULL = $B1 -CH376_ERR_FDT_OVER = $B2 -CH376_ERR_FILE_CLOSE = $B4 - -CH376_GET_IC_VER = $01 -CH376_SET_BAUDRATE = $02 -CH376_GET_ENTER_SLEEP = $03 -CH376_RESET_ALL = $05 -CH376_CHECK_EXIST = $06 -CH376_GET_FILE_SIZE = $0C - -CH376_SET_USB_MODE = $15 -CH376_GET_STATUS = $22 -CH376_RD_USB_DATA0 = $27 -CH376_CMD_WR_REQ_DATA = $2D -CH376_SET_FILE_NAME = $2F - -CH376_DISK_CONNECT = $30 ; check the disk connection status -CH376_DISK_MOUNT = $31 -CH376_FILE_OPEN = $32 -CH376_FILE_ENUM_GO = $33 -CH376_FILE_CREATE = $34 -CH376_FILE_CLOSE = $36 -CH376_BYTE_LOCATE = $39 -CH376_BYTE_READ = $3A -CH376_BYTE_RD_GO = $3B -CH376_BYTE_WRITE = $3C -CH376_BYTE_WR_GO = $3D -CH376_DISK_CAPACITY = $3E -CH376_DISK_RD_GO = $55 - -.proc _ch376_file_close - lda #CH376_FILE_CLOSE - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_seek_file - ldx #CH376_BYTE_LOCATE - stx CH376_COMMAND - sta CH376_DATA - sty CH376_DATA - lda #$00 ; Don't manage 32 bits length - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -; void ch376_set_file_name(char *filename) -.proc _ch376_set_file_name - sta ptr1 - stx ptr1+1 - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - ldy #0 -loop: - lda (ptr1),y ; replace by bufnom - beq end ; we reached 0 value - BRK_TELEMON XMINMA - sta CH376_DATA - iny - cpy #13 ; because we don't manage longfilename shortname =11 - bne loop -end: - sta CH376_DATA - rts -.endproc - -; char _ch376_file_open(); -.proc _ch376_file_open - lda #CH376_FILE_OPEN ; $32 - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_get_file_size - lda #CH376_GET_FILE_SIZE - sta CH376_COMMAND - lda #$68 - sta CH376_DATA - ; store file length 32 bits - lda CH376_DATA - sta tmp1 - lda CH376_DATA - sta tmp1+1 - lda CH376_DATA - sta tmp2 - lda CH376_DATA - sta tmp2+1 - rts -.endproc - -; void ch376_reset(); -.proc _ch376_reset - lda #CH376_RESET_ALL ; 5 - sta CH376_COMMAND - ; waiting - ldy #0 - ldx #0 -loop: - nop - inx - bne loop - iny - bne loop - rts -.endproc - -; char ch376_check_exist(char value); - -.proc _ch376_check_exist - sta tmp1 - lda #CH376_CHECK_EXIST ; - sta CH376_COMMAND - lda tmp1 - sta CH376_DATA - lda CH376_DATA - rts -.endproc - -; char ch376_ic_get_version(void) -.proc _ch376_ic_get_version - lda #CH376_GET_IC_VER - sta CH376_COMMAND - ldx #0 - lda CH376_DATA - rts -.endproc - -; void ch376_set_usb_mode(char mode) -.proc _ch376_set_usb_mode - ldx #CH376_SET_USB_MODE ; $15 - stx CH376_COMMAND - sta CH376_DATA - rts -.endproc - -; void ch376_set_bytes_write(int value); -.proc _ch376_set_bytes_write - ldy #CH376_BYTE_WRITE - sty CH376_COMMAND - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_set_bytes_read - ldy #CH376_BYTE_READ - sty CH376_COMMAND - ; Storing 32 bits value - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -; char ch376_disk_mount(); -.proc _ch376_disk_mount - lda #CH376_DISK_MOUNT ; $31 - sta CH376_COMMAND - jsr _ch376_wait_response - ; if we read data value, we have then length of the volume name - ldx #0 - rts -.endproc - - -; char ch376_wait_response(); -.proc _ch376_wait_response -; return 1 if usb controller does not respond -; else A contains answer of the controller - ldy #$FF ; We have to wait 35 ms, but well, this loop is broken when controler is OK -loop3: - ldx #$FF ; don't decrease this counter. Because ch376 won't respond if there is a lower value -loop: - lda CH376_COMMAND - and #%10000000 - cmp #128 - bne no_error - dex - bne loop - dey - bne loop3 - ; error is here - rts -no_error: - lda #CH376_GET_STATUS - sta CH376_COMMAND - lda CH376_DATA - rts -.endproc - -.proc _ch376_fread - ; use ptr1 to count bytes - jsr _ch376_set_bytes_read -continue: - cmp #CH376_USB_INT_DISK_READ ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished - ; TODO in A : $ff X: $ff - lda #0 - tax - rts -we_read: - lda #CH376_RD_USB_DATA0 - sta CH376_COMMAND - - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read - - ldy #0 -loop: - lda CH376_DATA ; read the data - sta (PTR_READ_DEST),y - iny - cpy tmp2 - bne loop - tya - clc - adc PTR_READ_DEST - bcc next - inc PTR_READ_DEST+1 -next: - sta PTR_READ_DEST - - lda #CH376_BYTE_RD_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue -finished: - ; TODO return bytes read - lda tmp1 - ldx tmp1+1 - rts -.endproc - -; void _ch376_fwrite(void *ptr,int number) -.proc _ch376_fwrite - ; use ptr1 to count bytes - sta ptr2 - stx ptr2+1 - - jsr popax - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - - lda ptr2 - ldx ptr2+1 - jsr _ch376_set_bytes_write -continue: - cmp #CH376_USB_INT_DISK_WRITE ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished - - lda #0 - tax - rts -we_read: - lda #CH376_CMD_WR_REQ_DATA - sta CH376_COMMAND - - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read - - ldy #0 -loop: - lda (PTR_READ_DEST),y - sta CH376_DATA ; read the data - dec tmp2 - bne loop - - - lda #CH376_BYTE_WR_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue -finished: - lda tmp1 - ldx tmp1+1 - rts -.endproc - -.proc _ch376_file_create - lda #CH376_FILE_CREATE - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc diff --git a/libsrc/telestrat/graphics.s b/libsrc/telestrat/graphics.s deleted file mode 100644 index e0b002d3c..000000000 --- a/libsrc/telestrat/graphics.s +++ /dev/null @@ -1,58 +0,0 @@ -; jede jede@oric.org 2017-01-22 - - .export _paper,_hires,_text,_circle,_curset, _switchOffCursor - - .include "zeropage.inc" - .include "telestrat.inc" - .import popa - - -.proc _paper - ldx #0 ; First window - ; A contains the paper - BRK_TELEMON XPAPER - rts -.endproc - -; XINK is bugged, it corrupt memory : removing from export -.proc _ink - ldx #0 ; First window - ; A contains the ink - BRK_TELEMON XINK - rts -.endproc - -; can be optimized with a macro -.proc _hires - BRK_TELEMON XHIRES - rts -.endproc - -.proc _text - BRK_TELEMON XTEXT - rts -.endproc - -.proc _curset - jsr popa ; Pixel - jsr popa - sta HRSX - jsr popa - sta HRSY - BRK_TELEMON XCURSE - rts -.endproc - -.proc _circle - sta HRS1 - BRK_TELEMON XCIRCL - rts -.endproc - -.proc _switchOffCursor - ldx #0 - BRK_TELEMON XCOSCR - rts -.endproc - - diff --git a/libsrc/telestrat/keyboard.s b/libsrc/telestrat/keyboard.s deleted file mode 100644 index 7069d1003..000000000 --- a/libsrc/telestrat/keyboard.s +++ /dev/null @@ -1,14 +0,0 @@ -; jede jede@oric.org 2017-01-22 - - .export _key - - .include "zeropage.inc" - .include "telestrat.inc" - -; char key(void); - -.proc _key - BRK_TELEMON XRDW0 ; read keyboard - rts -.endproc - diff --git a/libsrc/telestrat/mym.s b/libsrc/telestrat/mym.s deleted file mode 100644 index 009ccf53b..000000000 --- a/libsrc/telestrat/mym.s +++ /dev/null @@ -1,626 +0,0 @@ - .export _Mym_MusicStart - .importzp sp,tmp2,tmp3,tmp1,ptr1 - - .include "telestrat.inc" - -; To check: AYC -; http://cpcwiki.eu/index.php/AYC - - - - -_DecodedByte :=$D0 ; Byte being currently decoded from the MYM stream -_DecodeBitCounter :=$D2 ; Number of bits we can read in the current byte -_DecodedResult :=$D3 ; What is returned by the 'read bits' function -_CurrentAYRegister :=$D4 ; Contains the number of the register being decoded -_RegisterBufferHigh :=$D5 ; Points to the high byte of the decoded register buffer, increment to move to the next register -_BufferFrameOffset :=$D6 ; From 0 to 127, used when filling the decoded register buffer -_MusicResetCounter :=$D7 ; 2 bytes Contains the number of rows to play before reseting -_CurrentFrame :=$D9 ; From 0 to 255 and then cycles... the index of the frame to play this vbl -_PlayerVbl :=$DA -_FrameLoadBalancer :=$DB ; We depack a new frame every 9 VBLs, this way the 14 registers are evenly depacked over 128 frames - - -VIA_1 := $30f -VIA_2 := $30c - -_MusicData := $c000 - -; mym(char *buf) - - - - -; -; Current PSG values during unpacking -; - - -.proc _Mym_MusicStart - - ; The two first bytes of the MYM music is the number of rows in the music - ; We decrement that at each frame, and when we reach zero, time to start again. - sta ptr1 - stx ptr1+1 - - ldy #0 - lda (ptr1),y - sta _MusicResetCounter+0 - iny - lda (ptr1),y - tax - inx - stx _MusicResetCounter+1 - - ;ldx _MusicData+0 - ;stx _MusicResetCounter+0 - ;ldx _MusicData+1 - ;inx - ;stx _MusicResetCounter+1 - - - ; Initialize the read bit counter - ldy #2 ; should be useless because we can do iny which earn 1 byte - - lda ptr1 - clc - adc #2 - bcc next20 - inc ptr1+1 - lda ptr1+1 - sta __auto_music_ptr+2 -next20: - sta ptr1 - sta __auto_music_ptr+1 - - - - ;lda #<(_MusicData+2) - ;sta __auto_music_ptr+1 - ;lda #>(_MusicData+2) - ;sta __auto_music_ptr+2 - - lda #1 - sta _DecodeBitCounter - - ; Clear all data - lda #0 - sta _DecodedResult - sta _DecodedByte - sta _PlayerVbl - sta _PlayerRegCurrentValue - sta _BufferFrameOffset - sta _PlayerCount - sta _CurrentAYRegister - sta _CurrentFrame - - ldx #14 -loop_init: - dex - sta _PlayerRegValues,x - bne loop_init - - - ; - ; Unpack the 128 first register frames - ; - - lda #>_PlayerBuffer - sta _RegisterBufferHigh - - ldx #0 -unpack_block_loop: - stx _CurrentAYRegister - - ; Unpack that register - jsr _PlayerUnpackRegister2 - - ; Next register - ldx _CurrentAYRegister - inx - cpx #14 - bne unpack_block_loop - - - lda #128 - sta _PlayerVbl+0 - - lda #0 - sta _PlayerCount - sta _CurrentAYRegister - sta _CurrentFrame - - lda #9 - sta _FrameLoadBalancer - - lda #1 - sta _MusicPlaying - - ; - ; Install the IRQ - ; - php - sei - lda #<_Mym_PlayFrame - sta _InterruptCallBack_3+1 - lda #>_Mym_PlayFrame - sta _InterruptCallBack_3+2 - plp - - rts - - -_Mym_MusicStop: - - ; Indicate the main code that the music is finished - lda #0 - sta _MusicPlaying - - ; Disable the IRQ so it does not conflict or cause weird things - php - sei - lda #<_DoNothing - sta _InterruptCallBack_3+1 - lda #>_DoNothing - sta _InterruptCallBack_3+2 - plp - - ; Cut the sound so it does not sounds like a dying cat - - ; y=register number - ; x=value to write - ldy #7 ; Control register - ldx #$FF - jsr _PsgPlayRegister - - ldy #8 ; Volume A - ldx #0 - jsr _PsgPlayRegister - - ldy #9 ; Volume B - ldx #0 - jsr _PsgPlayRegister - - ldy #10 ; Volume C - ldx #0 - jsr _PsgPlayRegister - rts - - -_Mym_PlayFrame: - - ; - ; Check for end of music - ; CountZero: $81,$0d - dec _MusicResetCounter+0 - bne music_contines - dec _MusicResetCounter+1 - bne music_contines - -music_resets: - jmp _Mym_MusicStop - -music_contines: - - ; - ; Play a frame of 14 registers - ; - - lda _CurrentFrame - sta _auto_psg_play_read+1 - lda #>_PlayerBuffer - sta _auto_psg_play_read+2 - - ldy #0 -register_loop: - -_auto_psg_play_read: - ldx _PlayerBuffer - - ; y=register number - ; x=value to write - jsr _PsgPlayRegister - - inc _auto_psg_play_read+2 - iny - cpy #14 - bne register_loop - - - - inc _CurrentFrame - inc _PlayerCount - - lda _CurrentAYRegister - cmp #14 - bcs end_reg - - - dec _FrameLoadBalancer - bne end - - jsr _PlayerUnpackRegister - inc _CurrentAYRegister - lda #9 - sta _FrameLoadBalancer -end: - rts - - -end_reg: - - lda _PlayerCount - cmp #128 - bcc skip2 - - lda #0 - sta _CurrentAYRegister - sta _PlayerCount - lda #9 - sta _FrameLoadBalancer - - clc - lda _PlayerVbl+0 - adc #128 - sta _PlayerVbl+0 -skip2: - - - rts - - - -; y=register number -; x=value to write -_PsgPlayRegister: - - sty VIA_1 - txa - - pha - lda VIA_2 - ora #$EE ; $EE 238 11101110 - sta VIA_2 - - and #$11 ; $11 17 00010001 - ora #$CC ; $CC 204 11001100 - sta VIA_2 - - tax - pla - sta VIA_1 - txa - ora #$EC ; $EC 236 11101100 - sta VIA_2 - - and #$11 ; $11 17 00010001 - ora #$CC ; $CC 204 11001100 - sta VIA_2 - - rts - - - - -; -; Initialise X with the number of bits to read -; Y is not modifier -; -_ReadBits: - - lda #0 - sta _DecodedResult - - ; Will iterate X times (number of bits to read) -loop_read_bits: - - dec _DecodeBitCounter - beq get_next_byte - -shift_bit: - asl _DecodedByte - rol _DecodedResult - - dex - bne loop_read_bits - rts - -get_next_byte: - ; reset mask - lda #8 - sta _DecodeBitCounter - - ; fetch a new byte, and increment the adress. -__auto_music_ptr: - lda _MusicData+2 - sta _DecodedByte - - inc __auto_music_ptr+1 - bne shift_bit - inc __auto_music_ptr+2 - jmp shift_bit - - - - - -_PlayerUnpackRegister: - lda #>_PlayerBuffer - clc - adc _CurrentAYRegister - sta _RegisterBufferHigh -_PlayerUnpackRegister2: - ; - ; Init register bit count and current value - ; - ldx _CurrentAYRegister - lda _PlayerRegValues,x - sta _PlayerRegCurrentValue - - - ; - ; Check if it's packed or not - ; and call adequate routine... - ; - ldx #1 - jsr _ReadBits - ldx _DecodedResult - bne DecompressFragment - - -UnchangedFragment: - - ; - ; No change at all, just repeat '_PlayerRegCurrentValue' 128 times - ; - lda _RegisterBufferHigh ; highpart of buffer adress + register number - sta __auto_copy_unchanged_write+2 - - ldx #128 ; 128 iterations - lda _PlayerRegCurrentValue ; Value to write - - ldy _PlayerVbl - -repeat_loop: -__auto_copy_unchanged_write: - sta _PlayerBuffer,y - iny - dex - bne repeat_loop - - - jmp player_main_return - - -player_main_return: - ; Write back register current value - ldx _CurrentAYRegister - lda _PlayerRegCurrentValue - sta _PlayerRegValues,x - - ; Move to the next register buffer - inc _RegisterBufferHigh - rts - - - - -DecompressFragment: - lda _PlayerVbl ; Either 0 or 128 at this point else we have a problem... - sta _BufferFrameOffset - -decompressFragmentLoop: - -player_copy_packed_loop: - ; Check packing method - ldx #1 - jsr _ReadBits - - ldx _DecodedResult - bne PlayerNotCopyLast - -UnchangedRegister: - - ; We just copy the current value 128 times - lda _RegisterBufferHigh ; highpart of buffer adress + register number - sta __auto_player_copy_last+2 - - ldx _BufferFrameOffset ; Value between 00 and 7f - lda _PlayerRegCurrentValue ; Value to copy -__auto_player_copy_last: - sta _PlayerBuffer,x - - inc _BufferFrameOffset - - - -player_return: - - ; Check end of loop - lda _BufferFrameOffset - and #127 - bne decompressFragmentLoop - - jmp player_main_return - - -PlayerNotCopyLast: - ; Check packing method - ldx #1 - jsr _ReadBits - - ldx _DecodedResult - beq DecompressWithOffset - -ReadNewRegisterValue: - ; Read new register value (variable bit count) - ldx _CurrentAYRegister - lda _PlayerRegBits,x - tax - jsr _ReadBits - ldx _DecodedResult - stx _PlayerRegCurrentValue - - ; Copy to stream - lda _RegisterBufferHigh ; highpart of buffer adress + register number - sta __auto_player_read_new+2 - - ldx _BufferFrameOffset ; Value between 00 and 7f - lda _PlayerRegCurrentValue ; New value to write -__auto_player_read_new: - sta _PlayerBuffer,x - - inc _BufferFrameOffset - jmp player_return - - - - -DecompressWithOffset: - - ; Read Offset (0 to 127) - ldx #7 - jsr _ReadBits - - lda _RegisterBufferHigh ; highpart of buffer adress + register number - sta __auto_write+2 ; Write adress - sta __auto_read+2 ; Read adress - - ; Compute wrap around offset... - lda _BufferFrameOffset ; between 0 and 255 - clc - adc _DecodedResult ; + Offset Between 00 and 7f - sec - sbc #128 ; -128 - tay - - ; Read count (7 bits) - ldx #7 - jsr _ReadBits - - inc _DecodedResult ; 1 to 129 - - - ldx _BufferFrameOffset - -player_copy_offset_loop: - -__auto_read: - lda _PlayerBuffer,y ; Y for reading - iny - -__auto_write: - sta _PlayerBuffer,x ; X for writing - - inx - dec _DecodedResult - bne player_copy_offset_loop - - stx _BufferFrameOffset - sta _PlayerRegCurrentValue - - jmp player_return - - - - -; -; Size in bits of each PSG register -; -_PlayerRegBits: - ; Chanel A Frequency - .byt 8 - .byt 4 - - ; Chanel B Frequency - .byt 8 - .byt 4 - - ; Chanel C Frequency - .byt 8 - .byt 4 - - ; Chanel sound generator - .byt 5 - - ; select - .byt 8 - - ; Volume A,B,C - .byt 5 - .byt 5 - .byt 5 - - ; Wave period - .byt 8 - .byt 8 - - ; Wave form - .byt 8 - -_PlayerCount: - .res 1,0 ; must be equal to 0 -_MusicPlaying: - .res 1,0 ; must be equal to 0 - - -_PlayerRegValues: -_RegisterChanAFrequency: - ; Chanel A Frequency - .res 1,8 - .res 1,4 - -_RegisterChanBFrequency: - ; Chanel B Frequency - .res 1,8 - .res 1,4 - -_RegisterChanCFrequency: - ; Chanel C Frequency - .res 1,8 - .res 1,4 - -_RegisterChanNoiseFrequency: - ; Chanel sound generator - .res 1,5 - - ; select - .res 1,8 - - ; Volume A,B,C -_RegisterChanAVolume: - .res 1,5 -_RegisterChanBVolume: - .res 1,5 -_RegisterChanCVolume: - .res 1,5 - - ; Wave period - .res 1,8 - .res 1,8 - - ; Wave form - .res 1,8 - -_PlayerRegCurrentValue: - .res 1,0 -_DoNothing: - rts - -_InterruptCallBack_3: ; Used by the music player - jsr _DoNothing ; Transformed to "jsr _Mym_PlayFrame" -> 12 cycles - -; jsr MiniScrollLoading ; -> 338 cycles - - pla - tay - pla - tax - pla - - rti -_PlayerBuffer: - .res 256*14 ; About 3.5 kilobytes somewhere in memory, we put the music file in overlay memory - -.endproc - diff --git a/libsrc/telestrat/orixhdr.s b/libsrc/telestrat/orixhdr.s index c2a65d9fa..6fe2fca73 100644 --- a/libsrc/telestrat/orixhdr.s +++ b/libsrc/telestrat/orixhdr.s @@ -3,13 +3,13 @@ ; - ; The following symbol is used by the linker config. file - ; to force this module to be included into the output file. - .export __ORIXHDR__:abs = 1 + ; The following symbol is used by the linker config. file + ; to force this module to be included into the output file. + .export __ORIXHDR__:abs = 1 - ; These symbols, also, come from the configuration file. - .import __AUTORUN__, __PROGFLAG__ - .import __BASHEAD_START__, __MAIN_LAST__ + ; These symbols, also, come from the configuration file. + .import __AUTORUN__, __PROGFLAG__ + .import __BASHEAD_START__, __MAIN_LAST__ ; ------------------------------------------------------------------------ @@ -17,17 +17,17 @@ .segment "ORIXHDR" - .byte $01, $00 ; + .byte $01, $00 ; non C64 marker (same as o65 format) - .byte "ori" + .byte "ori" ; magic number - .byte $01 ; version - .byte $00,%00000000 ; 6502 only - .byte $00,$00 ; Extends - .byte $00,$00 ; OS + .byte $01 ; version of the header + .byte $00,%00000000 ; 6502 only + .byte $00,$00 ; type of language + .byte $00,$00 ; OS version .byte $00 ; reserved - .byte $00 ; auto + .byte $00 ; auto or not .word __BASHEAD_START__ ; Address of start of file .word __MAIN_LAST__ - 1 ; Address of end of file diff --git a/libsrc/telestrat/oserrlist.s b/libsrc/telestrat/oserrlist.s deleted file mode 100644 index 8ec41de6d..000000000 --- a/libsrc/telestrat/oserrlist.s +++ /dev/null @@ -1,75 +0,0 @@ -; -; Stefan Haubenthal, 2004-05-25 -; Ullrich von Bassewitz, 18.07.2002 -; -; Defines the platform specific error list. -; -; The table is built as a list of entries -; -; .byte entrylen -; .byte errorcode -; .asciiz errormsg -; -; and terminated by an entry with length zero that is returned if the -; error code could not be found. -; - - .export __sys_oserrlist - -;---------------------------------------------------------------------------- -; Macros used to generate the list (may get moved to an include file?) - -; Regular entry -.macro sys_oserr_entry code, msg - .local Start, End -Start: .byte End - Start - .byte code - .asciiz msg -End: -.endmacro - -; Sentinel entry -.macro sys_oserr_sentinel msg - .byte 0 ; Length is always zero - .byte 0 ; Code is unused - .asciiz msg -.endmacro - -;---------------------------------------------------------------------------- -; The error message table - -.rodata - -__sys_oserrlist: - sys_oserr_entry 1, "File not found" - sys_oserr_entry 2, "Invalid command end" - sys_oserr_entry 3, "No drive number" - sys_oserr_entry 4, "Bad drive number" - sys_oserr_entry 5, "Invalid filename" - sys_oserr_entry 6, "fderr=(error number)" - sys_oserr_entry 7, "Illegal attribute" - sys_oserr_entry 8, "Wildcard(s) not allowed" - sys_oserr_entry 9, "File already exists" - sys_oserr_entry 10, "Insufficient disc space" - sys_oserr_entry 11, "File open" - sys_oserr_entry 12, "Illegal quantity" - sys_oserr_entry 13, "End address missing" - sys_oserr_entry 14, "Start address > end address" - sys_oserr_entry 15, "Missing 'to'" - sys_oserr_entry 16, "Renamed file not on same disc" - sys_oserr_entry 17, "Unknown array" - sys_oserr_entry 18, "Target drive not source drive" - sys_oserr_entry 19, "Destination not specified" - sys_oserr_entry 20, "Cannot merge and overwrite" - sys_oserr_entry 21, "Single target file illegal" - sys_oserr_entry 22, "Syntax" - sys_oserr_entry 23, "Filename missing" - sys_oserr_entry 24, "Source file missing" - sys_oserr_entry 25, "Type mismatch" - sys_oserr_entry 26, "Disc write-protected" - sys_oserr_entry 27, "Incompatible drives" - sys_oserr_entry 28, "File not open" - sys_oserr_entry 29, "File end" - sys_oserr_sentinel "Unknown error" - - diff --git a/libsrc/telestrat/oserror.s b/libsrc/telestrat/oserror.s deleted file mode 100644 index 37c9bd7fc..000000000 --- a/libsrc/telestrat/oserror.s +++ /dev/null @@ -1,17 +0,0 @@ -; -; Stefan Haubenthal, 2011-04-18 -; -; int __fastcall__ _osmaperrno (unsigned char oserror); -; /* Map a system specific error into a system independent code */ -; - - .include "errno.inc" - .export __osmaperrno - -.proc __osmaperrno - - lda #<EUNKNOWN - ldx #>EUNKNOWN - rts - -.endproc diff --git a/libsrc/telestrat/print.s b/libsrc/telestrat/print.s deleted file mode 100644 index 9942e3ad9..000000000 --- a/libsrc/telestrat/print.s +++ /dev/null @@ -1,16 +0,0 @@ -; jede jede@oric.org 2017-01-22 - -; void print (char * str); - .export _print - .import popax - .importzp tmp1 - .include "telestrat.inc" - -.proc _print - stx tmp1 - ldy tmp1 - BRK_TELEMON XWSTR0 - rts -.endproc - - From bbff709d9f74c783831cad0ffacc79f65772a2f8 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 00:00:21 +0100 Subject: [PATCH 206/407] Correcting return line --- doc/telestrat.sgml | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index b981fbfaf..d31457fad 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -150,7 +150,6 @@ it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In th <item>fclose <item>fopen <item>fread - </itemize> From 4b77072fed541a3635ed2b6ec7d3b5f521c5500a Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 00:05:50 +0100 Subject: [PATCH 207/407] Correcting alignment --- libsrc/telestrat/close.s | 2 +- libsrc/telestrat/mainargs.s | 12 ++++++------ libsrc/telestrat/write.s | 36 +++++++++++++++++------------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/libsrc/telestrat/close.s b/libsrc/telestrat/close.s index 240ebb063..04d8788d1 100644 --- a/libsrc/telestrat/close.s +++ b/libsrc/telestrat/close.s @@ -6,7 +6,7 @@ .include "zeropage.inc" .include "telestrat.inc" - .include "errno.inc" + .include "errno.inc" .include "fcntl.inc" ; int open (const char* name, int flags, ...); /* May take a mode argument */ diff --git a/libsrc/telestrat/mainargs.s b/libsrc/telestrat/mainargs.s index fa388cbfa..41c3a5131 100644 --- a/libsrc/telestrat/mainargs.s +++ b/libsrc/telestrat/mainargs.s @@ -26,14 +26,14 @@ initmainargs: L0: lda BUFEDT,x beq L3 cmp #' ' - bne L1 - lda #0 - beq L3 + bne L1 + lda #0 + beq L3 L1: sta name,x inx - cpx #FNAME_LEN + cpx #FNAME_LEN bne L0 - lda #0 + lda #0 L3: sta name,x inc __argc ; argc always is equal to, at least, 1 @@ -57,7 +57,7 @@ setterm:sta term ; Set end of argument marker ; Now, store a pointer, to the argument, into the next slot. txa ; Get low byte - clc + clc adc #<BUFEDT bcc L4 inc L5+1 diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 1c0190531..278c28c83 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -24,25 +24,23 @@ stx ptr1+1 jsr popax ; get fd and discard - ; if fd=0001 then it stdout - - - cpx #0 - beq next - jmp L1 + ; if fd=0001 then it stdout + cpx #0 + beq next + jmp L1 next: - cmp #1 - beq L1 + cmp #1 + beq L1 - ; Here it's a file opened - lda ptr1 - sta PTR_READ_DEST - lda ptr1+1 - sta PTR_READ_DEST+1 - lda ptr3 - ldy ptr3+1 - BRK_TELEMON XFWRITE - rts + ; Here it's a file opened + lda ptr1 + sta PTR_READ_DEST + lda ptr1+1 + sta PTR_READ_DEST+1 + lda ptr3 + ldy ptr3+1 + BRK_TELEMON XFWRITE + rts L1: inc ptr2 @@ -54,9 +52,9 @@ L2: ldy #0 tax cpx #$0A ; Check for \n bne L3 - BRK_TELEMON XWR0 ; Macro send char to screen (channel 0 in telemon terms) + BRK_TELEMON XWR0 ; Macro send char to screen (channel 0 in telemon terms) lda #$0D ; return to the beggining of the line - BRK_TELEMON XWR0 ; Macro ; + BRK_TELEMON XWR0 ; Macro ; ldx #$0D From 5abb40b229a3bc6a52ef70dbf1b50cd44f81c418 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 00:11:11 +0100 Subject: [PATCH 208/407] Last push for tonight :) --- libsrc/telestrat/open.s | 23 +++++++++++++---------- libsrc/telestrat/read.s | 4 +--- libsrc/telestrat/write.s | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/libsrc/telestrat/open.s b/libsrc/telestrat/open.s index b3b390003..8e94de311 100644 --- a/libsrc/telestrat/open.s +++ b/libsrc/telestrat/open.s @@ -1,6 +1,8 @@ - .export _open - .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 + .export _open + + .import addysp,popax + + .importzp sp,tmp2,tmp3,tmp1 .include "telestrat.inc" @@ -15,17 +17,18 @@ dey ; ...checked (it generates a c compiler warning) dey dey - beq parmok ; Branch if parameter count ok - jsr addysp ; Fix stack, throw away unused parameters + beq parmok ; Branch if parameter count ok + jsr addysp ; Fix stack, throw away unused parameters ; Parameters ok. Pop the flags and save them into tmp3 -parmok: jsr popax ; Get flagss - sta tmp3 ; save flags +parmok: + jsr popax ; Get flagss + sta tmp3 ; save flags ; Get the filename from stack and parse it. Bail out if is not ok - jsr popax ; Get name - ldy tmp3 ; Get flags again - BRK_TELEMON XOPEN ; launch primitive ROM + jsr popax ; Get name + ldy tmp3 ; Get flags again + BRK_TELEMON XOPEN ; launch primitive ROM rts .endproc diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s index 85a6132eb..75766cda2 100644 --- a/libsrc/telestrat/read.s +++ b/libsrc/telestrat/read.s @@ -2,8 +2,6 @@ ; jede jede@oric.org 2017-01-22 ; - - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term .export _read .import popax @@ -11,7 +9,7 @@ .include "zeropage.inc" .include "telestrat.inc" -; int read (int fd, void* buf, unsigned count); +;int read (int fd, void* buf, unsigned count); .proc _read sta ptr1 ; count diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 278c28c83..1d269887d 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -59,7 +59,7 @@ L2: ldy #0 ldx #$0D L3: - BRK_TELEMON XWR0 ; Macro + BRK_TELEMON XWR0 ; Macro inc ptr1 bne L1 From ad6e54c2d8c470f44d1a5ee3fe45e2ce2ba9bd0d Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 22:44:06 +0100 Subject: [PATCH 209/407] Updating doc --- doc/telestrat.sgml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index d31457fad..c04e14f54 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -9,7 +9,7 @@ <date>2017-01-22 <abstract> -An overview over the Telestrat (telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C +An overview over the Telestrat (Telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C compiler.) </abstract> @@ -37,7 +37,7 @@ is a machine language program with a 20 bytes header described here : http://ori This header is used for Telemon 3.0. -Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in telemon, there is no way to load a binary easiy. +Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily. Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. @@ -47,10 +47,12 @@ The only way to load a binary (for Telemon 2.4) is to : <itemize> <item>remove the 20 bytes header <item>download osdk : http://osdk.defence-force.org/index?page=download -<item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when telestrat starts) +<item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when Telestrat starts) </itemize> +Please note also, that the binary converted into TAP file, will not produce a right stratsed file when tap2dsk and old2mfm are used. You will be in the case that Telestrat/Stratsed crashed when you do "DIR" command. +If you know the Stratsed disk format, please contact the author of this doc. <sect>Memory layout<p> @@ -60,7 +62,6 @@ In the standard setup, cc65-generated programs use the memory from available. ROM calls are possible without further precautions. - Special locations: <descrip> @@ -110,7 +111,6 @@ structures; accessing the struct fields will access the chip registers. </descrip><p> - <sect>Loadable drivers<p> <sect1>Extended memory drivers<p> @@ -124,27 +124,31 @@ No extended memory drivers are currently available for the Telestrat. telemon 2.4 & 3.0 manages joysticks but it had been handled yet. -</descrip><p> +</descrip> <sect1>Mouse drivers<p> +<descrip> + Telestrat manages also mouse, but it had been no handled yet in this version. +</descrip> + <sect1>RS232 device drivers<p> <descrip> -not done +Telestrat has a RS232 port, but it's not used -</descrip><p> +</descrip>< <sect>Limitations<label id="limitations"><p> <sect1>Disk I/O<p> -This version handles fopen, fread, fclose primitives. Because Telemon 3.0 handles these three primitives. By the way, -it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives. +Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 did not have not these primitives. +By the way, Telemon 3.0 uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose). <itemize> <item>fclose From d76911d38a8544c3351977e2a8edd81a3bcb75e7 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 22:53:28 +0100 Subject: [PATCH 210/407] Fixing telestrat.h --- include/telestrat.h | 34 +++++++++++++++++++++++++++++----- libsrc/telestrat/close.s | 2 -- libsrc/telestrat/mainargs.s | 2 +- libsrc/telestrat/open.s | 4 +--- libsrc/telestrat/write.s | 2 +- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/include/telestrat.h b/include/telestrat.h index 85da8df60..5a090647b 100644 --- a/include/telestrat.h +++ b/include/telestrat.h @@ -1,17 +1,41 @@ +/*****************************************************************************/ +/* */ +/* telestrat.h */ +/* */ +/* Oric Telestrat system-specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2017 Debrune Jérome, <jede@oric.org> */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ -void hires(); -void text(); void oups(); void ping(); void zap(); void shoot(); void explode(); -void paper(char color); -void ink(char color); - void kbdclick1(); diff --git a/libsrc/telestrat/close.s b/libsrc/telestrat/close.s index 04d8788d1..40e2c10b3 100644 --- a/libsrc/telestrat/close.s +++ b/libsrc/telestrat/close.s @@ -14,5 +14,3 @@ BRK_TELEMON XCLOSE ; launch primitive ROM rts .endproc - - \ No newline at end of file diff --git a/libsrc/telestrat/mainargs.s b/libsrc/telestrat/mainargs.s index 41c3a5131..0c9e799da 100644 --- a/libsrc/telestrat/mainargs.s +++ b/libsrc/telestrat/mainargs.s @@ -8,7 +8,7 @@ .constructor initmainargs, 24 .import __argc, __argv - .import ptr1 + .import ptr1 .include "telestrat.inc" .macpack generic diff --git a/libsrc/telestrat/open.s b/libsrc/telestrat/open.s index 8e94de311..08910f4f2 100644 --- a/libsrc/telestrat/open.s +++ b/libsrc/telestrat/open.s @@ -27,9 +27,7 @@ parmok: sta tmp3 ; save flags ; Get the filename from stack and parse it. Bail out if is not ok jsr popax ; Get name - ldy tmp3 ; Get flags again + ldy tmp3 ; Get flags again BRK_TELEMON XOPEN ; launch primitive ROM rts .endproc - - \ No newline at end of file diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 1d269887d..8c2bc08f7 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -53,7 +53,7 @@ L2: ldy #0 cpx #$0A ; Check for \n bne L3 BRK_TELEMON XWR0 ; Macro send char to screen (channel 0 in telemon terms) - lda #$0D ; return to the beggining of the line + lda #$0D ; return to the beggining of the line BRK_TELEMON XWR0 ; Macro ; From d2fc2c74fb40a8d3a02b412560e71853c19207fb Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Fri, 3 Feb 2017 21:11:37 +0100 Subject: [PATCH 211/407] Correcting scrsize.s into _scrsize.s --- libsrc/telestrat/{scrsize.s => _scrsize.s} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libsrc/telestrat/{scrsize.s => _scrsize.s} (100%) diff --git a/libsrc/telestrat/scrsize.s b/libsrc/telestrat/_scrsize.s similarity index 100% rename from libsrc/telestrat/scrsize.s rename to libsrc/telestrat/_scrsize.s From 39a1a142e3ea26bcf052df9db372970cfe9214c0 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 6 Feb 2017 19:26:12 +0100 Subject: [PATCH 212/407] gamate, lynx, nes, pce: remove joy_stddrv.s These targets don't support dynamically loaded joystick drivers. --- libsrc/gamate/joy_stddrv.s | 13 ------------- libsrc/lynx/joy_stddrv.s | 13 ------------- libsrc/nes/joy_stddrv.s | 13 ------------- libsrc/pce/joy_stddrv.s | 13 ------------- 4 files changed, 52 deletions(-) delete mode 100644 libsrc/gamate/joy_stddrv.s delete mode 100644 libsrc/lynx/joy_stddrv.s delete mode 100644 libsrc/nes/joy_stddrv.s delete mode 100644 libsrc/pce/joy_stddrv.s diff --git a/libsrc/gamate/joy_stddrv.s b/libsrc/gamate/joy_stddrv.s deleted file mode 100644 index b830d8d86..000000000 --- a/libsrc/gamate/joy_stddrv.s +++ /dev/null @@ -1,13 +0,0 @@ -; -; Name of the standard joystick driver -; -; Oliver Schmidt, 2012-11-01 -; -; const char joy_stddrv[]; -; - - .export _joy_stddrv - -.rodata - -_joy_stddrv: .asciiz "gamate-stdjoy.joy" diff --git a/libsrc/lynx/joy_stddrv.s b/libsrc/lynx/joy_stddrv.s deleted file mode 100644 index b0d30e8d5..000000000 --- a/libsrc/lynx/joy_stddrv.s +++ /dev/null @@ -1,13 +0,0 @@ -; -; Name of the standard joystick driver -; -; Oliver Schmidt, 2012-11-01 -; -; const char joy_stddrv[]; -; - - .export _joy_stddrv - -.rodata - -_joy_stddrv: .asciiz "lynx-stdjoy.joy" diff --git a/libsrc/nes/joy_stddrv.s b/libsrc/nes/joy_stddrv.s deleted file mode 100644 index b99659746..000000000 --- a/libsrc/nes/joy_stddrv.s +++ /dev/null @@ -1,13 +0,0 @@ -; -; Name of the standard joystick driver -; -; Oliver Schmidt, 2012-11-01 -; -; const char joy_stddrv[]; -; - - .export _joy_stddrv - -.rodata - -_joy_stddrv: .asciiz "nes-stdjoy.joy" diff --git a/libsrc/pce/joy_stddrv.s b/libsrc/pce/joy_stddrv.s deleted file mode 100644 index ba397409a..000000000 --- a/libsrc/pce/joy_stddrv.s +++ /dev/null @@ -1,13 +0,0 @@ -; -; Name of the standard joystick driver -; -; Oliver Schmidt, 2012-11-01 -; -; const char joy_stddrv[]; -; - - .export _joy_stddrv - -.rodata - -_joy_stddrv: .asciiz "pce-stdjoy.joy" From e6359ec01947e75ed209d145f063da1692ee9c71 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 6 Feb 2017 20:59:52 +0100 Subject: [PATCH 213/407] Add initial creativision.sgml, contributed by Stefan Haubenthal. --- doc/creativision.sgml | 174 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 doc/creativision.sgml diff --git a/doc/creativision.sgml b/doc/creativision.sgml new file mode 100644 index 000000000..5b69da75a --- /dev/null +++ b/doc/creativision.sgml @@ -0,0 +1,174 @@ +<!doctype linuxdoc system> + +<article> + +<title>VTech Creativision (aka Funvision) specific information for cc65 +<author><url url="mailto:polluks+cc65@sdf.lonestar.org" name="Stefan A. Haubenthal"> +<date>2016-04-14 + +<abstract> +An overview over the Creativision runtime system as it is implemented for the +cc65 C compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview<p> + +This file contains an overview of the Creativision runtime system as it comes +with the cc65 C compiler. It describes the memory layout, Creativision specific header +files, available drivers, and any pitfalls specific to that platform. + +Please note that Creativision specific functions are just mentioned here, they are +described in detail in the separate <url url="funcref.html" name="function +reference">. Even functions marked as "platform dependent" may be available on +more than one platform. Please see the function reference for more information. + + +<sect>Binary format<p> + +The standard binary output format generated by the linker for the Creativision target +is a 4 kbyte machine language program. It is of course possible to change +this behaviour by using one of the different linker configs. + +<sect>Memory layout<p> + +cc65 generated programs with the default setup run with the I/O area enabled, +which gives a usable memory range of $B000 - $BEFF. +More ROM may need additional bankswitching code. + +Special locations: + +<descrip> + <tag/Text screen/ + The text screen is located at VRAM $1000. + + <tag/Stack/ + The C runtime stack is located at $3FF and growing downwards. + + <tag/Heap/ + The C heap is located at the end of the program and grows towards the C + runtime stack. + +</descrip><p> + + + +<sect>Platform specific header files<p> + +Programs containing Creativision specific code may use the <tt/creativision.h/ header file. + + +<sect1>Creativision specific functions<p> + +<itemize> +<item>bios_playsound +<item>joystate +<item>psg_delay +<item>psg_outb +<item>psg_silence +</itemize> + + + +<!--<sect1>Hardware access<p> + +The following pseudo variables declared in the <tt/creativision.inc/ include file do +allow access to hardware located in the address space. + +<descrip> + + <tag><tt/VDP/</tag> + The <tt/VDP/ defines allow access to the video chip. + +</descrip><p> + +<descrip> + + <tag><tt/PIA/</tag> + The <tt/PIA/ defines allow access to the I/O chip. + +</descrip><p>--> + + + +<sect>Loadable drivers<p> + +<sect1>Graphics drivers<p> + +No graphics drivers are currently available for the Creativision. + + +<sect1>Extended memory drivers<p> + +No extended memory drivers are currently available for the Creativision. + + +<sect1>Joystick drivers<p> + +No joystick drivers are currently available for the Creativision but <tt/joystate()/. + + +<sect1>Mouse drivers<p> + +No mouse drivers are currently available for the Creativision. + + +<sect1>RS232 device drivers<p> + +No communication port drivers are currently available for the Creativision. + + + +<sect>Limitations<p> + +<sect1>Disk I/O<p> + +The existing library for the Creativision doesn't implement C file +I/O. There are even no hacks for the <tt/read()/ and <tt/write()/ routines. + +To be more concrete, this limitation means that you cannot use any of the +following functions (and a few others): + +<itemize> +<item>fclose +<item>fopen +<item>fread +<item>fprintf +<item>fputc +<item>fscanf +<item>fwrite +<item>... +</itemize> + + + +<sect>Other hints<p> + + + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> From c33383e6de5beb17931c4375307071653fb9cdd0 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 6 Feb 2017 21:06:08 +0100 Subject: [PATCH 214/407] Add Creativision to README.md and html index --- README.md | 1 + doc/index.sgml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index b62ac761d..359fdaa08 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ including - the NEC PC-Engine (aka TurboGrafx-16). - the Nintendo Entertainment System (NES) console. - the Watara Supervision console. +- the VTech Creativision console. - the Oric Atmos. - the Lynx console. - the Ohio Scientific Challenger 1P. diff --git a/doc/index.sgml b/doc/index.sgml index 9b7ab794e..2a5c8894f 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -140,6 +140,9 @@ <tag><htmlurl url="cbm610.html" name="cbm610.html"></tag> Topics specific to the Commodore 610. + <tag><htmlurl url="creativision.html" name="creativision.html"></tag> + Topics specific to the Creativision Console. + <tag><htmlurl url="lynx.html" name="lynx.html"></tag> Topics specific to the Atari Lynx Game Console. From 69e3bbea7eba3c97802cf8fa94f581432ee5300c Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 7 Feb 2017 07:33:27 -0500 Subject: [PATCH 215/407] Reverted 'Used more mundane addressing in some of the instructions in "zlib/inflatemem.s".' This reverted some of commit e7e65044e607f15b7d5b4e55abf7cdcb123993a8. --- libsrc/zlib/inflatemem.s | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libsrc/zlib/inflatemem.s b/libsrc/zlib/inflatemem.s index ea550c074..b3a0510c5 100644 --- a/libsrc/zlib/inflatemem.s +++ b/libsrc/zlib/inflatemem.s @@ -1,10 +1,15 @@ ; ; 2003-09-21, Piotr Fusik -; 2016-07-19, Greg King +; 2017-02-07, Greg King ; ; unsigned __fastcall__ inflatemem (char* dest, const char* source); ; +; Two "lda (0,x)" instructions can't be assembled for the PC-Engine library +; because an implied ".setdp $2000" changes $00 into a non-zero-page address. +; Therefore, this file isn't assembled for that target. +.ifndef __PCE__ + .export _inflatemem .import incsp2 @@ -139,8 +144,8 @@ inflateCopyBlock: ldy #1 sty getBit_hold ; Get 16-bit length - ldx #0 - lda (inputPointer,x) + ldx #inputPointer + lda (0,x) sta moveBlock_len lda (inputPointer),y sta moveBlock_len+1 @@ -165,15 +170,15 @@ moveBlock: .endif inc moveBlock_len+1 moveBlock_1: - lda (inputPointer,x) + lda (0,x) .if (.cpu & CPU_ISET_65SC02) sta (outputPointer) .else sta (outputPointer),y .endif - inc inputPointer + inc 0,x bne moveBlock_2 - inc inputPointer+1 + inc 1,x moveBlock_2: inc outputPointer bne moveBlock_3 @@ -671,3 +676,5 @@ bitsPointer_h: ; Sorted codes. sortedCodes: .res 256+1+29+30+2 + +.endif From 38451fa8a4d6a1e4141f24bb50e774582ac564af Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 8 Feb 2017 14:34:35 +0100 Subject: [PATCH 216/407] intermediate check-in -- creativision joystick driver --- asminc/creativision.inc | 6 +- libsrc/creativision/joy/creativision-stdjoy.s | 191 ++++++++++++++++++ libsrc/creativision/joy_stat_stddrv.s | 12 ++ libsrc/creativision/libref.s | 3 +- 4 files changed, 207 insertions(+), 5 deletions(-) create mode 100644 libsrc/creativision/joy/creativision-stdjoy.s create mode 100644 libsrc/creativision/joy_stat_stddrv.s diff --git a/asminc/creativision.inc b/asminc/creativision.inc index 624b65e8f..bd30bc462 100644 --- a/asminc/creativision.inc +++ b/asminc/creativision.inc @@ -29,10 +29,10 @@ CH_URCORNER = 36 CH_LLCORNER = 37 CH_LRCORNER = 38 -;** I/O +;** I/O (Zero-page variables) ZP_KEYBOARD = $10 ZP_JOY0_DIR = $11 ZP_JOY1_DIR = $13 -ZP_JOY_LBUTTONS = $16 -ZP_JOY_RBUTTONS = $17 +ZP_JOY0_BUTTONS = $16 +ZP_JOY1_BUTTONS = $17 diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s new file mode 100644 index 000000000..f24a8045b --- /dev/null +++ b/libsrc/creativision/joy/creativision-stdjoy.s @@ -0,0 +1,191 @@ +; +; Standard joystick driver for the Creativision. +; +; Christian Groessler, 2017-02-06 +; + + .include "zeropage.inc" + + .include "joy-kernel.inc" + .include "joy-error.inc" + .include "creativision.inc" + + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _creativisionstd_joy + +; Driver signature + + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number + +; Library reference + + .addr $0000 + +; Button state masks (8 values) + + .byte $10 ; JOY_UP + .byte $04 ; JOY_DOWN + .byte $20 ; JOY_LEFT + .byte $08 ; JOY_RIGHT + .byte $01 ; JOY_FIRE (button #1) + .byte $02 ; JOY_FIRE2 (button #2) + .byte $00 ; Future expansion + .byte $00 ; Future expansion + +; Jump table. + + .addr INSTALL + .addr UNINSTALL + .addr COUNT + .addr READJOY + .addr 0 ; IRQ entry not used + +; ------------------------------------------------------------------------ +; Constants + +JOY_COUNT = 2 ; Number of joysticks we support + +; ------------------------------------------------------------------------ +; Code + + .code + +; ------------------------------------------------------------------------ +; INSTALL routine. Is called after the driver is loaded into memory. If +; possible, check if the hardware is present and determine the amount of +; memory available. +; Must return an JOY_ERR_xx code in a/x. +; + +INSTALL: + lda #JOY_ERR_OK + ldx #0 +; rts ; Fall through + +; ------------------------------------------------------------------------ +; UNINSTALL routine. Is called before the driver is removed from memory. +; Can do cleanup or whatever. Must not return anything. +; + +UNINSTALL: + rts + + +; ------------------------------------------------------------------------ +; COUNT: Return the total number of available joysticks in a/x. +; + +COUNT: + lda #<JOY_COUNT + ldx #>JOY_COUNT + rts + +; ------------------------------------------------------------------------ +; READ: Read a particular joystick passed in A. +; + +READJOY: + and #1 ; fix joystick number + bne READJOY_1 ; read right joystick + +; Read left joystick + + ldx ZP_JOY0_DIR + lda ZP_JOY0_BUTTONS + jmp convert ; convert joystick state to sane cc65 values + +; Read right joystick + +READJOY_1: + + ldx ZP_JOY1_DIR + lda ZP_JOY1_BUTTONS + lsr a + lsr a + ;jmp convert ; convert joystick state to sane cc65 values + ; fall thru... + +; ------------------------------------------------------------------------ +; convert: make runtime lib compatible values +; A - buttons +; X - direction +; + +convert: + ldy #0 + sty retval ; initialize return value + +; ------ +; buttons: + ; Port values are for the left hand joystick (right hand joystick + ; values were shifted to the right to be identical). + ; Why are there two bits indicating a pressed trigger? + ; According to the "Second book of programs for the Dick Smith Wizard" + ; (pg. 88ff), the left hand fire button gives the value of + ; %00010001 and the right hand button gives %00100010 + ; Why two bits? Am I missing something? Can there be cases that just + ; one of those bits is set? + ; We just test if any of those two bits is not zero... + + tay + and #%00010001 + beq cnv_1 + + inc retval ; left button pressed + +cnv_1: tya + and #%00100010 + beq cnv_2 + + lda #$02 + ora retval + sta retval ; right button pressed + +; ------ +; direction: +cnv_2: txa + ; tested with https://sourceforge.net/projects/creativisionemulator + ; $49 - %01001001 - up + ; $41 - %01000001 - down + ; $4D - %01001101 - left + ; $45 - %01000101 - right + ; + ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different + ; ignored for now... + ; $85 - %10000101 - up + right + ; $8D - %10001101 - down + left + ; $89 - %10001001 - up + left + ; $85 - %10000101 - down + right (emulator bug?) + + bit testbit ; bit #0 set? + beq done ; no, no direction + + and #%00001100 ; mask out other bits + tax + lda #%00000100 ; init bitmask +loop: dex + bmi done2 + asl a + bne loop + +done2: ora retval + rts + +done: lda retval + rts + +; ------------------------------------------------------------------------ +; + .data +testbit:.byte $01 + +; ------------------------------------------------------------------------ +; + .bss +retval: .res 0 diff --git a/libsrc/creativision/joy_stat_stddrv.s b/libsrc/creativision/joy_stat_stddrv.s new file mode 100644 index 000000000..fc458641c --- /dev/null +++ b/libsrc/creativision/joy_stat_stddrv.s @@ -0,0 +1,12 @@ +; +; Address of the static standard joystick driver +; +; Christian Groessler, 2017-02-06 +; +; const void joy_static_stddrv[]; +; + + .export _joy_static_stddrv + .import _creativisionstd_joy + +_joy_static_stddrv := _creativisionstd_joy diff --git a/libsrc/creativision/libref.s b/libsrc/creativision/libref.s index b642da80a..19e7e778f 100644 --- a/libsrc/creativision/libref.s +++ b/libsrc/creativision/libref.s @@ -2,8 +2,7 @@ ; Oliver Schmidt, 2013-05-31 ; - .export joy_libref, tgi_libref + .export joy_libref .import _exit joy_libref := _exit -tgi_libref := _exit From 9cde534b232572b30456b2d4574d0ef0f0ccad0b Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 9 Feb 2017 18:46:56 +0100 Subject: [PATCH 217/407] Rollback for *.vcxproj, telestrat.sgml modified for "don't" instead of "did not" for telemon2.4 --- doc/telestrat.sgml | 2 +- src/ar65.vcxproj | 6 +++--- src/ca65.vcxproj | 6 +++--- src/cc65.vcxproj | 6 +++--- src/chrcvt65.vcxproj | 6 +++--- src/cl65.vcxproj | 6 +++--- src/co65.vcxproj | 6 +++--- src/common.vcxproj | 6 +++--- src/da65.vcxproj | 8 +++++--- src/grc65.vcxproj | 6 +++--- src/ld65.vcxproj | 6 +++--- src/od65.vcxproj | 6 +++--- src/sim65.vcxproj | 6 +++--- src/sp65.vcxproj | 6 +++--- 14 files changed, 42 insertions(+), 40 deletions(-) diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index c04e14f54..9032156ee 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -147,7 +147,7 @@ Telestrat has a RS232 port, but it's not used <sect1>Disk I/O<p> -Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 did not have not these primitives. +Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 does not have these primitives. By the way, Telemon 3.0 uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose). <itemize> diff --git a/src/ar65.vcxproj b/src/ar65.vcxproj index 003a5fa69..b077134ce 100644 --- a/src/ar65.vcxproj +++ b/src/ar65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ca65.vcxproj b/src/ca65.vcxproj index fb7cf2e26..4e02fa2a9 100644 --- a/src/ca65.vcxproj +++ b/src/ca65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/cc65.vcxproj b/src/cc65.vcxproj index aa85b0936..1c1f993fe 100644 --- a/src/cc65.vcxproj +++ b/src/cc65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/chrcvt65.vcxproj b/src/chrcvt65.vcxproj index d120399d1..1daf7cae9 100644 --- a/src/chrcvt65.vcxproj +++ b/src/chrcvt65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/cl65.vcxproj b/src/cl65.vcxproj index b6ceb161a..64c1126b1 100644 --- a/src/cl65.vcxproj +++ b/src/cl65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/co65.vcxproj b/src/co65.vcxproj index 89eed36e1..c66c8aac8 100644 --- a/src/co65.vcxproj +++ b/src/co65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/common.vcxproj b/src/common.vcxproj index c466d9712..053d23981 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -113,13 +113,13 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> <ConfigurationType>StaticLibrary</ConfigurationType> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/da65.vcxproj b/src/da65.vcxproj index cf297fd32..2695edc08 100644 --- a/src/da65.vcxproj +++ b/src/da65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> @@ -86,6 +86,7 @@ <ClCompile Include="da65\infofile.c" /> <ClCompile Include="da65\labels.c" /> <ClCompile Include="da65\main.c" /> + <ClCompile Include="da65\opc4510.c" /> <ClCompile Include="da65\opc6502.c" /> <ClCompile Include="da65\opc6502x.c" /> <ClCompile Include="da65\opc65816.c" /> @@ -109,6 +110,7 @@ <ClInclude Include="da65\handler.h" /> <ClInclude Include="da65\infofile.h" /> <ClInclude Include="da65\labels.h" /> + <ClInclude Include="da65\opc4510.h" /> <ClInclude Include="da65\opc6502.h" /> <ClInclude Include="da65\opc6502x.h" /> <ClInclude Include="da65\opc65816.h" /> diff --git a/src/grc65.vcxproj b/src/grc65.vcxproj index afac0cce1..211ad7cce 100644 --- a/src/grc65.vcxproj +++ b/src/grc65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ld65.vcxproj b/src/ld65.vcxproj index cc5598aad..acb9b4240 100644 --- a/src/ld65.vcxproj +++ b/src/ld65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/od65.vcxproj b/src/od65.vcxproj index 2ace26001..c788ac961 100644 --- a/src/od65.vcxproj +++ b/src/od65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/sim65.vcxproj b/src/sim65.vcxproj index 9ba0980ba..f87b4db6b 100644 --- a/src/sim65.vcxproj +++ b/src/sim65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/sp65.vcxproj b/src/sp65.vcxproj index 6e7d992d4..8db98346c 100644 --- a/src/sp65.vcxproj +++ b/src/sp65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> From 4266e712f25383a2a5dbabb0161240f8c989b9f1 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Sun, 12 Feb 2017 11:41:11 +0100 Subject: [PATCH 218/407] Optimize inflatemem. The new version is 30% shorter and 10% faster. It also avoids the indirect-X addressing mode, which was a problem for PC-Engine. --- libsrc/zlib/inflatemem.s | 954 +++++++++++++++++---------------------- 1 file changed, 404 insertions(+), 550 deletions(-) diff --git a/libsrc/zlib/inflatemem.s b/libsrc/zlib/inflatemem.s index b3a0510c5..27802fbff 100644 --- a/libsrc/zlib/inflatemem.s +++ b/libsrc/zlib/inflatemem.s @@ -1,43 +1,41 @@ ; -; 2003-09-21, Piotr Fusik -; 2017-02-07, Greg King +; 2017-02-12, Piotr Fusik ; ; unsigned __fastcall__ inflatemem (char* dest, const char* source); ; - -; Two "lda (0,x)" instructions can't be assembled for the PC-Engine library -; because an implied ".setdp $2000" changes $00 into a non-zero-page address. -; Therefore, this file isn't assembled for that target. -.ifndef __PCE__ +; NOTE: Be extremely careful with modifications, because this code is heavily +; optimized for size (for example assumes certain register and flag values +; when its internal routines return). Test with the gunzip65 sample. +; .export _inflatemem .import incsp2 - .importzp sp, sreg, ptr1, ptr2, ptr3, ptr4, tmp1 - - .macpack cpu + .importzp sp, sreg, ptr1, ptr2, ptr3, ptr4 ; -------------------------------------------------------------------------- ; ; Constants ; -; Maximum length of a Huffman code. -MAX_BITS = 15 +; Argument values for getBits. +GET_1_BIT = $81 +GET_2_BITS = $82 +GET_3_BITS = $84 +GET_4_BITS = $88 +GET_5_BITS = $90 +GET_6_BITS = $a0 +GET_7_BITS = $c0 -; All Huffman trees are stored in the bitsCount, bitsPointer_l -; and bitsPointer_h arrays. There may be two trees: the literal/length tree -; and the distance tree, or just one - the temporary tree. +; Huffman trees. +TREE_SIZE = 16 +PRIMARY_TREE = 0 +DISTANCE_TREE = TREE_SIZE -; Index in the mentioned arrays for the beginning of the literal/length tree -; or the temporary tree. -PRIMARY_TREE = 0 - -; Index in the mentioned arrays for the beginning of the distance tree. -DISTANCE_TREE = MAX_BITS - -; Size of each array. -TREES_SIZE = 2*MAX_BITS +; Alphabet. +LENGTH_SYMBOLS = 1+29+2 ; EOF, 29 length symbols, two unused symbols +DISTANCE_SYMBOLS = 30 +CONTROL_SYMBOLS = LENGTH_SYMBOLS+DISTANCE_SYMBOLS ; -------------------------------------------------------------------------- @@ -46,30 +44,26 @@ TREES_SIZE = 2*MAX_BITS ; ; Pointer to the compressed data. -inputPointer := ptr1 ; 2 bytes +inputPointer := ptr1 ; 2 bytes ; Pointer to the uncompressed data. -outputPointer := ptr2 ; 2 bytes +outputPointer := ptr2 ; 2 bytes ; Local variables. ; As far as there is no conflict, same memory locations are used ; for different variables. -inflateDynamicBlock_cnt := ptr3 ; 1 byte -inflateCodes_src := ptr3 ; 2 bytes -buildHuffmanTree_src := ptr3 ; 2 bytes -getNextLength_last := ptr3 ; 1 byte -getNextLength_index := ptr3+1 ; 1 byte - -buildHuffmanTree_ptr := ptr4 ; 2 bytes -fetchCode_ptr := ptr4 ; 2 bytes -getBits_tmp := ptr4 ; 1 byte - -moveBlock_len := sreg ; 2 bytes -inflateDynamicBlock_np := sreg ; 1 byte -inflateDynamicBlock_nd := sreg+1 ; 1 byte - -getBit_hold := tmp1 ; 1 byte +inflateStored_pageCounter := ptr3 ; 1 byte +inflateDynamic_symbol := ptr3 ; 1 byte +inflateDynamic_lastLength := ptr3+1 ; 1 byte + .assert ptr4 = ptr3 + 2, error, "Need three bytes for inflateDynamic_tempCodes" +inflateDynamic_tempCodes := ptr3+1 ; 3 bytes +inflateDynamic_allCodes := inflateDynamic_tempCodes+1 ; 1 byte +inflateDynamic_primaryCodes := inflateDynamic_tempCodes+2 ; 1 byte +inflateCodes_sourcePointer := ptr3 ; 2 bytes +inflateCodes_lengthMinus2 := ptr4 ; 1 byte +getBits_base := sreg ; 1 byte +getBit_buffer := sreg+1 ; 1 byte ; -------------------------------------------------------------------------- @@ -83,45 +77,59 @@ _inflatemem: sta inputPointer stx inputPointer+1 ; outputPointer = dest -.if (.cpu & CPU_ISET_65SC02) - lda (sp) ldy #1 -.else - ldy #0 - lda (sp),y - iny -.endif - sta outputPointer lda (sp),y sta outputPointer+1 + dey + lda (sp),y + sta outputPointer -; ldy #1 - sty getBit_hold -inflatemem_1: +; ldy #0 + sty getBit_buffer + +inflate_blockLoop: ; Get a bit of EOF and two bits of block type - ldx #3 - lda #0 +; ldy #0 + sty getBits_base + lda #GET_3_BITS jsr getBits lsr a ; A and Z contain block type, C contains EOF flag ; Save EOF flag php -; Go to the routine decompressing this block - jsr callExtr - plp - bcc inflatemem_1 -; C flag is set! + bne inflateCompressed -; return outputPointer - dest; +; Decompress a 'stored' data block. +; ldy #0 + sty getBit_buffer ; ignore bits until byte boundary + jsr getWord ; skip the length we don't need + jsr getWord ; get the two's complement length + sta inflateStored_pageCounter + bcs inflateStored_firstByte ; jmp +inflateStored_copyByte: + jsr getByte +; sec +inflateStoreByte: + jsr storeByte + bcc inflateCodes_loop +inflateStored_firstByte: + inx + bne inflateStored_copyByte + inc inflateStored_pageCounter + bne inflateStored_copyByte + +; Block decompressed. +inflate_nextBlock: + plp + bcc inflate_blockLoop + +; Decompression complete. +; return outputPointer - dest lda outputPointer -.if (.cpu & CPU_ISET_65SC02) - sbc (sp) ; C flag is set - ldy #1 -.else - ldy #0 - sbc (sp),y ; C flag is set +; ldy #0 +; sec + sbc (sp),y iny -.endif pha lda outputPointer+1 sbc (sp),y @@ -130,442 +138,346 @@ inflatemem_1: ; pop dest jmp incsp2 -; -------------------------------------------------------------------------- -; Go to proper block decoding routine. - -callExtr: - bne inflateCompressedBlock - -; -------------------------------------------------------------------------- -; Decompress a 'stored' data block. - -inflateCopyBlock: -; Ignore bits until byte boundary - ldy #1 - sty getBit_hold -; Get 16-bit length - ldx #inputPointer - lda (0,x) - sta moveBlock_len - lda (inputPointer),y - sta moveBlock_len+1 -; Skip the length and one's complement of it - lda #4 - clc - adc inputPointer - sta inputPointer - bcc moveBlock - inc inputPointer+1 -; jmp moveBlock - -; -------------------------------------------------------------------------- -; Copy block of length moveBlock_len from (0,x) to the output. - -moveBlock: - ldy moveBlock_len - beq moveBlock_1 -.if (.cpu & CPU_ISET_65SC02) -.else - ldy #0 -.endif - inc moveBlock_len+1 -moveBlock_1: - lda (0,x) -.if (.cpu & CPU_ISET_65SC02) - sta (outputPointer) -.else - sta (outputPointer),y -.endif - inc 0,x - bne moveBlock_2 - inc 1,x -moveBlock_2: - inc outputPointer - bne moveBlock_3 - inc outputPointer+1 -moveBlock_3: -.if (.cpu & CPU_ISET_65SC02) - dey -.else - dec moveBlock_len -.endif - bne moveBlock_1 - dec moveBlock_len+1 - bne moveBlock_1 - rts - -; -------------------------------------------------------------------------- +inflateCompressed: ; Decompress a Huffman-coded data block -; (A = 1: fixed, A = 2: dynamic). +; A=1: fixed block, initialize with fixed codes +; A=2: dynamic block, start by clearing all code lengths +; A=3: invalid compressed data, not handled in this routine + eor #2 -inflateCompressedBlock: - lsr a - bne inflateDynamicBlock -; Note: inflateDynamicBlock may assume that A = 1 - -; -------------------------------------------------------------------------- -; Decompress a Huffman-coded data block with default Huffman trees -; (defined by the DEFLATE format): -; literalCodeLength: 144 times 8, 112 times 9 -; endCodeLength: 7 -; lengthCodeLength: 23 times 7, 6 times 8 -; distanceCodeLength: 30 times 5+DISTANCE_TREE, 2 times 8 -; (two 8-bit codes from the primary tree are not used). - -inflateFixedBlock: - ldx #159 - stx distanceCodeLength+32 - lda #8 -inflateFixedBlock_1: - sta literalCodeLength-1,x - sta literalCodeLength+159-1,x - dex - bne inflateFixedBlock_1 - ldx #112 -; lda #9 -inflateFixedBlock_2: - inc literalCodeLength+144-1,x ; sta - dex - bne inflateFixedBlock_2 - ldx #24 -; lda #7 -inflateFixedBlock_3: - dec endCodeLength-1,x ; sta - dex - bne inflateFixedBlock_3 - ldx #30 - lda #5+DISTANCE_TREE -inflateFixedBlock_4: - sta distanceCodeLength-1,x - dex - bne inflateFixedBlock_4 - beq inflateCodes ; branch always - -; -------------------------------------------------------------------------- -; Decompress a Huffman-coded data block, reading Huffman trees first. - -inflateDynamicBlock: -; numberOfPrimaryCodes = 257 + getBits(5) - ldx #5 -; lda #1 - jsr getBits - sta inflateDynamicBlock_np -; numberOfDistanceCodes = 1 + getBits(5) - ldx #5 - lda #1+29+1 - jsr getBits - sta inflateDynamicBlock_nd -; numberOfTemporaryCodes = 4 + getBits(4) - lda #4 +; ldy #0 +inflateCompressed_setCodeLengths: tax - jsr getBits - sta inflateDynamicBlock_cnt -; Get lengths of temporary codes in the order stored in tempCodeLengthOrder - txa ; lda #0 - tay -inflateDynamicBlock_1: - ldx #3 ; A = 0 - jsr getBits ; does not change Y -inflateDynamicBlock_2: - ldx tempCodeLengthOrder,y - sta literalCodeLength,x - lda #0 + beq inflateCompressed_setLiteralCodeLength +; fixed Huffman literal codes: +; 144 8-bit codes +; 112 9-bit codes + lda #4 + cpy #144 + rol a +inflateCompressed_setLiteralCodeLength: + sta literalSymbolCodeLength,y + beq inflateCompressed_setControlCodeLength +; fixed Huffman control codes: +; 24 7-bit codes +; 6 8-bit codes +; 2 meaningless 8-bit codes +; 30 5-bit distance codes + lda #5+DISTANCE_TREE + cpy #LENGTH_SYMBOLS + bcs inflateCompressed_setControlCodeLength + cpy #24 + adc #$100+2-DISTANCE_TREE +inflateCompressed_setControlCodeLength: + cpy #CONTROL_SYMBOLS + bcs inflateCompressed_noControlSymbol + sta controlSymbolCodeLength,y +inflateCompressed_noControlSymbol: iny - cpy inflateDynamicBlock_cnt - bcc inflateDynamicBlock_1 - cpy #19 - bcc inflateDynamicBlock_2 - ror literalCodeLength+19 ; C flag is set, so this will set b7 + bne inflateCompressed_setCodeLengths + + tax + beq inflateDynamic + +; Decompress a block +inflateCodes: + jsr buildHuffmanTree +inflateCodes_loop: + jsr fetchPrimaryCode + bcc inflateStoreByte + beq inflate_nextBlock +; Copy sequence from look-behind buffer +; ldy #0 + sty getBits_base + cmp #9 + bcc inflateCodes_setSequenceLength + tya +; lda #0 + cpx #1+28 + bcs inflateCodes_setSequenceLength + dex + txa + lsr a + ror getBits_base + inc getBits_base + lsr a + rol getBits_base + jsr getAMinus1BitsMax8 +; sec + adc #0 +inflateCodes_setSequenceLength: + sta inflateCodes_lengthMinus2 + ldx #DISTANCE_TREE + jsr fetchCode + cmp #4 + bcc inflateCodes_setOffsetLowByte + inc getBits_base + lsr a + jsr getAMinus1BitsMax8 +inflateCodes_setOffsetLowByte: + eor #$ff + sta inflateCodes_sourcePointer + lda getBits_base + cpx #10 + bcc inflateCodes_setOffsetHighByte + lda getNPlus1Bits_mask-10,x + jsr getBits + clc +inflateCodes_setOffsetHighByte: + eor #$ff +; clc + adc outputPointer+1 + sta inflateCodes_sourcePointer+1 + jsr copyByte + jsr copyByte +inflateCodes_copyByte: + jsr copyByte + dec inflateCodes_lengthMinus2 + bne inflateCodes_copyByte + beq inflateCodes_loop ; jmp + +inflateDynamic: +; Decompress a block reading Huffman trees first +; ldy #0 +; numberOfPrimaryCodes = 257 + getBits(5) +; numberOfDistanceCodes = 1 + getBits(5) +; numberOfTemporaryCodes = 4 + getBits(4) + ldx #3 +inflateDynamic_getHeader: + lda inflateDynamic_headerBits-1,x + jsr getBits +; sec + adc inflateDynamic_headerBase-1,x + sta inflateDynamic_tempCodes-1,x + dex + bne inflateDynamic_getHeader + +; Get lengths of temporary codes in the order stored in inflateDynamic_tempSymbols +; ldx #0 +inflateDynamic_getTempCodeLengths: + lda #GET_3_BITS + jsr getBits + ldy inflateDynamic_tempSymbols,x + sta literalSymbolCodeLength,y + ldy #0 + inx + cpx inflateDynamic_tempCodes + bcc inflateDynamic_getTempCodeLengths + ; Build the tree for temporary codes jsr buildHuffmanTree ; Use temporary codes to get lengths of literal/length and distance codes - ldx #0 - ldy #1 - stx getNextLength_last -inflateDynamicBlock_3: - jsr getNextLength - sta literalCodeLength,x - inx - bne inflateDynamicBlock_3 -inflateDynamicBlock_4: - jsr getNextLength -inflateDynamicBlock_5: - sta endCodeLength,x - inx - cpx inflateDynamicBlock_np - bcc inflateDynamicBlock_4 - lda #0 - cpx #1+29 - bcc inflateDynamicBlock_5 -inflateDynamicBlock_6: - jsr getNextLength - cmp #0 - beq inflateDynamicBlock_7 - adc #DISTANCE_TREE-1 ; C flag is set -inflateDynamicBlock_7: - sta endCodeLength,x - inx - cpx inflateDynamicBlock_nd - bcc inflateDynamicBlock_6 - ror endCodeLength,x ; C flag is set, so this will set b7 -; jmp inflateCodes - -; -------------------------------------------------------------------------- -; Decompress a data block basing on given Huffman trees. - -inflateCodes: - jsr buildHuffmanTree -inflateCodes_1: - jsr fetchPrimaryCode - bcs inflateCodes_2 -; Literal code -.if (.cpu & CPU_ISET_65SC02) - sta (outputPointer) -.else - ldy #0 - sta (outputPointer),y -.endif - inc outputPointer - bne inflateCodes_1 - inc outputPointer+1 - bcc inflateCodes_1 ; branch always -; End of block -inflateCodes_ret: - rts -inflateCodes_2: - beq inflateCodes_ret -; Restore a block from the look-behind buffer - jsr getValue - sta moveBlock_len - tya - jsr getBits - sta moveBlock_len+1 - ldx #DISTANCE_TREE - jsr fetchCode - jsr getValue - sec - eor #$ff - adc outputPointer - sta inflateCodes_src +; ldx #0 +; sec +inflateDynamic_decodeLength: +; C=1: literal codes +; C=0: control codes + stx inflateDynamic_symbol php - tya - jsr getBits - plp - eor #$ff - adc outputPointer+1 - sta inflateCodes_src+1 - ldx #inflateCodes_src - jsr moveBlock - beq inflateCodes_1 ; branch always - -; -------------------------------------------------------------------------- -; Build Huffman trees basing on code lengths (in bits). -; stored in the *CodeLength arrays. -; A byte with its highest bit set marks the end. - -buildHuffmanTree: - lda #<literalCodeLength - sta buildHuffmanTree_src - lda #>literalCodeLength - sta buildHuffmanTree_src+1 -; Clear bitsCount and bitsPointer_l - ldy #2*TREES_SIZE+1 - lda #0 -buildHuffmanTree_1: - sta bitsCount-1,y - dey - bne buildHuffmanTree_1 - beq buildHuffmanTree_3 ; branch always -; Count number of codes of each length -buildHuffmanTree_2: - tax - inc bitsPointer_l,x - iny - bne buildHuffmanTree_3 - inc buildHuffmanTree_src+1 -buildHuffmanTree_3: - lda (buildHuffmanTree_src),y - bpl buildHuffmanTree_2 -; Calculate a pointer for each length - ldx #0 - lda #<sortedCodes - ldy #>sortedCodes - clc -buildHuffmanTree_4: - sta bitsPointer_l,x - tya - sta bitsPointer_h,x - lda bitsPointer_l+1,x - adc bitsPointer_l,x ; C flag is zero - bcc buildHuffmanTree_5 - iny -buildHuffmanTree_5: - inx - cpx #TREES_SIZE - bcc buildHuffmanTree_4 - lda #>literalCodeLength - sta buildHuffmanTree_src+1 - ldy #0 - bcs buildHuffmanTree_9 ; branch always -; Put codes into their place in sorted table -buildHuffmanTree_6: - beq buildHuffmanTree_7 - tax - lda bitsPointer_l-1,x - sta buildHuffmanTree_ptr - lda bitsPointer_h-1,x - sta buildHuffmanTree_ptr+1 - tya - ldy bitsCount-1,x - inc bitsCount-1,x - sta (buildHuffmanTree_ptr),y - tay -buildHuffmanTree_7: - iny - bne buildHuffmanTree_9 - inc buildHuffmanTree_src+1 - ldx #MAX_BITS-1 -buildHuffmanTree_8: - lda bitsCount,x - sta literalCount,x - dex - bpl buildHuffmanTree_8 -buildHuffmanTree_9: - lda (buildHuffmanTree_src),y - bpl buildHuffmanTree_6 - rts - -; -------------------------------------------------------------------------- -; Decode next code length using temporary codes. - -getNextLength: - stx getNextLength_index - dey - bne getNextLength_1 ; Fetch a temporary code jsr fetchPrimaryCode ; Temporary code 0..15: put this length - ldy #1 - cmp #16 - bcc getNextLength_2 + bpl inflateDynamic_storeLengths ; Temporary code 16: repeat last length 3 + getBits(2) times ; Temporary code 17: put zero length 3 + getBits(3) times ; Temporary code 18: put zero length 11 + getBits(7) times - tay - ldx tempExtraBits-16,y - lda tempBaseValue-16,y + tax jsr getBits - cpy #17 + cpx #GET_3_BITS + bcc inflateDynamic_code16 + beq inflateDynamic_code17 +; sec + adc #7 +inflateDynamic_code17: +; ldy #0 + sty inflateDynamic_lastLength +inflateDynamic_code16: tay - txa ; lda #0 - bcs getNextLength_2 -getNextLength_1: - lda getNextLength_last -getNextLength_2: - sta getNextLength_last - ldx getNextLength_index + lda inflateDynamic_lastLength + iny + iny +inflateDynamic_storeLengths: + iny + plp + ldx inflateDynamic_symbol +inflateDynamic_storeLength: + bcc inflateDynamic_controlSymbolCodeLength + sta literalSymbolCodeLength,x + inx + cpx #1 +inflateDynamic_storeNext: + dey + bne inflateDynamic_storeLength + sta inflateDynamic_lastLength + beq inflateDynamic_decodeLength ; jmp +inflateDynamic_controlSymbolCodeLength: + cpx inflateDynamic_primaryCodes + bcc inflateDynamic_storeControl +; the code lengths we skip here were zero-initialized +; in inflateCompressed_setControlCodeLength + bne inflateDynamic_noStartDistanceTree + ldx #LENGTH_SYMBOLS +inflateDynamic_noStartDistanceTree: + ora #DISTANCE_TREE +inflateDynamic_storeControl: + sta controlSymbolCodeLength,x + inx + cpx inflateDynamic_allCodes + bcc inflateDynamic_storeNext + dey +; ldy #0 + jmp inflateCodes + +; Build Huffman trees basing on code lengths (in bits) +; stored in the *SymbolCodeLength arrays +buildHuffmanTree: +; Clear nBitCode_totalCount, nBitCode_literalCount, nBitCode_controlCount + tya +; lda #0 +buildHuffmanTree_clear: + sta nBitCode_clearFrom,y + iny + bne buildHuffmanTree_clear +; Count number of codes of each length +; ldy #0 +buildHuffmanTree_countCodeLengths: + ldx literalSymbolCodeLength,y + inc nBitCode_literalCount,x + inc nBitCode_totalCount,x + cpy #CONTROL_SYMBOLS + bcs buildHuffmanTree_noControlSymbol + ldx controlSymbolCodeLength,y + inc nBitCode_controlCount,x + inc nBitCode_totalCount,x +buildHuffmanTree_noControlSymbol: + iny + bne buildHuffmanTree_countCodeLengths +; Calculate offsets of symbols sorted by code length +; lda #0 + ldx #$100-3*TREE_SIZE +buildHuffmanTree_calculateOffsets: + sta nBitCode_literalOffset+3*TREE_SIZE-$100,x + clc + adc nBitCode_literalCount+3*TREE_SIZE-$100,x + inx + bne buildHuffmanTree_calculateOffsets +; Put symbols in their place in the sorted array +; ldy #0 +buildHuffmanTree_assignCode: + tya + ldx literalSymbolCodeLength,y + ldy nBitCode_literalOffset,x + inc nBitCode_literalOffset,x + sta codeToLiteralSymbol,y + tay + cpy #CONTROL_SYMBOLS + bcs buildHuffmanTree_noControlSymbol2 + ldx controlSymbolCodeLength,y + ldy nBitCode_controlOffset,x + inc nBitCode_controlOffset,x + sta codeToControlSymbol,y + tay +buildHuffmanTree_noControlSymbol2: + iny + bne buildHuffmanTree_assignCode rts -; -------------------------------------------------------------------------- -; Read a code basing on the primary tree. - +; Read Huffman code using the primary tree fetchPrimaryCode: ldx #PRIMARY_TREE -; jmp fetchCode - -; -------------------------------------------------------------------------- -; Read a code from input basing on the tree specified in X. +; Read a code from input using the tree specified in X. ; Return low byte of this code in A. -; For the literal/length tree, the C flag is set if the code is non-literal. - +; Return C flag reset for literal code, set for length code. fetchCode: - lda #0 -fetchCode_1: +; ldy #0 + tya +fetchCode_nextBit: jsr getBit rol a inx sec - sbc bitsCount-1,x - bcs fetchCode_1 - adc bitsCount-1,x ; C flag is zero - cmp literalCount-1,x - sta fetchCode_ptr - ldy bitsPointer_l-1,x - lda bitsPointer_h-1,x - sta fetchCode_ptr+1 - lda (fetchCode_ptr),y + sbc nBitCode_totalCount,x + bcs fetchCode_nextBit +; clc + adc nBitCode_controlCount,x + bcs fetchCode_control +; clc + adc nBitCode_literalOffset,x + tax + lda codeToLiteralSymbol,x + clc + rts +fetchCode_control: +; sec + adc nBitCode_controlOffset-1,x + tax + lda codeToControlSymbol-1,x + and #$1f ; make distance symbols zero-based + tax + sec rts -; -------------------------------------------------------------------------- -; Decode low byte of a value (length or distance), basing on the code in A. -; The result is the base value for this code plus some bits read from input. - -getValue: - tay - ldx lengthExtraBits-1,y - lda lengthBaseValue_l-1,y - pha - lda lengthBaseValue_h-1,y - tay - pla -; jmp getBits - -; -------------------------------------------------------------------------- -; Read X-bit number from the input and add it to A. -; Increment Y if overflow. -; If X > 8, read only 8 bits. -; On return X holds number of unread bits: X = (X > 8 ? X - 8 : 0); - +; Read A minus 1 bits, but no more than 8 +getAMinus1BitsMax8: + rol getBits_base + tax + cmp #9 + bcs getByte + lda getNPlus1Bits_mask-2,x getBits: - cpx #0 - beq getBits_ret -.if (.cpu & CPU_ISET_65SC02) - stz getBits_tmp - dec getBits_tmp -.else - pha - lda #$ff - sta getBits_tmp - pla -.endif -getBits_1: - jsr getBit - bcc getBits_2 - sbc getBits_tmp ; C flag is set - bcc getBits_2 - iny -getBits_2: - dex - beq getBits_ret - asl getBits_tmp - bmi getBits_1 -getBits_ret: + jsr getBits_loop +getBits_normalizeLoop: + lsr getBits_base + ror a + bcc getBits_normalizeLoop rts -; -------------------------------------------------------------------------- -; Read a single bit from input, return it in the C flag. +; Read 16 bits +getWord: + jsr getByte + tax +; Read 8 bits +getByte: + lda #$80 +getBits_loop: + jsr getBit + ror a + bcc getBits_loop + rts +; Read one bit, return in the C flag getBit: - lsr getBit_hold - bne getBit_ret + lsr getBit_buffer + bne getBit_return pha -.if (.cpu & CPU_ISET_65SC02) - lda (inputPointer) -.else - sty getBit_hold - ldy #0 +; ldy #0 lda (inputPointer),y - ldy getBit_hold -.endif inc inputPointer - bne getBit_1 + bne getBit_samePage inc inputPointer+1 -getBit_1: - ror a ; (C flag was set) - sta getBit_hold +getBit_samePage: + sec + ror a + sta getBit_buffer pla -getBit_ret: +getBit_return: + rts + +; Copy a previously written byte +copyByte: + ldy outputPointer + lda (inflateCodes_sourcePointer),y + ldy #0 +; Write a byte +storeByte: +; ldy #0 + sta (outputPointer),y + inc outputPointer + bne storeByte_return + inc outputPointer+1 + inc inflateCodes_sourcePointer+1 +storeByte_return: rts @@ -575,57 +487,17 @@ getBit_ret: ; .rodata -; -------------------------------------------------------------------------- -; Arrays for the temporary codes. -; Order, in which lengths of the temporary codes are stored. -tempCodeLengthOrder: - .byte 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 +getNPlus1Bits_mask: + .byte GET_1_BIT,GET_2_BITS,GET_3_BITS,GET_4_BITS,GET_5_BITS,GET_6_BITS,GET_7_BITS -; Base values. -tempBaseValue: - .byte 3,3,11 +inflateDynamic_tempSymbols: + .byte GET_2_BITS,GET_3_BITS,GET_7_BITS,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 -; Number of extra bits to read. -tempExtraBits: - .byte 2,3,7 - -; -------------------------------------------------------------------------- -; Arrays for the length and distance codes. - -; Base values. -lengthBaseValue_l: - .byte <3,<4,<5,<6,<7,<8,<9,<10 - .byte <11,<13,<15,<17,<19,<23,<27,<31 - .byte <35,<43,<51,<59,<67,<83,<99,<115 - .byte <131,<163,<195,<227,<258 -distanceBaseValue_l: - .byte <1,<2,<3,<4,<5,<7,<9,<13 - .byte <17,<25,<33,<49,<65,<97,<129,<193 - .byte <257,<385,<513,<769,<1025,<1537,<2049,<3073 - .byte <4097,<6145,<8193,<12289,<16385,<24577 -lengthBaseValue_h: - .byte >3,>4,>5,>6,>7,>8,>9,>10 - .byte >11,>13,>15,>17,>19,>23,>27,>31 - .byte >35,>43,>51,>59,>67,>83,>99,>115 - .byte >131,>163,>195,>227,>258 -distanceBaseValue_h: - .byte >1,>2,>3,>4,>5,>7,>9,>13 - .byte >17,>25,>33,>49,>65,>97,>129,>193 - .byte >257,>385,>513,>769,>1025,>1537,>2049,>3073 - .byte >4097,>6145,>8193,>12289,>16385,>24577 - -; Number of extra bits to read. -lengthExtraBits: - .byte 0,0,0,0,0,0,0,0 - .byte 1,1,1,1,2,2,2,2 - .byte 3,3,3,3,4,4,4,4 - .byte 5,5,5,5,0 -distanceExtraBits: - .byte 0,0,0,0,1,1,2,2 - .byte 3,3,4,4,5,5,6,6 - .byte 7,7,8,8,9,9,10,10 - .byte 11,11,12,12,13,13 +inflateDynamic_headerBits: + .byte GET_4_BITS,GET_5_BITS,GET_5_BITS +inflateDynamic_headerBase: + .byte 3,LENGTH_SYMBOLS,0 ; -------------------------------------------------------------------------- @@ -635,46 +507,28 @@ distanceExtraBits: .bss -; Number of literal codes of each length in the primary tree -; (MAX_BITS bytes, overlap with literalCodeLength). -literalCount: +; Data for building trees. -; -------------------------------------------------------------------------- -; Data for building the primary tree. - -; Lengths of literal codes. -literalCodeLength: +literalSymbolCodeLength: .res 256 -; Length of the end code. -endCodeLength: - .res 1 -; Lengths of length codes. -lengthCodeLength: - .res 29 +controlSymbolCodeLength: + .res CONTROL_SYMBOLS -; -------------------------------------------------------------------------- -; Data for building the distance tree. +; Huffman trees. -; Lengths of distance codes. -distanceCodeLength: - .res 30 -; For two unused codes in the fixed trees and an 'end' mark. - .res 3 +nBitCode_clearFrom: +nBitCode_totalCount: + .res 2*TREE_SIZE +nBitCode_literalCount: + .res TREE_SIZE +nBitCode_controlCount: + .res 2*TREE_SIZE +nBitCode_literalOffset: + .res TREE_SIZE +nBitCode_controlOffset: + .res 2*TREE_SIZE -; -------------------------------------------------------------------------- -; The Huffman trees. - -; Number of codes of each length. -bitsCount: - .res TREES_SIZE -; Pointers to sorted codes of each length. -bitsPointer_l: - .res TREES_SIZE+1 -bitsPointer_h: - .res TREES_SIZE - -; Sorted codes. -sortedCodes: - .res 256+1+29+30+2 - -.endif +codeToLiteralSymbol: + .res 256 +codeToControlSymbol: + .res CONTROL_SYMBOLS From 7e8bb7b700572a50ed4f1e87ebeea4fd35177459 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 12 Feb 2017 14:54:57 -0500 Subject: [PATCH 219/407] Fixed ca65's BRK instruction encoding for the 65816. BRK is two bytes on all 6502 variants; but, the 65816's maker declared officially that assemblers should support an optional operand. --- src/ca65/instr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ca65/instr.c b/src/ca65/instr.c index 5e7904992..53d3573a6 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -650,7 +650,7 @@ static const struct { { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BRA", 0x0020000, 0x80, 0, PutPCRel8 }, - { "BRK", 0x0000001, 0x00, 0, PutAll }, + { "BRK", 0x0000005, 0x00, 0, PutAll }, { "BRL", 0x0040000, 0x82, 0, PutPCRel16 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, From 1f12a06f7cc2ae79a800fe3faed727513364091b Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Mon, 13 Feb 2017 19:41:05 +0100 Subject: [PATCH 220/407] Disallow global variable declarations with an initializer. E.g. extern int i = 42; --- src/cc65/compile.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 9f1ab29f5..f01ddf6c5 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -144,17 +144,14 @@ static void Parse (void) ** ** - if it is not a typedef or function, ** - if we don't had a storage class given ("int i") - ** - if the storage class is explicitly specified as static, - ** - or if there is an initialization. + ** or the storage class is explicitly specified as static. ** ** This means that "extern int i;" will not get storage allocated. */ if ((Decl.StorageClass & SC_FUNC) != SC_FUNC && (Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF && ((Spec.Flags & DS_DEF_STORAGE) != 0 || - (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC || - ((Decl.StorageClass & SC_EXTERN) != 0 && - CurTok.Tok == TOK_ASSIGN))) { + (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC)) { /* We will allocate storage */ Decl.StorageClass |= SC_STORAGE | SC_DEF; From 730d01a25f3440bd5bdca3a3cf8068287ff52f6a Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Mon, 13 Feb 2017 21:04:45 +0100 Subject: [PATCH 221/407] Global uninitialized variable is only a tentative definition. Closes #204 --- src/cc65/compile.c | 55 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index f01ddf6c5..85a2e9939 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -154,7 +154,7 @@ static void Parse (void) (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC)) { /* We will allocate storage */ - Decl.StorageClass |= SC_STORAGE | SC_DEF; + Decl.StorageClass |= SC_STORAGE; } /* If this is a function declarator that is not followed by a comma @@ -187,6 +187,9 @@ static void Parse (void) /* Allow initialization */ if (CurTok.Tok == TOK_ASSIGN) { + /* This is a definition */ + Entry->Flags |= SC_DEF; + /* We cannot initialize types of unknown size, or ** void types in ISO modes. */ @@ -234,18 +237,14 @@ static void Parse (void) Entry->Flags &= ~(SC_STORAGE | SC_DEF); } - /* Allocate storage if it is still needed */ - if (Entry->Flags & SC_STORAGE) { - - /* Switch to the BSS segment */ - g_usebss (); - - /* Define a label */ - g_defgloblabel (Entry->Name); - - /* Allocate space for uninitialized variable */ - g_res (Size); - } + /* A global (including static) uninitialized variable + ** is only a tentative definition. For example, this is valid: + ** int i; + ** int i; + ** static int j; + ** static int j = 42; + ** Code for these will be generated in FinishCompile. + */ } } @@ -300,7 +299,7 @@ void Compile (const char* FileName) struct tm* TM; /* Since strftime is locale dependent, we need the abbreviated month names - ** in english. + ** in English. */ static const char MonthNames[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", @@ -397,20 +396,26 @@ void Compile (const char* FileName) void FinishCompile (void) /* Emit literals, externals, debug info, do cleanup and optimizations */ { - SymTable* SymTab; - SymEntry* Func; + SymEntry* Entry; - /* Walk over all functions, doing cleanup, optimizations ... */ - SymTab = GetGlobalSymTab (); - Func = SymTab->SymHead; - while (Func) { - if (SymIsOutputFunc (Func)) { + /* Walk over all global symbols: + ** - for functions do cleanup, optimizations ... + ** - generate code for uninitialized global variables + */ + for (Entry = GetGlobalSymTab ()->SymHead; Entry; Entry = Entry->NextSym) { + if (SymIsOutputFunc (Entry)) { /* Function which is defined and referenced or extern */ - MoveLiteralPool (Func->V.F.LitPool); - CS_MergeLabels (Func->V.F.Seg->Code); - RunOpt (Func->V.F.Seg->Code); + MoveLiteralPool (Entry->V.F.LitPool); + CS_MergeLabels (Entry->V.F.Seg->Code); + RunOpt (Entry->V.F.Seg->Code); + } else if ((Entry->Flags & (SC_STORAGE | SC_DEF | SC_STATIC)) == (SC_STORAGE | SC_STATIC)) { + /* Tentative definition of uninitialized global variable */ + g_usebss (); + g_defgloblabel (Entry->Name); + g_res (SizeOf (Entry->Type)); + /* Mark as defined, so that it will be exported not imported */ + Entry->Flags |= SC_DEF; } - Func = Func->NextSym; } /* Output the literal pool */ From 31f19fbc6579a57186cc44e06e8494a34b9de057 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Mon, 13 Feb 2017 21:10:21 +0100 Subject: [PATCH 222/407] Issue an error for duplicate global variables. Previously it was an assembler error. --- src/cc65/compile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 85a2e9939..9cdeaf7e5 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -188,6 +188,10 @@ static void Parse (void) if (CurTok.Tok == TOK_ASSIGN) { /* This is a definition */ + if (SymIsDef (Entry)) { + Error ("Global variable `%s' has already been defined", + Entry->Name); + } Entry->Flags |= SC_DEF; /* We cannot initialize types of unknown size, or From ccdbb2b0e64f04004b90059c00e486411153d985 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 13 Feb 2017 22:43:26 +0100 Subject: [PATCH 223/407] Add testcode/lib/mouse-test.c. Rename samples/mousetest.c to mousedemo.c. mouse-test.c can be use to test all available mouse drivers for a given target. Currently supported targets are Atari, C64, and C128. To avoid confusion, rename samples/mousetest.c to mousedemo.c. --- samples/Makefile | 12 +- samples/README | 4 +- samples/{mousetest.c => mousedemo.c} | 4 +- testcode/lib/mouse-test.c | 431 +++++++++++++++++++++++++++ 4 files changed, 441 insertions(+), 10 deletions(-) rename samples/{mousetest.c => mousedemo.c} (98%) create mode 100644 testcode/lib/mouse-test.c diff --git a/samples/Makefile b/samples/Makefile index abd304b14..edfeca689 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -66,8 +66,8 @@ LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000 LDFLAGS_tgidemo_apple2 = --start-addr 0x4000 LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000 -# The Apple ][ needs the start address adjusted for the mousetest -LDFLAGS_mousetest_apple2 = --start-addr 0x4000 +# The Apple ][ needs the start address adjusted for the mousedemo +LDFLAGS_mousedemo_apple2 = --start-addr 0x4000 # The Apple machines need the end address adjusted for large programs LDFLAGS_gunzip65_apple2 = -D __HIMEM__=0xBF00 @@ -111,7 +111,7 @@ EXELIST_c64 = \ gunzip65 \ hello \ mandelbrot \ - mousetest \ + mousedemo \ multdemo \ nachtm \ ovrldemo \ @@ -126,7 +126,7 @@ EXELIST_apple2 = \ gunzip65 \ hello \ mandelbrot \ - mousetest \ + mousedemo \ multdemo \ ovrldemo \ sieve \ @@ -139,7 +139,7 @@ EXELIST_atari = \ gunzip65 \ hello \ mandelbrot \ - mousetest \ + mousedemo \ multdemo \ ovrldemo \ sieve \ @@ -147,7 +147,7 @@ EXELIST_atari = \ EXELIST_atarixl = $(EXELIST_atari) -EXELIST_atari2600 = \ +EXELIST_atari2600 = \ atari2600hello # -------------------------------------------------------------------------- diff --git a/samples/README b/samples/README index a576c4032..88a6021c8 100644 --- a/samples/README +++ b/samples/README @@ -69,8 +69,8 @@ Platforms: Runs on all platforms that have TGI support: Apple ][, C64, C128, Oric Atmos, Geos and Lynx. ----------------------------------------------------------------------------- -Name: mousetest -Description: Tests and shows how to use the mouse. +Name: mousedemo +Description: Shows how to use the mouse. Platforms: All systems with mouse and conio support: C64, C128, CBM510, Atari, Apple ][ diff --git a/samples/mousetest.c b/samples/mousedemo.c similarity index 98% rename from samples/mousetest.c rename to samples/mousedemo.c index 3910d5a0a..d1b48e9ee 100644 --- a/samples/mousetest.c +++ b/samples/mousedemo.c @@ -1,6 +1,6 @@ /* -** Test/demo program for mouse usage. -** Will work for the C64/C128/CBM510/Atari/Apple2. +** Demo program for mouse usage. +** Supports the C64/C128/CBM510/Atari/Apple2. ** ** 2001-09-13, Ullrich von Bassewitz ** 2013-09-05, Greg King diff --git a/testcode/lib/mouse-test.c b/testcode/lib/mouse-test.c new file mode 100644 index 000000000..2e316c4c6 --- /dev/null +++ b/testcode/lib/mouse-test.c @@ -0,0 +1,431 @@ +/* +** Test program for mouse drivers. +** Supportsthe C64/C128/CBM510/Atari/Apple2. +** +** 2001-09-13, Ullrich von Bassewitz +** 2013-09-05, Greg King +** +** Compile with "-DSTATIC_MOUSE" to statically link all available drivers. +** Compile with "-DMOUSE_DRIVER=<driver_sym>" to statically link the given driver. +** E.g., -DMOUSE_DRIVER=atrsts_mou to just link with the Atari ST mouse driver. +*/ + + + +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <mouse.h> +#include <pen.h> +#include <conio.h> +#include <ctype.h> +#include <dbg.h> +#include <cc65.h> + +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) + +extern int getsp(void); + +#define NO_DEBUG +#define NO_JAIL + +#ifdef __ATARI__ +extern const struct mouse_callbacks mouse_pm_callbacks; +extern const struct mouse_callbacks mouse_txt_callbacks; +//#define MOUSE_CALLBACK mouse_def_callbacks +#define MOUSE_CALLBACK mouse_pm_callbacks +//#define MOUSE_CALLBACK mouse_txt_callbacks +#else +#define MOUSE_CALLBACK mouse_def_callbacks +#endif + +#if defined(MOUSE_DRIVER) || defined(STATIC_MOUSE) + +/* A statically linked driver was named on the compiler's command line. +** Make sure that it is used instead of a dynamic one. +*/ +# undef DYN_DRV +# define DYN_DRV 0 +#else + +/* Use a dynamically loaded driver, by default. */ +# ifndef DYN_DRV +# define DYN_DRV 1 +# endif +#endif + + + +#ifdef __CBM__ + +/* Set dark-on-light colors. */ +const unsigned char mouse_def_pointercolor = COLOR_BLACK; + +#endif + + + +static void __fastcall__ CheckError (const char* S, unsigned char Error) +{ + if (Error != MOUSE_ERR_OK) { + cprintf ("\n%s: %s(%u)\r\n", S, mouse_geterrormsg (Error), Error); + + /* Wait for a key-press, so that some platforms can show the error + ** message before they remove the current screen. + */ + if (doesclrscrafterexit ()) { + cgetc (); + } + exit (EXIT_FAILURE); + } +} + + + +#if DYN_DRV + +/* Points to the dynamic driver's name. */ +static const char *mouse_name; + + +static void DoWarning (void) +/* Warn the user that a driver is needed for this program. */ +{ + cprintf ("Warning: This program needs\r\n" + "the driver with the name\r\n" + " %s\r\n" + "on a disk! Press 'y' if you have it;\r\n" + "or, any other key to exit.\r\n", mouse_stddrv); + if (tolower (cgetc ()) != 'y') { + exit (EXIT_SUCCESS); + } + cprintf ("OK. Please wait patiently...\r\n"); +} + +#else + +unsigned char *mouse_drv_use; +#endif + + +#ifdef __ATARI__ +#ifdef __ATARIXL__ +#define MSENAME_EXT "X" +#define MSESTAT_0 atrxjoy_mou +#define MSESTAT_1 atrxst_mou +#define MSESTAT_2 atrxami_mou +#define MSESTAT_3 atrxtrk_mou +#define MSESTAT_4 atrxtt_mou +#else +#define MSENAME_EXT "" +#define MSESTAT_0 atrjoy_mou +#define MSESTAT_1 atrst_mou +#define MSESTAT_2 atrami_mou +#define MSESTAT_3 atrtrk_mou +#define MSESTAT_4 atrtt_mou +#endif +#define MSENAME_0 "ATR" MSENAME_EXT "JOY.MOU" +#define MSENAME_1 "ATR" MSENAME_EXT "ST.MOU" +#define MSENAME_2 "ATR" MSENAME_EXT "AMI.MOU" +#define MSENAME_3 "ATR" MSENAME_EXT "TRK.MOU" +#define MSENAME_4 "ATR" MSENAME_EXT "TT.MOU" +#elif defined(__C64__) || defined(__C128__) +#ifdef __C64__ +#define MSENAME_EXT "c64-" +#define MSESTAT_0 c64_joy_mou +#define MSESTAT_1 c64_1351_mou +#define MSESTAT_2 c64_inkwell_mou +#define MSESTAT_3 c64_pot_mou +#else +#define MSENAME_EXT "c128-" +#define MSESTAT_0 c128_joy_mou +#define MSESTAT_1 c128_1351_mou +#define MSESTAT_2 c128_inkwell_mou +#define MSESTAT_3 c128_pot_mou +#endif +#define MSENAME_0 MSENAME_EXT "joy.mou" +#define MSENAME_1 MSENAME_EXT "1351.mou" +#define MSENAME_2 MSENAME_EXT "inkwell.mou" +#define MSENAME_3 MSENAME_EXT "pot.mou" +#endif + + +static void __fastcall__ ShowState (unsigned char Jailed, unsigned char Invisible) +/* Display jail and cursor states. */ +{ + cclearxy (0, 7, 32); + gotoxy (0, 7); + cprintf ("Pointer is %svisible%s.", Invisible? "in" : "", Jailed? " and jailed" : ""); +} + +#ifdef __ATARIXL__ +extern char _HIDDEN_RAM_SIZE__, _HIDDEN_RAM_LAST__, _HIDDEN_RAM_START__; +#endif + +#if DYN_DRV +int main (int argc, char *argv[]) +#else +int main (void) +#endif +{ + struct mouse_info info; + struct mouse_box full_box, small_box; + unsigned char width, height; + char C; + bool Invisible = true, Done = false, Jailed = false; + +#ifdef __ATARIXL__ + cprintf ("adding heap: $%04X bytes at $%04X\r\n", + &_HIDDEN_RAM_SIZE__ - (&_HIDDEN_RAM_LAST__ - &_HIDDEN_RAM_START__), + &_HIDDEN_RAM_LAST__); + + _heapadd (&_HIDDEN_RAM_LAST__, (size_t)(&_HIDDEN_RAM_SIZE__ - (&_HIDDEN_RAM_LAST__ - &_HIDDEN_RAM_START__))); + cgetc (); +#endif + +#ifndef NO_DEBUG + /* Initialize the debugger */ + DbgInit (0); +#endif + + /* Set dark-on-light colors. Clear the screen. */ +#ifdef __CBM__ + (void) bordercolor (COLOR_GRAY2); + (void) bgcolor (COLOR_WHITE); + (void) textcolor (COLOR_GRAY1); +#else + (void) bordercolor (COLOR_BLUE); + (void) bgcolor (COLOR_WHITE); + (void) textcolor (COLOR_BLACK); +#endif + cursor (0); + clrscr (); + + /* If a lightpen driver is installed, then it can get a calibration value + ** from this file (if it exists). Or, the user can adjust the pen; and, + ** the value will be put into this file, for the next time. + ** (Other drivers will ignore this.) + */ +#if defined(__C64__) || defined(__C128__) || defined(__CBM510__) + pen_adjust ("pen.dat"); +#endif + +#if DYN_DRV + /* If a dynamically loadable driver is named on the command line, + ** then use that driver instead of the standard one. + */ + if (argc > 1) { + mouse_name = argv[1]; + } else { +#if defined(__ATARI__) || defined(__C64__) || defined(__C128__) + char selection, flag = 0; + cprintf ("Select mouse driver:\r\n" + " 0 - Joystick\r\n" +#ifdef __ATARI__ + " 1 - ST Mouse\r\n" + " 2 - Amiga Mouse\r\n" + " 3 - Atari Trakball\r\n" + " 4 - Atari TouchPad\r\n" +#else + " 1 - 1351 Mouse\r\n" + " 2 - Inkwell Mouse\r\n" + " 3 - Paddle\r\n" +#endif + "Enter selection: "); + while (1) { + switch (selection = cgetc ()) { + case '0': mouse_name = MSENAME_0; flag = 1; break; + case '1': mouse_name = MSENAME_1; flag = 1; break; + case '2': mouse_name = MSENAME_2; flag = 1; break; + case '3': mouse_name = MSENAME_3; flag = 1; break; +#ifdef __ATARI__ + case '4': mouse_name = MSENAME_4; flag = 1; break; +#endif + } + if (flag) break; + } + cprintf ("%c\r\nOK, loading \"%s\",\r\nplease wait patiently...\r\n", selection, mouse_name); +#else + /* Output a warning about the standard driver that is needed. */ + DoWarning (); + mouse_name = mouse_stddrv; +#endif + } + + /* Load and install the driver. */ + CheckError ("mouse_load_driver", + mouse_load_driver (&MOUSE_CALLBACK, mouse_name)); +#else /* not DYN_DRV */ +#if !defined(MOUSE_DRIVER) && (defined(__ATARI__) || defined(__C64__) || defined(__C128__)) + { + char selection, flag = 0; + cprintf ("Select mouse driver:\r\n" + " 0 - Joystick\r\n" +#ifdef __ATARI__ + " 1 - ST Mouse\r\n" + " 2 - Amiga Mouse\r\n" + " 3 - Atari Trakball\r\n" + " 4 - Atari TouchPad\r\n" +#else + " 1 - 1351 Mouse\r\n" + " 2 - Inkwell Mouse\r\n" + " 3 - Paddle\r\n" +#endif + "Enter selection: "); + while (1) { + switch (selection = cgetc ()) { + case '0': mouse_drv_use = MSESTAT_0; flag = 1; break; + case '1': mouse_drv_use = MSESTAT_1; flag = 1; break; + case '2': mouse_drv_use = MSESTAT_2; flag = 1; break; + case '3': mouse_drv_use = MSESTAT_3; flag = 1; break; +#ifdef __ATARI__ + case '4': mouse_drv_use = MSESTAT_4; flag = 1; break; +#endif + } + if (flag) break; + } + } +#else + mouse_drv_use = mouse_static_stddrv; +#endif + + /* Install the driver. */ + CheckError ("mouse_install", + mouse_install (&MOUSE_CALLBACK, +# ifdef MOUSE_DRIVER + MOUSE_DRIVER +# else +#if defined(__ATARI__) || defined(__C64__) || defined(__C128__) + mouse_drv_use +#else + mouse_static_stddrv +#endif +# endif + )); +#endif + +#ifndef NO_JAIL + /* Get the initial bounding box. */ + mouse_getbox (&full_box); +#endif + + screensize (&width, &height); + +top: + clrscr (); + + /* Print a help line */ + cputs (" d)ebug h)ide q)uit s)how j)ail"); + + gotoxy (1, 20); + cprintf ("SP: $%04X", getsp()); + + /* Put a cross at the center of the screen. */ + gotoxy (width / 2 - 3, height / 2 - 1); +#if defined(__CBM__) + cprintf ("%3u,%3u\r\n%*s\xDB", width / 2 * 8 + 4, height / 2 * 8 + 4, + width / 2, ""); +#else + cprintf ("%3u,%3u\r\n%*s+", width / 2 * 8 + 4, height / 2 * 8 + 4, + width / 2, ""); +#endif + + /* Test loop */ + ShowState (Jailed, Invisible); + do { + /* Get the current co-ordinates and button states; and, print them. */ + mouse_info (&info); + gotoxy (0, 2); + cprintf (" X = %3d\r\n", info.pos.x); + cprintf (" Y = %3d\r\n", info.pos.y); + cprintf (" B1 = %c\r\n", (info.buttons & MOUSE_BTN_LEFT) ? +#ifdef __CBM__ + 0x5F +#else + 'v' +#endif + : '^'); + cprintf (" B2 = %c", (info.buttons & MOUSE_BTN_RIGHT) ? +#ifdef __CBM__ + 0x5F +#else + 'v' +#endif + : '^'); + + /* Handle user input */ + if (kbhit ()) { + cclearxy (1, 9, 23); + switch (tolower (C = cgetc ())) { +#ifndef NO_DEBUG + case 'd': + BREAK(); + + /* The debugger might have changed the colors. + ** Restore them. + */ +#ifdef __CBM__ + (void) bordercolor (COLOR_GRAY2); + (void) bgcolor (COLOR_WHITE); + (void) textcolor (COLOR_GRAY1); +#else + (void) bordercolor (COLOR_BLUE); + (void) bgcolor (COLOR_WHITE); + (void) textcolor (COLOR_BLACK); +#endif + + /* The debugger changed the screen; restore it. */ + goto top; +#endif + case 'h': + mouse_hide (); + ShowState (Jailed, ++Invisible); + break; + +#ifndef NO_JAIL + case 'j': + if (Jailed) { + mouse_setbox (&full_box); + Jailed = false; + } else { + small_box.minx = max (info.pos.x - 10, full_box.minx); + small_box.miny = max (info.pos.y - 10, full_box.miny); + small_box.maxx = min (info.pos.x + 10, full_box.maxx); + small_box.maxy = min (info.pos.y + 10, full_box.maxy); + mouse_setbox (&small_box); + Jailed = true; + } + ShowState (Jailed, Invisible); + break; +#endif + case 's': + mouse_show (); + if (Invisible) { + ShowState (Jailed, --Invisible); + } + break; + + case 'q': + Done = true; + break; + + default: + gotoxy (1, 9); + cprintf ("Spurious character: $%02X", C); + } + } + } while (!Done); + +#if DYN_DRV + /* Uninstall and unload the driver. */ + CheckError ("mouse_unload", mouse_unload ()); +#else + /* Uninstall the static driver. */ + CheckError ("mouse_uninstall", mouse_uninstall ()); +#endif + + /* Say goodbye */ + cputsxy (0, height / 2 + 3, "Goodbye!"); + return EXIT_SUCCESS; +} From c0803ed53ac5113b8065e07a0c91eebf507975f5 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 14 Feb 2017 23:52:44 +0100 Subject: [PATCH 224/407] fix indentation --- libsrc/creativision/cputc.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/creativision/cputc.s b/libsrc/creativision/cputc.s index 208009ebd..ff60494b9 100644 --- a/libsrc/creativision/cputc.s +++ b/libsrc/creativision/cputc.s @@ -50,7 +50,7 @@ advance: iny cpy #SCREEN_COLS bne L3 - inc CURSOR_Y ; new line + inc CURSOR_Y ; new line ldy #0 ; + cr L3: sty CURSOR_X jmp plot From b858b0d6230d263dedec8e741b01cd8a5602cb59 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 15 Feb 2017 15:37:06 +0100 Subject: [PATCH 225/407] Add joystick driver to documentation. --- doc/creativision.sgml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/creativision.sgml b/doc/creativision.sgml index 5b69da75a..64623b3b2 100644 --- a/doc/creativision.sgml +++ b/doc/creativision.sgml @@ -66,7 +66,6 @@ Programs containing Creativision specific code may use the <tt/creativision.h/ h <itemize> <item>bios_playsound -<item>joystate <item>psg_delay <item>psg_outb <item>psg_silence @@ -109,8 +108,12 @@ No extended memory drivers are currently available for the Creativision. <sect1>Joystick drivers<p> -No joystick drivers are currently available for the Creativision but <tt/joystate()/. +<descrip> + <tag><tt/creativision-stdjoy.joy (creativisionstd_joy)/</tag> + A joystick driver for the standard joystick is available. + +</descrip><p> <sect1>Mouse drivers<p> From e6530d68dd51c9c310b7a9aa346bb19d126b4910 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 15 Feb 2017 15:45:49 +0100 Subject: [PATCH 226/407] Fix joystick driver. Add interruptor support. Note that the joystick driver doesn't support combined movements (like left/up or right/down). This should be fixed. --- asminc/creativision.inc | 4 + include/creativision.h | 65 +++++++++------- libsrc/creativision/crt0.s | 8 +- libsrc/creativision/irq.s | 40 ++++++++++ libsrc/creativision/joy/creativision-stdjoy.s | 76 ++++++++++--------- testcode/lib/joy-test.c | 12 +-- 6 files changed, 132 insertions(+), 73 deletions(-) create mode 100644 libsrc/creativision/irq.s diff --git a/asminc/creativision.inc b/asminc/creativision.inc index bd30bc462..59b26101b 100644 --- a/asminc/creativision.inc +++ b/asminc/creativision.inc @@ -36,3 +36,7 @@ ZP_JOY1_DIR = $13 ZP_JOY0_BUTTONS = $16 ZP_JOY1_BUTTONS = $17 +;** BIOS +BIOS_IRQ1_ADDR = $FF3F +BIOS_IRQ2_ADDR = $FF52 +BIOS_NMI_RESET_ADDR = $F808 diff --git a/include/creativision.h b/include/creativision.h index adaa1caab..5cc99b7af 100644 --- a/include/creativision.h +++ b/include/creativision.h @@ -1,9 +1,38 @@ -/* CreatiVision Header */ +/*****************************************************************************/ +/* */ +/* creativision.h */ +/* */ +/* Creativision system specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2013 cvemu */ +/* (C) 2017 Christian Groessler <chris@groessler.org> */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ #ifndef _CVISION_H - #define _CVISION_H +/* Character codes */ #define CH_VLINE 33 #define CH_HLINE 34 #define CH_ULCORNER 35 @@ -11,12 +40,13 @@ #define CH_LLCORNER 37 #define CH_LRCORNER 38 +/* no support for dynamically loadable drivers */ #define DYN_DRV 0 /* Colours - from TMS9918 */ #define C_TRANSPARENT 0 #define C_BLACK 1 -#define C_MED_GREEN 2 +#define C_MED_GREEN 2 #define C_LIGHT_GREEN 3 #define C_DARK_BLUE 4 #define C_LIGHT_BLUE 5 @@ -31,29 +61,10 @@ #define C_GREY 14 #define C_WHITE 15 -/* Joystick states */ -#define JOY_UP 5 -#define JOY_DOWN 1 -#define JOY_LEFT 7 -#define JOY_RIGHT 3 -#define JOY_LEFT_UP 6 -#define JOY_LEFT_DOWN 8 -#define JOY_RIGHT_UP 4 -#define JOY_RIGHT_DOWN 2 -#define JOY_LBUTTON 1 -#define JOY_RBUTTON 2 - -/* Joystick values */ -#define JOY_LEFT_DIR 1 -#define JOY_RIGHT_DIR 2 -#define JOY_LEFT_BUTTONS 3 -#define JOY_RIGHT_BUTTONS 4 - /* Protos */ -void __fastcall__ psg_outb( unsigned char b ); -void __fastcall__ psg_delay( unsigned char b ); -void psg_silence( void ); -void __fastcall__ bios_playsound( void *a, unsigned char b); -unsigned char __fastcall__ joystate( unsigned char which ); +void __fastcall__ psg_outb(unsigned char b); +void __fastcall__ psg_delay(unsigned char b); +void psg_silence(void); +void __fastcall__ bios_playsound(void *a, unsigned char b); -#endif +#endif /* #ifndef _CVISION_H */ diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s index ccae38e81..6faec38eb 100644 --- a/libsrc/creativision/crt0.s +++ b/libsrc/creativision/crt0.s @@ -4,11 +4,13 @@ .export _exit .export __STARTUP__ : absolute = 1 ; Mark as startup + .export irq2 .import zerobss, copydata .import initlib, donelib, callmain .import __VECTORS_LOAD__, __VECTORS_RUN__, __VECTORS_SIZE__ .import __ZP_LAST__, __STACKSIZE__, __RAM_START__ + .include "creativision.inc" .include "zeropage.inc" ; ------------------------------------------------------------------------ @@ -61,8 +63,8 @@ loop: jmp loop .segment "VECTORS" -irq1: jmp $FF3F -irq2: jmp $FF52 +irq1: jmp BIOS_IRQ1_ADDR +irq2: jmp BIOS_IRQ2_ADDR ; ------------------------------------------------------------------------ ; Define CART setup values for BIOS. @@ -92,7 +94,7 @@ irq2: jmp $FF52 ; BIOS Vector after NMI or RESET ; Keeping with retail cartridges, we jump back to BIOS ROM and have it ; setup zeropage etc, and show the Creativision logo and copyright. - .addr $F808 + .addr BIOS_NMI_RESET_ADDR ; BIOS Short Interrupt Handler ; Vectored from BIOS ROM:FE2C. This should contain a pointer to the user's diff --git a/libsrc/creativision/irq.s b/libsrc/creativision/irq.s new file mode 100644 index 000000000..f154c9199 --- /dev/null +++ b/libsrc/creativision/irq.s @@ -0,0 +1,40 @@ +; +; IRQ handling (CreatiVision version) +; + + .export initirq, doneirq + .import callirq, irq2 + + .include "creativision.inc" + +; ------------------------------------------------------------------------ + +.segment "ONCE" + +initirq: + lda #<IRQStub + ldx #>IRQStub + jmp setvec + +; ------------------------------------------------------------------------ + +.code + +doneirq: + lda #<BIOS_IRQ2_ADDR + ldx #>BIOS_IRQ2_ADDR +setvec: sei + sta irq2+1 + stx irq2+2 + cli + rts + +; ------------------------------------------------------------------------ + +.segment "CODE" + +IRQStub: + cld ; Just to be sure + jsr callirq ; Call the functions + jmp BIOS_IRQ2_ADDR ; Jump to the BIOS IRQ vector + diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s index f24a8045b..37b927d08 100644 --- a/libsrc/creativision/joy/creativision-stdjoy.s +++ b/libsrc/creativision/joy/creativision-stdjoy.s @@ -49,7 +49,7 @@ ; ------------------------------------------------------------------------ ; Constants -JOY_COUNT = 2 ; Number of joysticks we support +JOY_COUNT = 2 ; Number of joysticks we support ; ------------------------------------------------------------------------ ; Code @@ -66,7 +66,7 @@ JOY_COUNT = 2 ; Number of joysticks we support INSTALL: lda #JOY_ERR_OK ldx #0 -; rts ; Fall through +; rts ; Fall through ; ------------------------------------------------------------------------ ; UNINSTALL routine. Is called before the driver is removed from memory. @@ -91,14 +91,14 @@ COUNT: ; READJOY: - and #1 ; fix joystick number - bne READJOY_1 ; read right joystick + and #1 ; fix joystick number + bne READJOY_1 ; read right joystick ; Read left joystick ldx ZP_JOY0_DIR lda ZP_JOY0_BUTTONS - jmp convert ; convert joystick state to sane cc65 values + jmp convert ; convert joystick state to sane cc65 values ; Read right joystick @@ -108,8 +108,8 @@ READJOY_1: lda ZP_JOY1_BUTTONS lsr a lsr a - ;jmp convert ; convert joystick state to sane cc65 values - ; fall thru... + ;jmp convert ; convert joystick state to sane cc65 values + ; fall thru... ; ------------------------------------------------------------------------ ; convert: make runtime lib compatible values @@ -119,7 +119,7 @@ READJOY_1: convert: ldy #0 - sty retval ; initialize return value + sty retval ; initialize return value ; ------ ; buttons: @@ -127,7 +127,7 @@ convert: ; values were shifted to the right to be identical). ; Why are there two bits indicating a pressed trigger? ; According to the "Second book of programs for the Dick Smith Wizard" - ; (pg. 88ff), the left hand fire button gives the value of + ; (pg. 88ff), the left hand fire button gives the value of ; %00010001 and the right hand button gives %00100010 ; Why two bits? Am I missing something? Can there be cases that just ; one of those bits is set? @@ -137,7 +137,7 @@ convert: and #%00010001 beq cnv_1 - inc retval ; left button pressed + inc retval ; left button pressed cnv_1: tya and #%00100010 @@ -145,45 +145,47 @@ cnv_1: tya lda #$02 ora retval - sta retval ; right button pressed + sta retval ; right button pressed ; ------ ; direction: cnv_2: txa - ; tested with https://sourceforge.net/projects/creativisionemulator - ; $49 - %01001001 - up - ; $41 - %01000001 - down - ; $4D - %01001101 - left - ; $45 - %01000101 - right - ; - ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different - ; ignored for now... - ; $85 - %10000101 - up + right - ; $8D - %10001101 - down + left - ; $89 - %10001001 - up + left - ; $85 - %10000101 - down + right (emulator bug?) + ; tested with https://sourceforge.net/projects/creativisionemulator + ; $49 - %01001001 - up + ; $41 - %01000001 - down + ; $4D - %01001101 - left + ; $45 - %01000101 - right + ; + ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different + ; ignored for now... + ; $85 - %10000101 - up + right + ; $8D - %10001101 - down + left + ; $89 - %10001001 - up + left + ; $85 - %10000101 - down + right (emulator bug?) - bit testbit ; bit #0 set? - beq done ; no, no direction + bit testbit ; bit #0 set? + beq done ; no, no direction - and #%00001100 ; mask out other bits - tax - lda #%00000100 ; init bitmask -loop: dex - bmi done2 - asl a - bne loop + and #%00001100 ; mask out other bits + lsr a + lsr a + tax + lda #%00000100 ; init bitmask +loop: dex + bmi done2 + asl a + bne loop -done2: ora retval - rts +done2: ora retval + rts -done: lda retval - rts +done: lda retval + rts ; ------------------------------------------------------------------------ ; .data -testbit:.byte $01 +testbit:.byte $01 ; ------------------------------------------------------------------------ ; diff --git a/testcode/lib/joy-test.c b/testcode/lib/joy-test.c index 0a5c80902..fc751ebdc 100644 --- a/testcode/lib/joy-test.c +++ b/testcode/lib/joy-test.c @@ -46,7 +46,7 @@ int main (void) clrscr (); count = joy_count (); -#ifdef __ATARI5200__ +#if defined(__ATARI5200__) || defined(__CREATIVISION__) cprintf ("JOYSTICKS: %d", count); #else cprintf ("Driver supports %d joystick(s)", count); @@ -55,13 +55,13 @@ int main (void) for (i = 0; i < count; ++i) { gotoxy (0, i+1); j = joy_read (i); -#ifdef __ATARI5200__ +#if defined(__ATARI5200__) || defined(__CREATIVISION__) cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s%-3s", i, - (j & joy_masks[JOY_UP])? " U " : " u ", - (j & joy_masks[JOY_DOWN])? " D " : " d ", - (j & joy_masks[JOY_LEFT])? " L " : " l ", - (j & joy_masks[JOY_RIGHT])? " R " : " r ", + (j & joy_masks[JOY_UP])? " U " : " ", + (j & joy_masks[JOY_DOWN])? " D " : " ", + (j & joy_masks[JOY_LEFT])? " L " : " ", + (j & joy_masks[JOY_RIGHT])? " R " : " ", (j & joy_masks[JOY_FIRE])? " 1 " : " ", (j & joy_masks[JOY_FIRE2])? " 2 " : " "); #else From ddae920ee9e7cbfc3b9cd7fc8319102fe8ca3a62 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 15 Feb 2017 15:53:57 +0100 Subject: [PATCH 227/407] remove old joystick code --- libsrc/creativision/joy.s | 58 --------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 libsrc/creativision/joy.s diff --git a/libsrc/creativision/joy.s b/libsrc/creativision/joy.s deleted file mode 100644 index eb0bc6594..000000000 --- a/libsrc/creativision/joy.s +++ /dev/null @@ -1,58 +0,0 @@ -;* -;* Creativision Joystick Function -;* -;* unsigned char __fastcall__ joystate(unsigned char joy); -;* -;* JOY_1 -> Return Left Joystick direction -;* JOY_2 -> Return Right Joystick direction -;* JOY_3 -> Return Left Joystick buttons -;* JOY_4 -> Return Right Joystick buttons -;* -;* Will only work if interrupts are enabled. - - .export _joystate - .include "creativision.inc" - -_joystate: - cmp #1 ; Left Direction - bne l1 - - lda $11 - beq l5 - and #$0F - lsr a - tax - inx - txa - rts - -l1: cmp #2 ; Right Direction - bne l2 - - lda $13 - beq l5 - and #$0F - lsr a - tax - inx - txa - rts - -l2: cmp #3 ; Left Buttons - bne l3 - - lda $16 - beq l5 - and #$0F - rts - -l3: cmp #4 - bne l4 - - lda $17 - beq l5 - and #$0F - rts - -l4: lda #0 -l5: rts From 5988ec37cdce1655b14159a3a20a5493ba5459fd Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Wed, 15 Feb 2017 18:51:27 +0100 Subject: [PATCH 228/407] Revert "Disallow global variable declarations with an initializer." This reverts commit 1f12a06f7cc2ae79a800fe3faed727513364091b. --- src/cc65/compile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 9cdeaf7e5..48a5c29d3 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -144,14 +144,17 @@ static void Parse (void) ** ** - if it is not a typedef or function, ** - if we don't had a storage class given ("int i") - ** or the storage class is explicitly specified as static. + ** - if the storage class is explicitly specified as static, + ** - or if there is an initialization. ** ** This means that "extern int i;" will not get storage allocated. */ if ((Decl.StorageClass & SC_FUNC) != SC_FUNC && (Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF && ((Spec.Flags & DS_DEF_STORAGE) != 0 || - (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC)) { + (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC || + ((Decl.StorageClass & SC_EXTERN) != 0 && + CurTok.Tok == TOK_ASSIGN))) { /* We will allocate storage */ Decl.StorageClass |= SC_STORAGE; From 39d655278da511dee9e6acb0bc94d88ff80ac006 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 15 Feb 2017 16:09:21 -0500 Subject: [PATCH 229/407] Added "telestrat.html" to index. Sorted "gamate.html". --- doc/index.sgml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/index.sgml b/doc/index.sgml index 2a5c8894f..99b4f10b5 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -3,7 +3,7 @@ <article> <title>cc65 Documentation Overview <author><url url="http://cc65.github.io/doc"> -<date> +<date>2017-02-15 <sect>Program documentation<p> @@ -58,7 +58,7 @@ <tag><htmlurl url="coding.html" name="coding.html"></tag> Contains hints on creating the most effective code with cc65. - + <tag><htmlurl url="cc65-intern.html" name="cc65-intern.html"></tag> Describes internal details of cc65, such as calling conventions. @@ -143,6 +143,9 @@ <tag><htmlurl url="creativision.html" name="creativision.html"></tag> Topics specific to the Creativision Console. + <tag><htmlurl url="gamate.html" name="gamate.html"></tag> + Topics specific to the Bit Corporation Gamate Console. + <tag><htmlurl url="lynx.html" name="lynx.html"></tag> Topics specific to the Atari Lynx Game Console. @@ -155,9 +158,6 @@ <tag><htmlurl url="pce.html" name="pce.html"></tag> Topics specific to NEC PC-Engine (TurboGrafx) Console. - <tag><htmlurl url="gamate.html" name="gamate.html"></tag> - Topics specific to Bit Corporation Gamate Console. - <tag><htmlurl url="pet.html" name="pet.html"></tag> Topics specific to the Commodore PET machines. @@ -167,6 +167,9 @@ <tag><htmlurl url="supervision.html" name="supervision.html"></tag> Topics specific to the Watara Supervision Console. + <tag><htmlurl url="telestrat.html" name="telestrat.html"></tag> + Topics specific to the Oric Telestrat. + <tag><htmlurl url="vic20.html" name="vic20.html"></tag> Topics specific to the Commodore VIC20. From bb27d8d14ec6768424755694b47d91feb0014aa4 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 22 Feb 2017 14:25:10 +0100 Subject: [PATCH 230/407] README.md: PC-Engine is a console --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8914c45a..fa8c4df60 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ including - the Atari 5200 console. - GEOS for the C64, C128 and Apple //e. - the Bit Corporation Gamate console. -- the NEC PC-Engine (aka TurboGrafx-16). +- the NEC PC-Engine (aka TurboGrafx-16) console. - the Nintendo Entertainment System (NES) console. - the Watara Supervision console. - the VTech Creativision console. From ae7fa8f2ea25dbd96a062284ef77ff7b15423489 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Fri, 24 Feb 2017 00:10:02 +0100 Subject: [PATCH 231/407] Improved display list instruction definition for more comfortable use within void data definition. --- doc/atari.sgml | 43 ++++++++++++++++++++ include/_antic.h | 56 +++++++++++++------------- testcode/lib/atari/displaylist.c | 69 ++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 28 deletions(-) create mode 100644 testcode/lib/atari/displaylist.c diff --git a/doc/atari.sgml b/doc/atari.sgml index a0dbe2f47..1b084324f 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -317,6 +317,49 @@ chip registers. </descrip><p> +<sect1>Display lists<p> + +An major feature of the Atari graphics chip "ANTIC" is to +process instructions for the display generation. +cc65 supports constructing these display lists by offering defines +for the instructions. In conjunction with the "void"-variable extension +of cc65, display lists can be created quite comfortable: + +<verb> +... +unsigned char ScreenMemory[100]; + +void DisplayList = +{ + DL_BLK8, + DL_BLK8, + DL_BLK8, + DL_LMS(DL_CHR20x8x2), + ScreenMemory, + DL_CHR20x8x2, + DL_CHR20x8x2, + DL_CHR20x8x2, + DL_BLK4, + DL_CHR20x8x2, + DL_JVB +}; +... +POKEW(560,(unsigned int)&DisplayList); // SDLSTL +... +</verb> + +Please inspect the <tt/_antic.h/ header file to detemine the supported +instruction names. Modifiers on instructions can be nested without need +for an order: + +<tt/DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_MAP80x4x2))))/ + +Please mind that ANTIC has memory alignment requirements for "player +missile graphics"-data, font data, display lists and screen memory. Creation +of a special linker configuration with appropriate aligned segments and +switching to that segment in the c-code is usually neccessary. A more memory +hungry solution consists in using the "<tt/posix_memalign()/" function in +conjunction with copying your data to the allocated memory. <sect1>Character mapping<p> diff --git a/include/_antic.h b/include/_antic.h index ab0cd9664..23a72609c 100644 --- a/include/_antic.h +++ b/include/_antic.h @@ -57,42 +57,42 @@ struct __antic { /* antic instruction set */ /* absolute instructions (non mode lines) */ -#define DL_JMP 1 -#define DL_JVB 65 +#define DL_JMP (unsigned char) 1 +#define DL_JVB (unsigned char) 65 -#define DL_BLK1 0 -#define DL_BLK2 16 -#define DL_BLK3 32 -#define DL_BLK4 48 -#define DL_BLK5 64 -#define DL_BLK6 80 -#define DL_BLK7 96 -#define DL_BLK8 112 +#define DL_BLK1 (unsigned char) 0 +#define DL_BLK2 (unsigned char) 16 +#define DL_BLK3 (unsigned char) 32 +#define DL_BLK4 (unsigned char) 48 +#define DL_BLK5 (unsigned char) 64 +#define DL_BLK6 (unsigned char) 80 +#define DL_BLK7 (unsigned char) 96 +#define DL_BLK8 (unsigned char) 112 /* absolute instructions (mode lines) */ -#define DL_CHR40x8x1 2 /* monochrome, 40 character & 8 scanlines per mode line (GR. 0) */ -#define DL_CHR40x10x1 3 /* monochrome, 40 character & 10 scanlines per mode line */ -#define DL_CHR40x8x4 4 /* colour, 40 character & 8 scanlines per mode line (GR. 12) */ -#define DL_CHR40x16x4 5 /* colour, 40 character & 16 scanlines per mode line (GR. 13) */ -#define DL_CHR20x8x2 6 /* colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1) */ -#define DL_CHR20x16x2 7 /* colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) */ +#define DL_CHR40x8x1 (unsigned char) 2 /* monochrome, 40 character & 8 scanlines per mode line (GR. 0) */ +#define DL_CHR40x10x1 (unsigned char) 3 /* monochrome, 40 character & 10 scanlines per mode line */ +#define DL_CHR40x8x4 (unsigned char) 4 /* colour, 40 character & 8 scanlines per mode line (GR. 12) */ +#define DL_CHR40x16x4 (unsigned char) 5 /* colour, 40 character & 16 scanlines per mode line (GR. 13) */ +#define DL_CHR20x8x2 (unsigned char) 6 /* colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1) */ +#define DL_CHR20x16x2 (unsigned char) 7 /* colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) */ -#define DL_MAP40x8x4 8 /* colour, 40 pixel & 8 scanlines per mode line (GR. 3) */ -#define DL_MAP80x4x2 9 /* 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) */ -#define DL_MAP80x4x4 10 /* colour, 80 pixel & 4 scanlines per mode line (GR.5) */ -#define DL_MAP160x2x2 11 /* 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) */ -#define DL_MAP160x1x2 12 /* 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) */ -#define DL_MAP160x2x4 13 /* 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) */ -#define DL_MAP160x1x4 14 /* 4 colours, 160 pixel & 1 scanline per mode line (GR.15) */ -#define DL_MAP320x1x1 15 /* monochrome, 320 pixel & 1 scanline per mode line (GR.8) */ +#define DL_MAP40x8x4 (unsigned char) 8 /* colour, 40 pixel & 8 scanlines per mode line (GR. 3) */ +#define DL_MAP80x4x2 (unsigned char) 9 /* 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) */ +#define DL_MAP80x4x4 (unsigned char) 10 /* colour, 80 pixel & 4 scanlines per mode line (GR.5) */ +#define DL_MAP160x2x2 (unsigned char) 11 /* 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) */ +#define DL_MAP160x1x2 (unsigned char) 12 /* 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) */ +#define DL_MAP160x2x4 (unsigned char) 13 /* 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) */ +#define DL_MAP160x1x4 (unsigned char) 14 /* 4 colours, 160 pixel & 1 scanline per mode line (GR.15) */ +#define DL_MAP320x1x1 (unsigned char) 15 /* monochrome, 320 pixel & 1 scanline per mode line (GR.8) */ /* modifiers on mode lines */ -#define DL_HSCROL 16 -#define DL_VSCROL 32 -#define DL_LMS 64 +#define DL_HSCROL(x) (unsigned char)((x) | 16) +#define DL_VSCROL(x) (unsigned char)((x) | 32) +#define DL_LMS(x) (unsigned char)((x) | 64) /* general modifier */ -#define DL_DLI 128 +#define DL_DLI(x) (unsigned char)((x) | 128) /* End of _antic.h */ #endif /* #ifndef __ANTIC_H */ diff --git a/testcode/lib/atari/displaylist.c b/testcode/lib/atari/displaylist.c new file mode 100644 index 000000000..869b5bb65 --- /dev/null +++ b/testcode/lib/atari/displaylist.c @@ -0,0 +1,69 @@ +/* +** testprogram for ANTIC instructions as defined in "_antic.h" +** +** 23-Feb-2017, Christian Krueger +*/ + +#include <conio.h> +#include <atari.h> +#include <peekpoke.h> +#include <string.h> + +// code is only for testing purposes, as screen and display list are not aligned +// and jumps not set! + +unsigned char DummyScreen[400]; + +void DisplayList = { + DL_BLK1, + DL_BLK2, + DL_BLK3, + DL_BLK4, + DL_BLK5, + DL_BLK6, + DL_BLK7, + DL_DLI(DL_BLK8), + DL_LMS(DL_CHR40x8x1), + DummyScreen, + DL_HSCROL(DL_CHR40x10x1), + DL_VSCROL(DL_CHR40x8x4), + DL_CHR40x16x4, + DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_CHR20x8x2)))), + DummyScreen+120, + DL_CHR20x16x2, + DL_MAP40x8x4, + DL_MAP80x4x2, + DL_MAP80x4x4, + DL_MAP160x2x2, + DL_MAP160x1x2, + DL_MAP160x2x4, + DL_MAP160x1x4, + DL_MAP320x1x1, + DL_JVB, + DL_JMP +}; + +unsigned char dlend = 0; + + +int +main(void) +{ + // unfortunately "sizeof()" doesn't work with void data + // (Error: Size of data type is unknown) + // so we trick with the adresses at front and behind... + + int returnValue = (((unsigned int)&dlend-(unsigned int)&DisplayList) != 28); // assure only one byte per instruction! + + clrscr(); + if (returnValue) + cputs("Test FAILED!"); + else + cputs("Test passed."); + + cputs("\n\rHit any key to exit..."); + cgetc(); + + return returnValue; +} + From f55d334435a1c1d845e1850021b23d83638cae29 Mon Sep 17 00:00:00 2001 From: Irgendwer <C.Krueger.B@web.de> Date: Fri, 24 Feb 2017 11:19:33 +0100 Subject: [PATCH 232/407] Update atari.sgml --- doc/atari.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/atari.sgml b/doc/atari.sgml index 1b084324f..6cbff6208 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -319,7 +319,7 @@ chip registers. <sect1>Display lists<p> -An major feature of the Atari graphics chip "ANTIC" is to +A major feature of the Atari graphics chip "ANTIC" is to process instructions for the display generation. cc65 supports constructing these display lists by offering defines for the instructions. In conjunction with the "void"-variable extension From e5af45b913f2cf40cd234f7c249b23e8e79c0870 Mon Sep 17 00:00:00 2001 From: Irgendwer <C.Krueger.B@web.de> Date: Fri, 24 Feb 2017 11:21:56 +0100 Subject: [PATCH 233/407] Update displaylist.c --- testcode/lib/atari/displaylist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testcode/lib/atari/displaylist.c b/testcode/lib/atari/displaylist.c index 869b5bb65..04c599878 100644 --- a/testcode/lib/atari/displaylist.c +++ b/testcode/lib/atari/displaylist.c @@ -51,7 +51,7 @@ main(void) { // unfortunately "sizeof()" doesn't work with void data // (Error: Size of data type is unknown) - // so we trick with the adresses at front and behind... + // so we trick with the addresses at front and end... int returnValue = (((unsigned int)&dlend-(unsigned int)&DisplayList) != 28); // assure only one byte per instruction! From aeee5610e1cdefaeae36456499c20e7bcffa1c3f Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Fri, 24 Feb 2017 19:06:32 +0100 Subject: [PATCH 234/407] atari_antic.inc: use "or" instead of "plus" in the usage example --- asminc/atari_antic.inc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/asminc/atari_antic.inc b/asminc/atari_antic.inc index 1eb4c87ef..a4557c7b4 100644 --- a/asminc/atari_antic.inc +++ b/asminc/atari_antic.inc @@ -33,16 +33,16 @@ NMIRES = ANTIC + $0F ;NMI interrupt reset ; ScreenDL: ; .byte DL_BLK8 ; .byte DL_BLK8 -; .byte DL_CHR40x8x1 + DL_LMS + DL_DLI +; .byte DL_CHR40x8x1 | DL_LMS | DL_DLI ; .word ScreenAlignment -; .byte DL_BLK1 + DL_DLI -; .byte DL_MAP320x1x1 + DL_LMS +; .byte DL_BLK1 | DL_DLI +; .byte DL_MAP320x1x1 | DL_LMS ; .word Screen ; ; .repeat 99 ; .byte DL_MAP320x1x1 ; .endrepeat -; .byte DL_MAP320x1x1 + DL_LMS +; .byte DL_MAP320x1x1 | DL_LMS ; .word Screen + 40 * 100 ; 100 lines a 40 byte, 'Screen' has to be aligned correctly! ; .repeat 92 ; .byte DL_MAP320x1x1 @@ -55,6 +55,8 @@ NMIRES = ANTIC + $0F ;NMI interrupt reset DL_JMP = 1 DL_JVB = 65 +; DL_BLKn display n empty lines (just background) + DL_BLK1 = 0 DL_BLK2 = 16 DL_BLK3 = 32 From 6afcc370edbd77d494fc6378a20de0023be6981f Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 25 Feb 2017 20:19:34 +0100 Subject: [PATCH 235/407] Optimization of two string functions (size & speed). --- libsrc/common/strcat.s | 48 ++++++++------------ libsrc/common/strchr.s | 47 ++++++++++--------- testcode/lib/strcat-test.c | 93 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 52 deletions(-) create mode 100644 testcode/lib/strcat-test.c diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 7784d89f7..279bfe65b 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 31.05.1998 +; Christian Krueger: 2013-Jul-24, minor optimization ; ; char* strcat (char* dest, const char* src); ; @@ -12,44 +13,35 @@ _strcat: sta ptr1 ; Save src stx ptr1+1 jsr popax ; Get dest - sta ptr2 - stx ptr2+1 sta tmp3 ; Remember for function return - ldy #0 + tay + lda #0 + sta ptr2 ; access from page start, y contains low byte + stx ptr2+1 -; find end of dest - -sc1: lda (ptr2),y - beq sc2 +findEndOfDest: + lda (ptr2),y + beq endOfDestFound iny - bne sc1 + bne findEndOfDest inc ptr2+1 - bne sc1 + bne findEndOfDest -; end found, get offset in y into pointer +endOfDestFound: + sty ptr2 ; advance pointer to last y position + ldy #0 ; reset new y-offset -sc2: tya - clc - adc ptr2 - sta ptr2 - bcc sc3 - inc ptr2+1 - -; copy src - -sc3: ldy #0 -sc4: lda (ptr1),y +copyByte: + lda (ptr1),y sta (ptr2),y - beq sc5 + beq done iny - bne sc4 + bne copyByte inc ptr1+1 inc ptr2+1 - bne sc4 + bne copyByte ; like bra here -; done, return pointer to dest - -sc5: lda tmp3 ; X does still contain high byte +; return pointer to dest +done: lda tmp3 ; X does still contain high byte rts - diff --git a/libsrc/common/strchr.s b/libsrc/common/strchr.s index 308381b06..0bd55d0e1 100644 --- a/libsrc/common/strchr.s +++ b/libsrc/common/strchr.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 31.05.1998 +; Christian Krueger, 2013-Aug-04, minor optimization ; ; const char* strchr (const char* s, int c); ; @@ -9,40 +10,38 @@ .importzp ptr1, tmp1 _strchr: - sta tmp1 ; Save c - jsr popax ; get s - sta ptr1 - stx ptr1+1 - ldy #0 + sta tmp1 ; Save c + jsr popax ; get s + tay ; low byte of pointer to y + stx ptr1+1 + lda #0 + sta ptr1 ; ptr access page wise -Loop: lda (ptr1),y ; Get next char - beq EOS ; Jump on end of string - cmp tmp1 ; Found? - beq Found ; Jump if yes +Loop: lda (ptr1),y ; Get next char + beq EOS ; Jump on end of string + cmp tmp1 ; Found? + beq Found ; Jump if yes iny - bne Loop - inc ptr1+1 - bne Loop ; Branch always + bne Loop + inc ptr1+1 + bne Loop ; Branch always ; End of string. Check if we're searching for the terminating zero -EOS: lda tmp1 ; Get the char we're searching for - bne NotFound ; Jump if not searching for terminator +EOS: + lda tmp1 ; Get the char we're searching for + bne NotFound ; Jump if not searching for terminator -; Found. Calculate pointer to c. +; Found. Set pointer to c. -Found: ldx ptr1+1 ; Load high byte of pointer - tya ; Low byte offset - clc - adc ptr1 - bcc Found1 - inx -Found1: rts +Found: + ldx ptr1+1 ; Load high byte of pointer + tya ; low byte is in y + rts ; Not found, return NULL NotFound: - lda #0 + lda #0 tax rts - diff --git a/testcode/lib/strcat-test.c b/testcode/lib/strcat-test.c new file mode 100644 index 000000000..edd614fc4 --- /dev/null +++ b/testcode/lib/strcat-test.c @@ -0,0 +1,93 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define SourceStringSize 257 // test correct page passing (>256) + +static char SourceString[SourceStringSize+1]; // +1 room for terminating null +static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer + + +int main (void) +{ + unsigned i,j; + char* p; + + /* Print a header */ + printf ("strcat(): "); + + for (i=0; i < SourceStringSize; ++i) + SourceString[i] = (i%128)+1; + + SourceString[i] = 0; + + if (strlen(SourceString) != SourceStringSize) + { + printf ("Fail: Source string initialization or 'strlen()' problem!\n"); + printf ("Expected length: %u but is %u!\n", SourceStringSize, strlen(SourceString)); + exit (EXIT_FAILURE); + } + + /* Ensure empty destination string */ + DestinationString[0] = 0; + + if (strlen(DestinationString) != 0) + { + printf ("Fail: Destination string initialization or 'strlen()' problem!\n"); + printf ("Expected length: %u but is %u!\n", 0, strlen(DestinationString)); + exit (EXIT_FAILURE); + } + + /* Test concatenation to empty buffer */ + + p = strcat(DestinationString, SourceString); + + if (strlen(DestinationString) != SourceStringSize) + { + printf ("Fail: String concatenation to empty buffer!\n"); + printf ("Expected length: %u but is %u!\n", SourceStringSize, strlen(DestinationString)); + exit (EXIT_FAILURE); + } + + /* Test concatenation to non empty buffer */ + + p = strcat(DestinationString, SourceString); + + if (strlen(DestinationString) != 2*SourceStringSize) + { + printf ("Fail: String concatenation to non-empty buffer!\n"); + printf ("Expected length: %u but is %u!\n", 2*SourceStringSize, strlen(DestinationString)); + exit (EXIT_FAILURE); + } + + /* Test return value */ + + if (p != DestinationString) + { + printf ("Invalid return value!\n"); + exit (EXIT_FAILURE); + } + + /* Test contents */ + + for(j=0; j <2; ++j) + for(i=0; i < SourceStringSize; ++i) + { + unsigned position = j*SourceStringSize+i; + unsigned current = DestinationString[position]; + unsigned expected = (i%128)+1; + if (current != expected) + { + printf ("Fail: Unexpected destination buffer contents at position %u!\n", position); + printf ("Expected %u, but is %u!\n", expected, current); + exit (EXIT_FAILURE); + } + } + + /* Test passed */ + printf ("Passed\n"); + return EXIT_SUCCESS; +} + + + From f6002a149c84f9b97f9a0838c3977cff2e443d07 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sat, 25 Feb 2017 21:32:06 +0100 Subject: [PATCH 236/407] adding gotoxy.s --- asminc/telestrat.inc | 5 +++++ libsrc/telestrat/gotoxy.s | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 libsrc/telestrat/gotoxy.s diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index 2c3502ba8..ab209e520 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -107,6 +107,7 @@ XWR0 = $10 XWSTR0 = $14 XTEXT = $19 XHIRES = $1A +XFILLM = $1C XMINMA = $1F XFREAD = $27 ; only in TELEMON 3.0 XOPEN = $30 ; only in TELEMON 3.0 @@ -128,6 +129,10 @@ XINK = $93 XEXPLO = $9C XPING = $9D +; --------------------------------------------------------------------------- +; Page $200 +SCRX := $220 +SCRY := $224 ; --------------------------------------------------------------------------- ; Page $500 diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s new file mode 100644 index 000000000..18e010ae2 --- /dev/null +++ b/libsrc/telestrat/gotoxy.s @@ -0,0 +1,15 @@ + .export _gotoxy + + .import popa + + .importzp sp,tmp2,tmp3,tmp1 + + .include "telestrat.inc" + + +.proc _gotoxy + sta SCRY + jsr popa + sta SCRX + rts +.endproc From 4f1d007fb4cfbd20b7bf45e1bf14f41fcabd08ab Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sat, 25 Feb 2017 21:32:42 +0100 Subject: [PATCH 237/407] Correcting typo --- doc/telestrat.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index 9032156ee..fda4dee86 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -141,7 +141,7 @@ Telestrat manages also mouse, but it had been no handled yet in this version. Telestrat has a RS232 port, but it's not used -</descrip>< +</descrip> <sect>Limitations<label id="limitations"><p> From 1497330cc06512aff6a6708ba2d9e053b38ca7e1 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sat, 25 Feb 2017 22:10:13 +0100 Subject: [PATCH 238/407] adding clrscr.s --- asminc/telestrat.inc | 3 +++ libsrc/telestrat/clrscr.s | 31 +++++++++++++++++++++++++++++++ libsrc/telestrat/gotoxy.s | 2 ++ 3 files changed, 36 insertions(+) create mode 100644 libsrc/telestrat/clrscr.s diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index ab209e520..8a51e1c32 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -133,6 +133,9 @@ XPING = $9D ; Page $200 SCRX := $220 SCRY := $224 +ADSCRL := $218 +ADSCRH := $21C + ; --------------------------------------------------------------------------- ; Page $500 diff --git a/libsrc/telestrat/clrscr.s b/libsrc/telestrat/clrscr.s new file mode 100644 index 000000000..8c45aeeec --- /dev/null +++ b/libsrc/telestrat/clrscr.s @@ -0,0 +1,31 @@ + .export _clrscr + + .importzp sp + + .include "telestrat.inc" + +.proc _clrscr + lda #<SCREEN + ldy #>SCREEN + sta RES + sty RES+1 + + ldy #<(SCREEN+SCREEN_XSIZE*SCREEN_YSIZE) + ldx #>(SCREEN+SCREEN_XSIZE*SCREEN_YSIZE) + lda #' ' + BRK_TELEMON XFILLM + + + ; reset prompt position + lda #<(SCREEN+40) + sta ADSCRL + lda #>(SCREEN+40) + sta ADSCRH + + ; reset display position + lda #$01 + sta SCRY + lda #$02 + sta SCRX + rts +.endproc diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s index 18e010ae2..fb659d968 100644 --- a/libsrc/telestrat/gotoxy.s +++ b/libsrc/telestrat/gotoxy.s @@ -8,6 +8,8 @@ .proc _gotoxy + ; This function move only cursor for display, it does not move the prompt position + ; in telemon, there is position for prompt, and another for the cursor sta SCRY jsr popa sta SCRX From 7bc3bff83f682f9c511e272e30ae3736ca3681aa Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sat, 25 Feb 2017 22:20:17 +0100 Subject: [PATCH 239/407] adding gotox.s gotoy.s wherex.s wherey.s --- libsrc/telestrat/clrscr.s | 6 +++++- libsrc/telestrat/gotox.s | 16 ++++++++++++++++ libsrc/telestrat/gotoxy.s | 9 ++++++--- libsrc/telestrat/gotoy.s | 14 ++++++++++++++ libsrc/telestrat/wherex.s | 15 +++++++++++++++ libsrc/telestrat/wherey.s | 15 +++++++++++++++ 6 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 libsrc/telestrat/gotox.s create mode 100644 libsrc/telestrat/gotoy.s create mode 100644 libsrc/telestrat/wherex.s create mode 100644 libsrc/telestrat/wherey.s diff --git a/libsrc/telestrat/clrscr.s b/libsrc/telestrat/clrscr.s index 8c45aeeec..891c4162d 100644 --- a/libsrc/telestrat/clrscr.s +++ b/libsrc/telestrat/clrscr.s @@ -1,3 +1,7 @@ +; +; jede jede@oric.org 2017-02-25 +; + .export _clrscr .importzp sp @@ -25,7 +29,7 @@ ; reset display position lda #$01 sta SCRY - lda #$02 + lda #$00 sta SCRX rts .endproc diff --git a/libsrc/telestrat/gotox.s b/libsrc/telestrat/gotox.s new file mode 100644 index 000000000..d6af0e4dd --- /dev/null +++ b/libsrc/telestrat/gotox.s @@ -0,0 +1,16 @@ +; +; jede jede@oric.org 2017-02-25 +; + .export _gotox + + .import popa + + .importzp sp + + .include "telestrat.inc" + + +.proc _gotox + sta SCRX + rts +.endproc diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s index fb659d968..7aa83b71d 100644 --- a/libsrc/telestrat/gotoxy.s +++ b/libsrc/telestrat/gotoxy.s @@ -1,3 +1,6 @@ +; +; jede jede@oric.org 2017-02-25 +; .export _gotoxy .import popa @@ -10,8 +13,8 @@ .proc _gotoxy ; This function move only cursor for display, it does not move the prompt position ; in telemon, there is position for prompt, and another for the cursor - sta SCRY - jsr popa - sta SCRX + sta SCRY + jsr popa + sta SCRX rts .endproc diff --git a/libsrc/telestrat/gotoy.s b/libsrc/telestrat/gotoy.s new file mode 100644 index 000000000..d71570f10 --- /dev/null +++ b/libsrc/telestrat/gotoy.s @@ -0,0 +1,14 @@ +; +; jede jede@oric.org 2017-02-25 +; + .export _gotoy + + .importzp sp + + .include "telestrat.inc" + + +.proc _gotoy + sta SCRY + rts +.endproc diff --git a/libsrc/telestrat/wherex.s b/libsrc/telestrat/wherex.s new file mode 100644 index 000000000..6d9587ba8 --- /dev/null +++ b/libsrc/telestrat/wherex.s @@ -0,0 +1,15 @@ +; +; jede jede@oric.org 2017-02-25 +; + .export _wherex + + .importzp sp + + .include "telestrat.inc" + + +.proc _wherex + ldx #$00 + lda SCRX + rts +.endproc diff --git a/libsrc/telestrat/wherey.s b/libsrc/telestrat/wherey.s new file mode 100644 index 000000000..e211ed5b9 --- /dev/null +++ b/libsrc/telestrat/wherey.s @@ -0,0 +1,15 @@ +; +; jede jede@oric.org 2017-02-25 +; + .export _wherey + + .importzp sp + + .include "telestrat.inc" + + +.proc _wherey + ldx #$00 + lda SCRY + rts +.endproc From b0e035ba2b654891c98d7bf0de912e8d4da68798 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sat, 25 Feb 2017 22:23:46 +0100 Subject: [PATCH 240/407] Cleaning --- libsrc/telestrat/clrscr.s | 8 ++++---- libsrc/telestrat/gotoxy.s | 3 +-- libsrc/telestrat/gotoy.s | 1 - libsrc/telestrat/wherex.s | 1 - libsrc/telestrat/wherey.s | 1 - 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/libsrc/telestrat/clrscr.s b/libsrc/telestrat/clrscr.s index 891c4162d..f2b8fafc1 100644 --- a/libsrc/telestrat/clrscr.s +++ b/libsrc/telestrat/clrscr.s @@ -10,7 +10,7 @@ .proc _clrscr lda #<SCREEN - ldy #>SCREEN + ldy #>SCREEN sta RES sty RES+1 @@ -20,14 +20,14 @@ BRK_TELEMON XFILLM - ; reset prompt position + ; reset prompt position lda #<(SCREEN+40) sta ADSCRL lda #>(SCREEN+40) sta ADSCRH - ; reset display position - lda #$01 + ; reset display position + lda #$01 sta SCRY lda #$00 sta SCRX diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s index 7aa83b71d..e0c8154e3 100644 --- a/libsrc/telestrat/gotoxy.s +++ b/libsrc/telestrat/gotoxy.s @@ -5,11 +5,10 @@ .import popa - .importzp sp,tmp2,tmp3,tmp1 + .importzp sp .include "telestrat.inc" - .proc _gotoxy ; This function move only cursor for display, it does not move the prompt position ; in telemon, there is position for prompt, and another for the cursor diff --git a/libsrc/telestrat/gotoy.s b/libsrc/telestrat/gotoy.s index d71570f10..ed7101c80 100644 --- a/libsrc/telestrat/gotoy.s +++ b/libsrc/telestrat/gotoy.s @@ -7,7 +7,6 @@ .include "telestrat.inc" - .proc _gotoy sta SCRY rts diff --git a/libsrc/telestrat/wherex.s b/libsrc/telestrat/wherex.s index 6d9587ba8..0dd5139e1 100644 --- a/libsrc/telestrat/wherex.s +++ b/libsrc/telestrat/wherex.s @@ -7,7 +7,6 @@ .include "telestrat.inc" - .proc _wherex ldx #$00 lda SCRX diff --git a/libsrc/telestrat/wherey.s b/libsrc/telestrat/wherey.s index e211ed5b9..4958f10cf 100644 --- a/libsrc/telestrat/wherey.s +++ b/libsrc/telestrat/wherey.s @@ -7,7 +7,6 @@ .include "telestrat.inc" - .proc _wherey ldx #$00 lda SCRY From c240d42a9e36f565f03d00eab80b9a2c5aa99ae3 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sun, 26 Feb 2017 20:03:05 +0100 Subject: [PATCH 241/407] Added "strrchr" optimizaion a matching unit test and tiny unit test framework. (Documentation for that will follow later) --- include/unittest.h | 89 +++++++++++++++++++++++++++++++++++++ libsrc/common/strrchr.s | 58 +++++++++++------------- testcode/lib/strcat-test.c | 65 ++++++--------------------- testcode/lib/strrchr-test.c | 38 ++++++++++++++++ 4 files changed, 167 insertions(+), 83 deletions(-) create mode 100644 include/unittest.h create mode 100644 testcode/lib/strrchr-test.c diff --git a/include/unittest.h b/include/unittest.h new file mode 100644 index 000000000..a58bbb937 --- /dev/null +++ b/include/unittest.h @@ -0,0 +1,89 @@ +/*****************************************************************************/ +/* */ +/* unittest.h */ +/* */ +/* Unit test helper macros */ +/* */ +/* */ +/* */ +/* (C) 2017 Christian Krueger */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +#ifndef _UNITTEST_H +#define _UNITTEST_H + +#include <stdio.h> +#include <stdlib.h> + +#ifndef COMMA +#define COMMA , +#endif + +#define TEST int main(void) \ + {\ + printf("%s: ",__FILE__); + +#define ENDTEST printf("Passed\n"); \ + return EXIT_SUCCESS; \ + } + +#define ASSERT_IsTrue(a,b) if (!(a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be true but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } + +#define ASSERT_IsFalse(a,b) if ((a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be false but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } + +#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } + +#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value not: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } + +/* End of unittest.h */ +#endif + + + + diff --git a/libsrc/common/strrchr.s b/libsrc/common/strrchr.s index bd7389e76..3e4fb0810 100644 --- a/libsrc/common/strrchr.s +++ b/libsrc/common/strrchr.s @@ -1,47 +1,41 @@ ; ; Ullrich von Bassewitz, 31.05.1998 +; Christian Krueger: 2013-Aug-01, optimization ; ; char* strrchr (const char* s, int c); ; .export _strrchr .import popax - .importzp ptr1, ptr2, tmp1 + .importzp ptr1, tmp1, tmp2 _strrchr: - sta tmp1 ; Save c - jsr popax ; get s - sta ptr1 - stx ptr1+1 - lda #0 ; function result = NULL - sta ptr2 - sta ptr2+1 - tay + sta tmp1 ; Save c + jsr popax ; get s + tay ; low byte to y + stx ptr1+1 + ldx #0 ; default function result is NULL, X is high byte... + stx tmp2 ; tmp2 is low-byte + stx ptr1 ; low-byte of source string is in Y, so clear real one... + +testChar: + lda (ptr1),y ; get char + beq finished ; jump if end of string + cmp tmp1 ; found? + bne nextChar ; jump if no -L1: lda (ptr1),y ; get next char - beq L3 ; jump if end of string - cmp tmp1 ; found? - bne L2 ; jump if no +charFound: + sty tmp2 ; y has low byte of location, save it + ldx ptr1+1 ; x holds high-byte of result -; Remember a pointer to the character +nextChar: + iny + bne testChar + inc ptr1+1 + bne testChar ; here like bra... - tya - clc - adc ptr1 - sta ptr2 - lda ptr1+1 - adc #$00 - sta ptr2+1 +; return the pointer to the last occurrence -; Next char - -L2: iny - bne L1 - inc ptr1+1 - bne L1 ; jump always - -; Return the pointer to the last occurrence - -L3: lda ptr2 - ldx ptr2+1 +finished: + lda tmp2 ; high byte in X is already correct... rts diff --git a/testcode/lib/strcat-test.c b/testcode/lib/strcat-test.c index edd614fc4..fdc987288 100644 --- a/testcode/lib/strcat-test.c +++ b/testcode/lib/strcat-test.c @@ -1,5 +1,4 @@ -#include <stdio.h> -#include <stdlib.h> +#include <unittest.h> #include <string.h> #define SourceStringSize 257 // test correct page passing (>256) @@ -8,65 +7,38 @@ static char SourceString[SourceStringSize+1]; // +1 room for terminating null static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer -int main (void) +TEST { unsigned i,j; char* p; - - /* Print a header */ - printf ("strcat(): "); - + for (i=0; i < SourceStringSize; ++i) SourceString[i] = (i%128)+1; SourceString[i] = 0; - if (strlen(SourceString) != SourceStringSize) - { - printf ("Fail: Source string initialization or 'strlen()' problem!\n"); - printf ("Expected length: %u but is %u!\n", SourceStringSize, strlen(SourceString)); - exit (EXIT_FAILURE); - } + ASSERT_AreEqual(SourceStringSize, strlen(SourceString), "%u", "Source string initialization or 'strlen()' problem!"); /* Ensure empty destination string */ DestinationString[0] = 0; - if (strlen(DestinationString) != 0) - { - printf ("Fail: Destination string initialization or 'strlen()' problem!\n"); - printf ("Expected length: %u but is %u!\n", 0, strlen(DestinationString)); - exit (EXIT_FAILURE); - } - + ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!"); + /* Test concatenation to empty buffer */ - p = strcat(DestinationString, SourceString); - - if (strlen(DestinationString) != SourceStringSize) - { - printf ("Fail: String concatenation to empty buffer!\n"); - printf ("Expected length: %u but is %u!\n", SourceStringSize, strlen(DestinationString)); - exit (EXIT_FAILURE); - } - + strcat(DestinationString, SourceString); + + ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!"); + /* Test concatenation to non empty buffer */ p = strcat(DestinationString, SourceString); - if (strlen(DestinationString) != 2*SourceStringSize) - { - printf ("Fail: String concatenation to non-empty buffer!\n"); - printf ("Expected length: %u but is %u!\n", 2*SourceStringSize, strlen(DestinationString)); - exit (EXIT_FAILURE); - } + ASSERT_AreEqual(2*SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to non-empty buffer!"); /* Test return value */ - if (p != DestinationString) - { - printf ("Invalid return value!\n"); - exit (EXIT_FAILURE); - } + ASSERT_IsTrue(p == DestinationString,"Invalid return value!"); /* Test contents */ @@ -76,18 +48,9 @@ int main (void) unsigned position = j*SourceStringSize+i; unsigned current = DestinationString[position]; unsigned expected = (i%128)+1; - if (current != expected) - { - printf ("Fail: Unexpected destination buffer contents at position %u!\n", position); - printf ("Expected %u, but is %u!\n", expected, current); - exit (EXIT_FAILURE); - } + ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position); } - - /* Test passed */ - printf ("Passed\n"); - return EXIT_SUCCESS; } - +ENDTEST diff --git a/testcode/lib/strrchr-test.c b/testcode/lib/strrchr-test.c new file mode 100644 index 000000000..9c1c70032 --- /dev/null +++ b/testcode/lib/strrchr-test.c @@ -0,0 +1,38 @@ +#include <unittest.h> +#include <string.h> + +static char TestString[] = "01234567890123456789"; // two times the same string +static char Found[256]; + +TEST +{ + unsigned len; + unsigned i; + char* p; + + len = strlen(TestString)/2; // test only one half of the string, to find last appearance + + /* Search for all characters in the string, including the terminator */ + for (i = 0; i < len; ++i) + { + /* Search for this char */ + p = strrchr (TestString, TestString[i]); + ASSERT_AreEqual(i+len, p-TestString, "%u", "Unexpected location of character '%c' found!" COMMA TestString[i]); + + /* Mark the char as checked */ + Found[TestString[i]] = 1; + } + + /* Search for all other characters and make sure they aren't found */ + for (i = 0; i < 256; ++i) + { + if (!Found[i]) + { + p = strrchr (TestString, i); + ASSERT_IsFalse(p, "Unexpected location of character '%c' found!" COMMA TestString[i]); + } + } +} +ENDTEST + + From 3d28f5ca9089bd7f16ce77efeba0c66752932a07 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sun, 26 Feb 2017 22:36:19 +0100 Subject: [PATCH 242/407] Fixed indentation --- include/unittest.h | 78 ++++++++++++++++++------------------- libsrc/common/strcat.s | 47 +++++++++++----------- testcode/lib/strcat-test.c | 4 +- testcode/lib/strrchr-test.c | 4 +- 4 files changed, 66 insertions(+), 67 deletions(-) diff --git a/include/unittest.h b/include/unittest.h index a58bbb937..bd355bb0c 100644 --- a/include/unittest.h +++ b/include/unittest.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2017 Christian Krueger */ +/* (C) 2017 Christian Krueger */ /* */ /* This software is provided 'as-is', without any expressed or implied */ /* warranty. In no event will the authors be held liable for any damages */ @@ -37,49 +37,49 @@ #define COMMA , #endif -#define TEST int main(void) \ - {\ - printf("%s: ",__FILE__); +#define TEST int main(void) \ + {\ + printf("%s: ",__FILE__); -#define ENDTEST printf("Passed\n"); \ - return EXIT_SUCCESS; \ - } +#define ENDTEST printf("Passed\n"); \ + return EXIT_SUCCESS; \ + } -#define ASSERT_IsTrue(a,b) if (!(a)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(b);\ - printf("\n");\ - printf("Expected status should be true but wasn't!\n");\ - exit(EXIT_FAILURE);\ - } +#define ASSERT_IsTrue(a,b) if (!(a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be true but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } -#define ASSERT_IsFalse(a,b) if ((a)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(b);\ - printf("\n");\ - printf("Expected status should be false but wasn't!\n");\ - exit(EXIT_FAILURE);\ - } +#define ASSERT_IsFalse(a,b) if ((a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be false but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } -#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(d);\ - printf("\n");\ - printf("Expected value: "c", but is "c"!\n", (a), (b));\ - exit(EXIT_FAILURE);\ - } +#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } -#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(d);\ - printf("\n");\ - printf("Expected value not: "c", but is "c"!\n", (a), (b));\ - exit(EXIT_FAILURE);\ - } +#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value not: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } /* End of unittest.h */ #endif diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 279bfe65b..9be65386f 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -10,38 +10,37 @@ .importzp ptr1, ptr2, tmp3 _strcat: - sta ptr1 ; Save src - stx ptr1+1 - jsr popax ; Get dest - sta tmp3 ; Remember for function return - tay - lda #0 - sta ptr2 ; access from page start, y contains low byte - stx ptr2+1 + sta ptr1 ; Save src + stx ptr1+1 + jsr popax ; Get dest + sta tmp3 ; Remember for function return + tay + lda #0 + sta ptr2 ; access from page start, y contains low byte + stx ptr2+1 findEndOfDest: - lda (ptr2),y - beq endOfDestFound + lda (ptr2),y + beq endOfDestFound iny - bne findEndOfDest - inc ptr2+1 - bne findEndOfDest + bne findEndOfDest + inc ptr2+1 + bne findEndOfDest endOfDestFound: - sty ptr2 ; advance pointer to last y position - ldy #0 ; reset new y-offset + sty ptr2 ; advance pointer to last y position + ldy #0 ; reset new y-offset copyByte: - lda (ptr1),y - sta (ptr2),y - beq done + lda (ptr1),y + sta (ptr2),y + beq done iny - bne copyByte - inc ptr1+1 - inc ptr2+1 - bne copyByte ; like bra here + bne copyByte + inc ptr1+1 + inc ptr2+1 + bne copyByte ; like bra here ; return pointer to dest -done: lda tmp3 ; X does still contain high byte +done: lda tmp3 ; X does still contain high byte rts - diff --git a/testcode/lib/strcat-test.c b/testcode/lib/strcat-test.c index fdc987288..2e00b80cb 100644 --- a/testcode/lib/strcat-test.c +++ b/testcode/lib/strcat-test.c @@ -3,7 +3,7 @@ #define SourceStringSize 257 // test correct page passing (>256) -static char SourceString[SourceStringSize+1]; // +1 room for terminating null +static char SourceString[SourceStringSize+1]; // +1 room for terminating null static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer @@ -48,7 +48,7 @@ TEST unsigned position = j*SourceStringSize+i; unsigned current = DestinationString[position]; unsigned expected = (i%128)+1; - ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position); + ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position); } } ENDTEST diff --git a/testcode/lib/strrchr-test.c b/testcode/lib/strrchr-test.c index 9c1c70032..d2c2a20e4 100644 --- a/testcode/lib/strrchr-test.c +++ b/testcode/lib/strrchr-test.c @@ -1,7 +1,7 @@ #include <unittest.h> #include <string.h> -static char TestString[] = "01234567890123456789"; // two times the same string +static char TestString[] = "01234567890123456789"; // two times the same string static char Found[256]; TEST @@ -10,7 +10,7 @@ TEST unsigned i; char* p; - len = strlen(TestString)/2; // test only one half of the string, to find last appearance + len = strlen(TestString)/2; // test only one half of the string, to find last appearance /* Search for all characters in the string, including the terminator */ for (i = 0; i < len; ++i) From 09de875330a4ca5eeabf91a21e774758c1de4417 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Tue, 28 Feb 2017 08:05:11 +0100 Subject: [PATCH 243/407] Changed the location of unittest.h --- testcode/lib/strcat-test.c | 2 +- testcode/lib/strrchr-test.c | 2 +- {include => testcode/lib}/unittest.h | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {include => testcode/lib}/unittest.h (100%) diff --git a/testcode/lib/strcat-test.c b/testcode/lib/strcat-test.c index 2e00b80cb..58119e27a 100644 --- a/testcode/lib/strcat-test.c +++ b/testcode/lib/strcat-test.c @@ -1,5 +1,5 @@ -#include <unittest.h> #include <string.h> +#include "unittest.h" #define SourceStringSize 257 // test correct page passing (>256) diff --git a/testcode/lib/strrchr-test.c b/testcode/lib/strrchr-test.c index d2c2a20e4..a72c44db9 100644 --- a/testcode/lib/strrchr-test.c +++ b/testcode/lib/strrchr-test.c @@ -1,5 +1,5 @@ -#include <unittest.h> #include <string.h> +#include "unittest.h" static char TestString[] = "01234567890123456789"; // two times the same string static char Found[256]; diff --git a/include/unittest.h b/testcode/lib/unittest.h similarity index 100% rename from include/unittest.h rename to testcode/lib/unittest.h From 99f3c7d01d598061ff386a3b057b6db43e759eb0 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 1 Mar 2017 06:29:53 -0500 Subject: [PATCH 244/407] Fixed a makefile: "yaccdbg.c" includes "yacc.c". So, yaccdbg must depend on both of them. --- test/ref/Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/ref/Makefile b/test/ref/Makefile index 09dd96d44..6f0bd1bc1 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -1,4 +1,3 @@ - # makefile for the regression tests that generate output which has to be # compared with reference output @@ -24,7 +23,7 @@ WORKDIR := ..$S..$Stestwrk DIFF := $(WORKDIR)/bdiff CC := gcc -CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow +CFLAGS := -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow .PHONY: all clean @@ -34,6 +33,11 @@ TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c= all: $(REFS) $(TESTS) +# "yaccdbg.c" includes "yacc.c". +# yaccdbg's built files must depend on both of them. + +$(WORKDIR)/yaccdbg.ref: yacc.c + $(WORKDIR)/%.ref: %.c $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host $(WORKDIR)$S$*.host > $@ @@ -48,6 +52,8 @@ $(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl $(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl $(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl +$(WORKDIR)/yaccdbg%prg: yacc.c + $(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref $(CL65) $(CC65FLAGS) $< -o $@ $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out From 8f0ea644dddfaf9c41718ff055f4b77f0b8f43ad Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 1 Mar 2017 06:36:25 -0500 Subject: [PATCH 245/407] Fixed a pointer-difference, comparison-with-zero expression. Some GCC C compilers can't subtract higher pointers from lower pointers properly, when those pointers must be scaled (because they point to objects that are wider than a char). The scaling is done as unsigned which makes the difference positive instead of negative. So, a broken expression was changed into a direct comparison between the two pointers. --- test/ref/yacc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ref/yacc.c b/test/ref/yacc.c index 5768f80d0..d0b9190e4 100644 --- a/test/ref/yacc.c +++ b/test/ref/yacc.c @@ -562,7 +562,7 @@ yylook() } # ifdef LEXDEBUG - if((*(lsp-1)-yysvec-1)<0) + if (*(lsp-1) < yysvec + 1) { fprintf(yyout,"yylook: stopped (end)\n"); } From 9558ebf86c60339fec73895a70c39292469173a2 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Sat, 4 Mar 2017 10:04:32 +0100 Subject: [PATCH 246/407] creativision/crt0.s: enable display interrupts in display controller configuration Otherwise the joystick zero page locations won't get updated. --- libsrc/creativision/crt0.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s index 6faec38eb..420ac71ef 100644 --- a/libsrc/creativision/crt0.s +++ b/libsrc/creativision/crt0.s @@ -81,7 +81,7 @@ irq2: jmp BIOS_IRQ2_ADDR ; VDP Setup ; This sets to Graphics Mode 1 .byte $00 ; Register 0 - .byte $C0 ; Register 1 16K RAM, Active Display, Mode 1 + .byte $E0 ; Register 1 16K RAM, Active Display, Mode 1, VBI enabled .byte $04 ; Register 2 Name Table at $1000 - $12FF .byte $60 ; Register 3 Colour Table at $1800 - $181F .byte $00 ; Register 4 Pattern Table at $0000 - $07FF From 81115aa82625f2b7e773b29844a3a7af589cdb95 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sun, 5 Mar 2017 02:09:12 +0100 Subject: [PATCH 247/407] Added further optimizations and unit tests. --- libsrc/common/memmove.s | 11 +-- libsrc/common/strcat.s | 6 +- libsrc/common/strchr.s | 6 +- libsrc/common/strcspn.s | 78 +++++++-------- libsrc/common/strlen.s | 5 +- libsrc/common/strncat.s | 96 ++++++++++--------- libsrc/common/strspn.s | 80 ++++++++-------- libsrc/runtime/axlong.s | 16 ++-- test/val/{atoi-test.c => lib_common_atoi.c} | 0 test/val/lib_common_memmove.c | 61 ++++++++++++ .../val/lib_common_strcat.c | 2 - .../val/lib_common_strchr.c | 39 +++----- test/val/lib_common_strcspn.c | 26 +++++ test/val/lib_common_strncat.c | 54 +++++++++++ .../val/{strtol-test.c => lib_common_strol.c} | 0 .../val/lib_common_strrchr.c | 0 test/val/lib_common_strspn.c | 24 +++++ .../{strtoul-test.c => lib_common_strtoul.c} | 0 {testcode/lib => test/val}/unittest.h | 0 19 files changed, 327 insertions(+), 177 deletions(-) rename test/val/{atoi-test.c => lib_common_atoi.c} (100%) create mode 100644 test/val/lib_common_memmove.c rename testcode/lib/strcat-test.c => test/val/lib_common_strcat.c (99%) rename testcode/lib/strchr-test.c => test/val/lib_common_strchr.c (50%) create mode 100644 test/val/lib_common_strcspn.c create mode 100644 test/val/lib_common_strncat.c rename test/val/{strtol-test.c => lib_common_strol.c} (100%) rename testcode/lib/strrchr-test.c => test/val/lib_common_strrchr.c (100%) create mode 100644 test/val/lib_common_strspn.c rename test/val/{strtoul-test.c => lib_common_strtoul.c} (100%) rename {testcode/lib => test/val}/unittest.h (100%) diff --git a/libsrc/common/memmove.s b/libsrc/common/memmove.s index 9c33124f1..666447cd8 100644 --- a/libsrc/common/memmove.s +++ b/libsrc/common/memmove.s @@ -1,6 +1,6 @@ ; ; 2003-08-20, Ullrich von Bassewitz -; 2009-09-13, Christian Krueger -- performance increase (about 20%) +; 2009-09-13, Christian Krueger -- performance increase (about 20%), 2013-07-25 improved unrolling ; 2015-10-23, Greg King ; ; void* __fastcall__ memmove (void* dest, const void* src, size_t size); @@ -61,13 +61,10 @@ PageSizeCopy: ; assert Y = 0 dec ptr1+1 ; adjust base... dec ptr2+1 dey ; in entry case: 0 -> FF - lda (ptr1),y ; need to copy this 'intro byte' - sta (ptr2),y ; to 'land' later on Y=0! (as a result of the '.repeat'-block!) - dey ; FF ->FE @copyBytes: - .repeat 2 ; Unroll this a bit to make it faster... - lda (ptr1),y - sta (ptr2),y + .repeat 3 ; unroll this a bit to make it faster... + lda (ptr1),y ; important: unrolling three times gives a nice + sta (ptr2),y ; 255/3 = 85 loop which ends at 0 dey .endrepeat @copyEntry: ; in entry case: 0 -> FF diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 9be65386f..74fef0759 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -1,6 +1,6 @@ ; ; Ullrich von Bassewitz, 31.05.1998 -; Christian Krueger: 2013-Jul-24, minor optimization +; Christian Krueger: 2013-Jul-24, minor optimizations ; ; char* strcat (char* dest, const char* src); ; @@ -15,8 +15,12 @@ _strcat: jsr popax ; Get dest sta tmp3 ; Remember for function return tay +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz ptr2 +.else lda #0 sta ptr2 ; access from page start, y contains low byte +.endif stx ptr2+1 findEndOfDest: diff --git a/libsrc/common/strchr.s b/libsrc/common/strchr.s index 0bd55d0e1..48bb8822b 100644 --- a/libsrc/common/strchr.s +++ b/libsrc/common/strchr.s @@ -14,8 +14,12 @@ _strchr: jsr popax ; get s tay ; low byte of pointer to y stx ptr1+1 +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz ptr1 +.else lda #0 - sta ptr1 ; ptr access page wise + sta ptr1 ; access from page start, y contains low byte +.endif Loop: lda (ptr1),y ; Get next char beq EOS ; Jump on end of string diff --git a/libsrc/common/strcspn.s b/libsrc/common/strcspn.s index 8fd567ae4..3f7b42ed1 100644 --- a/libsrc/common/strcspn.s +++ b/libsrc/common/strcspn.s @@ -1,54 +1,54 @@ ; ; Ullrich von Bassewitz, 11.06.1998 +; Christian Krueger: 05-Aug-2013, optimization ; ; size_t strcspn (const char* s1, const char* s2); ; .export _strcspn - .import popax - .importzp ptr1, ptr2, tmp1, tmp2, tmp3 + .import popax, _strlen + .importzp ptr1, ptr2, tmp1, tmp2 _strcspn: - sta ptr2 ; Save s2 - stx ptr2+1 - jsr popax ; Get s1 - sta ptr1 - stx ptr1+1 - ldx #0 ; low counter byte - stx tmp1 ; high counter byte - ldy #$00 + jsr _strlen ; get length in a/x and transfer s2 to ptr1 + ; Note: It does not make sense to + ; have more than 255 test chars, so + ; we don't support a high byte here! (ptr1+1 is + ; also unchanged in strlen then (important!)) + ; -> the original implementation also + ; ignored this case -L1: lda (ptr1),y ; get next char from s1 - beq L6 ; jump if done - sta tmp2 ; save char + sta tmp1 ; tmp1 = strlen of test chars + jsr popax ; get and save s1 + sta ptr2 ; to ptr2 + stx ptr2+1 + ldx #0 ; low counter byte + stx tmp2 ; high counter byte + +loadChar: + ldy #0 + lda (ptr2),y ; get next char from s1 + beq leave ; handly byte of s1 +advance: + inc ptr2 ; advance string position to test + bne check + inc ptr2+1 + dey ; correct next iny (faster/shorter than bne...) + +checkNext: iny - bne L2 - inc ptr1+1 -L2: sty tmp3 ; save index into s1 +check: cpy tmp1 ; compare with length of test character string + beq endOfTestChars + cmp (ptr1),y ; found matching char? + bne checkNext - ldy #0 ; get index into s2 -L3: lda (ptr2),y ; - beq L4 ; jump if done - cmp tmp2 - beq L6 - iny - bne L3 - -; The character was not found in s2. Increment the counter and start over - -L4: ldy tmp3 ; reload index - inx - bne L1 - inc tmp1 - bne L1 - -; The character was found, or we reached the end of s1. Return count of -; characters - -L6: txa ; get low counter byte - ldx tmp1 ; get high counter byte +leave: txa ; restore position of finding + ldx tmp2 ; and return rts - - +endOfTestChars: + inx + bne loadChar + inc tmp2 + bne loadChar ; like bra... diff --git a/libsrc/common/strlen.s b/libsrc/common/strlen.s index b583eea50..1a51edb11 100644 --- a/libsrc/common/strlen.s +++ b/libsrc/common/strlen.s @@ -1,6 +1,10 @@ ; ; Ullrich von Bassewitz, 31.05.1998 ; +; Note: strspn & strcspn call internally this function and rely on +; the usage of only ptr1 here! Keep in mind when appling changes +; and check the other implementations too! +; ; int strlen (const char* s); ; @@ -23,4 +27,3 @@ L1: lda (ptr1),y L9: tya ; get low byte of counter, hi's all set rts - diff --git a/libsrc/common/strncat.s b/libsrc/common/strncat.s index b7bb04b2a..42717853f 100644 --- a/libsrc/common/strncat.s +++ b/libsrc/common/strncat.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 31.05.1998 +; Christian Krueger: 12-Aug-2013, minor optimizations ; ; char* strncat (char* dest, const char* src, size_t n); ; @@ -9,64 +10,65 @@ .importzp ptr1, ptr2, ptr3, tmp1, tmp2 _strncat: - eor #$FF ; one's complement to count upwards - sta tmp1 - txa - eor #$FF - sta tmp2 - jsr popax ; get src - sta ptr1 - stx ptr1+1 - jsr popax ; get dest - sta ptr2 - stx ptr2+1 - sta ptr3 ; remember for function return - stx ptr3+1 - ldy #0 + eor #$FF ; one's complement to count upwards + sta tmp1 + txa + eor #$FF + sta tmp2 + + jsr popax ; get src + sta ptr1 + stx ptr1+1 + + jsr popax ; get dest + sta ptr3 ; remember for function return + stx ptr3+1 + stx ptr2+1 + tay ; low byte as offset in Y +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz ptr2 +.else + ldx #0 + stx ptr2 ; destination on page boundary +.endif ; find end of dest -L1: lda (ptr2),y - beq L2 - iny - bne L1 - inc ptr2+1 - bne L1 +L1: lda (ptr2),y + beq L2 + iny + bne L1 + inc ptr2+1 + bne L1 -; end found, get offset in y into pointer - -L2: tya - clc - adc ptr2 - sta ptr2 - bcc L3 - inc ptr2+1 +; end found, apply offset to dest ptr and reset y +L2: sty ptr2 ; copy src. We've put the ones complement of the count into the counter, so ; we'll increment the counter on top of the loop -L3: ldy #0 - ldx tmp1 ; low counter byte +L3: ldy #0 + ldx tmp1 ; low counter byte -L4: inx - bne L5 - inc tmp2 - beq L6 ; jump if done -L5: lda (ptr1),y - sta (ptr2),y - beq L7 - iny - bne L4 - inc ptr1+1 - inc ptr2+1 - bne L4 +L4: inx + bne L5 + inc tmp2 + beq L6 ; jump if done +L5: lda (ptr1),y + sta (ptr2),y + beq L7 + iny + bne L4 + inc ptr1+1 + inc ptr2+1 + bne L4 ; done, set the trailing zero and return pointer to dest -L6: lda #0 - sta (ptr2),y -L7: lda ptr3 - ldx ptr3+1 - rts +L6: lda #0 + sta (ptr2),y +L7: lda ptr3 + ldx ptr3+1 + rts diff --git a/libsrc/common/strspn.s b/libsrc/common/strspn.s index f8b8fff2a..3316f0dab 100644 --- a/libsrc/common/strspn.s +++ b/libsrc/common/strspn.s @@ -1,56 +1,54 @@ ; ; Ullrich von Bassewitz, 11.06.1998 +; Christian Krueger: 08-Aug-2013, optimization ; ; size_t strspn (const char* s1, const char* s2); ; .export _strspn - .import popax - .importzp ptr1, ptr2, tmp1, tmp2, tmp3 + .import popax, _strlen + .importzp ptr1, ptr2, tmp1, tmp2 _strspn: - sta ptr2 ; Save s2 - stx ptr2+1 - jsr popax ; get s1 - sta ptr1 - stx ptr1+1 - ldx #0 ; low counter byte - stx tmp1 ; high counter byte - ldy #$00 + jsr _strlen ; get length in a/x and transfer s2 to ptr1 + ; Note: It does not make sense to + ; have more than 255 test chars, so + ; we don't support a high byte here! (ptr1+1 is + ; also unchanged in strlen then (important!)) + ; -> the original implementation also + ; ignored this case -L1: lda (ptr1),y ; get next char from s1 - beq L6 ; jump if done - sta tmp2 ; save char + sta tmp1 ; tmp1 = strlen of test chars + jsr popax ; get and save s1 + sta ptr2 ; to ptr2 + stx ptr2+1 + ldx #0 ; low counter byte + stx tmp2 ; high counter byte + +loadChar: + ldy #0 + lda (ptr2),y ; get next char from s1 + beq leave ; handly byte of s1 +advance: + inc ptr2 ; advance string position to test + bne check + inc ptr2+1 + dey ; correct next iny (faster/shorter than bne...) + +checkNext: iny - bne L2 - inc ptr1+1 -L2: sty tmp3 ; save index into s1 +check: cpy tmp1 ; compare with length of test character string + beq leave + cmp (ptr1),y ; found matching char? + bne checkNext - ldy #0 ; get index into s2 -L3: lda (ptr2),y ; - beq L6 ; jump if done - cmp tmp2 - beq L4 - iny - bne L3 - -; The character was found in s2. Increment the counter and start over - -L4: ldy tmp3 ; reload index +foundTestChar: inx - bne L1 - inc tmp1 - bne L1 + bne loadChar + inc tmp2 + bne loadChar ; like bra... -; The character was not found, or we reached the end of s1. Return count of -; characters - -L6: txa ; get low counter byte - ldx tmp1 ; get high counter byte +leave: txa ; restore position of finding + ldx tmp2 ; and return rts - - - - - - + \ No newline at end of file diff --git a/libsrc/runtime/axlong.s b/libsrc/runtime/axlong.s index 6d97b5025..02d0a825c 100644 --- a/libsrc/runtime/axlong.s +++ b/libsrc/runtime/axlong.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 25.10.2000 +; Christian Krueger, 02-Mar-2017, some bytes saved ; ; CC65 runtime: Convert int in ax into a long ; @@ -9,18 +10,13 @@ ; Convert AX from int to long in EAX +axlong: ldy #$ff + cpx #$80 ; Positive? + bcs store ; No, apply $FF + axulong: ldy #0 - sty sreg +store: sty sreg sty sreg+1 rts -axlong: cpx #$80 ; Positive? - bcc axulong ; Yes, handle like unsigned type - ldy #$ff - sty sreg - sty sreg+1 - rts - - - diff --git a/test/val/atoi-test.c b/test/val/lib_common_atoi.c similarity index 100% rename from test/val/atoi-test.c rename to test/val/lib_common_atoi.c diff --git a/test/val/lib_common_memmove.c b/test/val/lib_common_memmove.c new file mode 100644 index 000000000..dd5801569 --- /dev/null +++ b/test/val/lib_common_memmove.c @@ -0,0 +1,61 @@ +#include <string.h> +#include "unittest.h" + +#define BufferSize 384 // test correct page passing (>256, multiple of 128 here) + +static char Buffer[BufferSize+3]; // +1 to move up (and down) + + + +TEST +{ + unsigned i, v; + char* p; + + for (i=0; i < BufferSize; ++i) + Buffer[i+1] = (i%128); + + Buffer[0] = 255; // to check if start position is untouched + Buffer[BufferSize+2] = 255; // to check if end position is untouched + + // copy upwards + p = memmove(Buffer+2, Buffer+1, BufferSize); + + // check buffer consistency before target + ASSERT_AreEqual(255, (unsigned)Buffer[0], "%u", "Unexpected value before range!"); + + // check buffer consistency at starting point + ASSERT_AreEqual(0, (unsigned)Buffer[1], "%u", "Unexpected value at range start!"); + + // check buffer consistency after range + ASSERT_AreEqual(255, (unsigned)Buffer[BufferSize+2], "%u", "Unexpected value after range!"); + + // check buffer values + for (i=0; i < BufferSize; ++i) + { + ASSERT_AreEqual(i%128, (unsigned)Buffer[i+2], "%u", "Unexpected value in buffer at position %u!" COMMA i+2); + } + + v = Buffer[BufferSize+1]; // rember value of first untouched end-byte + + // copy downwards + p = memmove(Buffer+1, Buffer+2, BufferSize); + + // check buffer consistency before target + ASSERT_AreEqual(255, (unsigned)Buffer[0], "%u", "Unexpected value before range!"); + + // check buffer consistency at end point + ASSERT_AreEqual(v, (unsigned)Buffer[BufferSize+1], "%u", "Unexpected value at range end!"); + + // check buffer consistency after range + ASSERT_AreEqual(255, (unsigned)Buffer[BufferSize+2], "%u", "Unexpected value after range!"); + + // check buffer values + for (i=0; i < BufferSize; ++i) + { + ASSERT_AreEqual(i%128, (unsigned)Buffer[i+1], "%u", "Unexpected value in buffer at position %u!" COMMA i+1); + } +} +ENDTEST + + diff --git a/testcode/lib/strcat-test.c b/test/val/lib_common_strcat.c similarity index 99% rename from testcode/lib/strcat-test.c rename to test/val/lib_common_strcat.c index 58119e27a..1872053a4 100644 --- a/testcode/lib/strcat-test.c +++ b/test/val/lib_common_strcat.c @@ -52,5 +52,3 @@ TEST } } ENDTEST - - diff --git a/testcode/lib/strchr-test.c b/test/val/lib_common_strchr.c similarity index 50% rename from testcode/lib/strchr-test.c rename to test/val/lib_common_strchr.c index 7aba1de1e..a48d287e5 100644 --- a/testcode/lib/strchr-test.c +++ b/test/val/lib_common_strchr.c @@ -1,7 +1,5 @@ -#include <stdio.h> -#include <stdlib.h> #include <string.h> - +#include "unittest.h" /* Test string. Must NOT have duplicate characters! */ @@ -11,49 +9,34 @@ static char Found[256]; -int main (void) +TEST { unsigned Len; unsigned I; char* P; - /* Print a header */ - printf ("strchr(): "); - /* Get the length of the string */ Len = strlen (S); /* Search for all characters in the string, including the terminator */ - for (I = 0; I < Len+1; ++I) { - + for (I = 0; I < Len+1; ++I) + { /* Search for this char */ P = strchr (S, S[I]); /* Check if we found it */ - if (P == 0 || (P - S) != I) { - printf ("Failed for code 0x%02X, offset %u!\n", S[I], I); - printf ("P = %04X offset = %04X\n", P, P-S); - exit (EXIT_FAILURE); - } - + ASSERT_IsFalse(P == 0 || (P - S) != I, "For code 0x%02X, offset %u!\nP = %04X offset = %04X\n" COMMA S[I] COMMA I COMMA P COMMA P-S); /* Mark the char as checked */ Found[S[I]] = 1; } /* Search for all other characters and make sure they aren't found */ - for (I = 0; I < 256; ++I) { - if (Found[I] == 0) { - if (strchr (S, (char)I) != 0) { - printf ("Failed for code 0x%02X\n", I); - exit (EXIT_FAILURE); - } + for (I = 0; I < 256; ++I) + { + if (Found[I] == 0) + { + ASSERT_IsFalse(strchr (S, (char)I), "Failed for code 0x%02X\n" COMMA I); } } - - /* Test passed */ - printf ("Passed\n"); - return EXIT_SUCCESS; } - - - +ENDTEST diff --git a/test/val/lib_common_strcspn.c b/test/val/lib_common_strcspn.c new file mode 100644 index 000000000..10935a78e --- /dev/null +++ b/test/val/lib_common_strcspn.c @@ -0,0 +1,26 @@ +#include <string.h> +#include "unittest.h" + +#define EstimatedStringSize 384 // test correct page passing (>256) + +static char EstimatedString[EstimatedStringSize+1]; // +1 room for terminating null +static char* EmptyTestChars=""; // strlen equivalent... +static char* TestChars="1234567890"; // we like to find numbers + +TEST +{ + unsigned i; + + for (i=0; i < EstimatedStringSize; ++i) + EstimatedString[i] = (i%26)+'A'; // put ABCD... into the string to be estimated + + ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, TestChars), "%u", "Unxpected position returned for non-participant case!"); + + EstimatedString[EstimatedStringSize/2] = TestChars[strlen(TestChars-1)]; + ASSERT_AreEqual(EstimatedStringSize/2, strcspn(EstimatedString, TestChars), "%u", "Unxpected position returned for participant case!"); + + ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!"); +} +ENDTEST + + diff --git a/test/val/lib_common_strncat.c b/test/val/lib_common_strncat.c new file mode 100644 index 000000000..dd6df9147 --- /dev/null +++ b/test/val/lib_common_strncat.c @@ -0,0 +1,54 @@ +#include <string.h> +#include "unittest.h" + +#define SourceStringSize 384 // test correct page passing (>256, multiple of 128 here) + +static char SourceString[SourceStringSize+1]; // +1 room for terminating null +static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer + + +TEST +{ + unsigned i; + char* p; + + for (i=0; i < SourceStringSize; ++i) + SourceString[i] = (i%128)+1; + + SourceString[i] = 0; + + ASSERT_AreEqual(SourceStringSize, strlen(SourceString), "%u", "Source string initialization or 'strlen()' problem!"); + + /* Ensure empty destination string */ + DestinationString[0] = 0; + + ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!"); + + /* Test "unlimted" concatenation to empty buffer */ + + strncat(DestinationString, SourceString, 1024); + + ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!"); + + /* Test limited concatenation to non empty buffer */ + + p = strncat(DestinationString, SourceString, 128); + + ASSERT_AreEqual(SourceStringSize+128, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to non-empty buffer!"); + + /* Test return value */ + + ASSERT_IsTrue(p == DestinationString, "Invalid return value!"); + + /* Test contents */ + + for(i=0; i < strlen(DestinationString); ++i) + { + unsigned current = DestinationString[i]; + unsigned expected = (i%128)+1; + ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA i); + } +} +ENDTEST + + diff --git a/test/val/strtol-test.c b/test/val/lib_common_strol.c similarity index 100% rename from test/val/strtol-test.c rename to test/val/lib_common_strol.c diff --git a/testcode/lib/strrchr-test.c b/test/val/lib_common_strrchr.c similarity index 100% rename from testcode/lib/strrchr-test.c rename to test/val/lib_common_strrchr.c diff --git a/test/val/lib_common_strspn.c b/test/val/lib_common_strspn.c new file mode 100644 index 000000000..96a006469 --- /dev/null +++ b/test/val/lib_common_strspn.c @@ -0,0 +1,24 @@ +#include <string.h> +#include "unittest.h" + +#define EstimatedStringSize 384 // test correct page passing (>256) + +static char EstimatedString[EstimatedStringSize+1]; // +1 room for terminating null +static char* EmptyTestChars=""; // empty test case... +static char* TestChars="1234567890"; // we like to find numbers + +TEST +{ + unsigned i; + + for (i=0; i < EstimatedStringSize; ++i) + EstimatedString[i] = (i%10)+'0'; // put 0123... into the string to be estimated + + ASSERT_AreEqual(strlen(EstimatedString), strspn(EstimatedString, TestChars), "%u", "Unxpected position returned for all participant case!"); + + EstimatedString[EstimatedStringSize/2] = 'X'; + ASSERT_AreEqual(EstimatedStringSize/2, strspn(EstimatedString, TestChars), "%u", "Unxpected position returned for breaking case!"); + + ASSERT_AreEqual(0, strspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!"); +} +ENDTEST diff --git a/test/val/strtoul-test.c b/test/val/lib_common_strtoul.c similarity index 100% rename from test/val/strtoul-test.c rename to test/val/lib_common_strtoul.c diff --git a/testcode/lib/unittest.h b/test/val/unittest.h similarity index 100% rename from testcode/lib/unittest.h rename to test/val/unittest.h From 8d1b80e6fd7c4f3feef1fe7f56a321966bf59cd8 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sun, 5 Mar 2017 11:38:55 +0100 Subject: [PATCH 248/407] Fixed CPU-flag usage which fails on build server?! --- libsrc/common/strcat.s | 1 + libsrc/common/strchr.s | 1 + libsrc/common/strncat.s | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 74fef0759..7dce2f78a 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -8,6 +8,7 @@ .export _strcat .import popax .importzp ptr1, ptr2, tmp3 + .macpack cpu _strcat: sta ptr1 ; Save src diff --git a/libsrc/common/strchr.s b/libsrc/common/strchr.s index 48bb8822b..15c743776 100644 --- a/libsrc/common/strchr.s +++ b/libsrc/common/strchr.s @@ -8,6 +8,7 @@ .export _strchr .import popax .importzp ptr1, tmp1 + .macpack cpu _strchr: sta tmp1 ; Save c diff --git a/libsrc/common/strncat.s b/libsrc/common/strncat.s index 42717853f..e0fa39cc0 100644 --- a/libsrc/common/strncat.s +++ b/libsrc/common/strncat.s @@ -8,7 +8,8 @@ .export _strncat .import popax .importzp ptr1, ptr2, ptr3, tmp1, tmp2 - + .macpack cpu + _strncat: eor #$FF ; one's complement to count upwards sta tmp1 From 371e8efb7966268dbb86668f15813a36dd26d32e Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Tue, 7 Mar 2017 19:16:31 +0100 Subject: [PATCH 249/407] temporarily disable optimizations altogether until a fine grain control is implemented on Makefile level only disabling the compiler option -Os --- test/val/lib_common_memmove.c | 4 ++++ test/val/lib_common_strcat.c | 4 ++++ test/val/lib_common_strcspn.c | 4 ++++ test/val/lib_common_strncat.c | 4 ++++ test/val/lib_common_strspn.c | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/test/val/lib_common_memmove.c b/test/val/lib_common_memmove.c index dd5801569..6c04e1951 100644 --- a/test/val/lib_common_memmove.c +++ b/test/val/lib_common_memmove.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include <string.h> #include "unittest.h" diff --git a/test/val/lib_common_strcat.c b/test/val/lib_common_strcat.c index 1872053a4..6389d5651 100644 --- a/test/val/lib_common_strcat.c +++ b/test/val/lib_common_strcat.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include <string.h> #include "unittest.h" diff --git a/test/val/lib_common_strcspn.c b/test/val/lib_common_strcspn.c index 10935a78e..06838c435 100644 --- a/test/val/lib_common_strcspn.c +++ b/test/val/lib_common_strcspn.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include <string.h> #include "unittest.h" diff --git a/test/val/lib_common_strncat.c b/test/val/lib_common_strncat.c index dd6df9147..84d904fa0 100644 --- a/test/val/lib_common_strncat.c +++ b/test/val/lib_common_strncat.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include <string.h> #include "unittest.h" diff --git a/test/val/lib_common_strspn.c b/test/val/lib_common_strspn.c index 96a006469..693a1136a 100644 --- a/test/val/lib_common_strspn.c +++ b/test/val/lib_common_strspn.c @@ -1,3 +1,7 @@ +// temporarily disable optimizations altogether until a fine grain control +// is implemented on Makefile level only disabling the compiler option -Os +#pragma optimize (off) + #include <string.h> #include "unittest.h" From 97e3472c8701c2b7b89e8d4d98f693a25277c187 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 8 Mar 2017 13:16:40 +0100 Subject: [PATCH 250/407] creativision.inc: add symbolic names for joystick direction values --- asminc/creativision.inc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/asminc/creativision.inc b/asminc/creativision.inc index 59b26101b..83a63ba07 100644 --- a/asminc/creativision.inc +++ b/asminc/creativision.inc @@ -36,6 +36,24 @@ ZP_JOY1_DIR = $13 ZP_JOY0_BUTTONS = $16 ZP_JOY1_BUTTONS = $17 +;** Joystick direction values (ZP_JOY0_DIR/ZP_JOY1_DIR) +JOY_N = $49 +JOY_NNE = $48 +JOY_NE = $47 +JOY_ENE = $46 +JOY_E = $45 +JOY_ESE = $44 +JOY_SE = $43 +JOY_SSE = $42 +JOY_S = $41 +JOY_SSW = $40 +JOY_SW = $4F +JOY_WSW = $4E +JOY_W = $4D +JOY_WNW = $4C +JOY_NW = $4B +JOY_NNW = $4A + ;** BIOS BIOS_IRQ1_ADDR = $FF3F BIOS_IRQ2_ADDR = $FF52 From 64c4cef90140e97e018b82ddb37760af79df5a17 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 8 Mar 2017 13:19:53 +0100 Subject: [PATCH 251/407] Implement diagonal direction handling in creativision joystick driver. --- libsrc/creativision/joy/creativision-stdjoy.s | 274 +++++++++++------- 1 file changed, 166 insertions(+), 108 deletions(-) diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s index 37b927d08..3f167464a 100644 --- a/libsrc/creativision/joy/creativision-stdjoy.s +++ b/libsrc/creativision/joy/creativision-stdjoy.s @@ -1,60 +1,69 @@ ; ; Standard joystick driver for the Creativision. ; -; Christian Groessler, 2017-02-06 +; Christian Groessler, 2017-03-08 ; - .include "zeropage.inc" + .include "zeropage.inc" - .include "joy-kernel.inc" - .include "joy-error.inc" - .include "creativision.inc" + .include "joy-kernel.inc" + .include "joy-error.inc" + .include "creativision.inc" - .macpack module + .macpack module ; ------------------------------------------------------------------------ ; Header. Includes jump table - module_header _creativisionstd_joy + module_header _creativisionstd_joy ; Driver signature - .byte $6A, $6F, $79 ; "joy" - .byte JOY_API_VERSION ; Driver API version number + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number ; Library reference - .addr $0000 + .addr $0000 -; Button state masks (8 values) +; Symbolic names for joystick masks (similar names like the defines in joystick.h, but not related to them) - .byte $10 ; JOY_UP - .byte $04 ; JOY_DOWN - .byte $20 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $01 ; JOY_FIRE (button #1) - .byte $02 ; JOY_FIRE2 (button #2) - .byte $00 ; Future expansion - .byte $00 ; Future expansion +JOY_UP = $10 +JOY_DOWN = $04 +JOY_LEFT = $20 +JOY_RIGHT = $08 +JOY_FIRE = $01 +JOY_FIRE2 = $02 + +; Joystick state masks (8 values) + + .byte JOY_UP + .byte JOY_DOWN + .byte JOY_LEFT + .byte JOY_RIGHT + .byte JOY_FIRE + .byte JOY_FIRE2 + .byte $00 ; Future expansion + .byte $00 ; Future expansion ; Jump table. - .addr INSTALL - .addr UNINSTALL - .addr COUNT - .addr READJOY - .addr 0 ; IRQ entry not used + .addr INSTALL + .addr UNINSTALL + .addr COUNT + .addr READJOY + .addr 0 ; IRQ entry not used ; ------------------------------------------------------------------------ ; Constants -JOY_COUNT = 2 ; Number of joysticks we support +JOY_COUNT = 2 ; Number of joysticks we support ; ------------------------------------------------------------------------ ; Code - .code + .code ; ------------------------------------------------------------------------ ; INSTALL routine. Is called after the driver is loaded into memory. If @@ -63,131 +72,180 @@ JOY_COUNT = 2 ; Number of joysticks we support ; Must return an JOY_ERR_xx code in a/x. ; -INSTALL: - lda #JOY_ERR_OK - ldx #0 -; rts ; Fall through +INSTALL: lda #JOY_ERR_OK + ldx #0 +; rts ; Fall through ; ------------------------------------------------------------------------ ; UNINSTALL routine. Is called before the driver is removed from memory. ; Can do cleanup or whatever. Must not return anything. ; -UNINSTALL: - rts +UNINSTALL: rts ; ------------------------------------------------------------------------ ; COUNT: Return the total number of available joysticks in a/x. ; -COUNT: - lda #<JOY_COUNT - ldx #>JOY_COUNT - rts +COUNT: lda #<JOY_COUNT + ldx #>JOY_COUNT + rts ; ------------------------------------------------------------------------ ; READ: Read a particular joystick passed in A. ; -READJOY: - and #1 ; fix joystick number - bne READJOY_1 ; read right joystick +READJOY: and #1 ; fix joystick number + bne READJOY_1 ; read right joystick ; Read left joystick - ldx ZP_JOY0_DIR - lda ZP_JOY0_BUTTONS - jmp convert ; convert joystick state to sane cc65 values + ldx ZP_JOY0_DIR + lda ZP_JOY0_BUTTONS + jmp convert ; convert joystick state to cc65 values ; Read right joystick -READJOY_1: - - ldx ZP_JOY1_DIR - lda ZP_JOY1_BUTTONS - lsr a - lsr a - ;jmp convert ; convert joystick state to sane cc65 values - ; fall thru... +READJOY_1: ldx ZP_JOY1_DIR + lda ZP_JOY1_BUTTONS + lsr a + lsr a + ;jmp convert ; convert joystick state to cc65 values + ; fall thru... ; ------------------------------------------------------------------------ ; convert: make runtime lib compatible values -; A - buttons -; X - direction +; inputs: +; A - buttons +; X - direction ; convert: - ldy #0 - sty retval ; initialize return value ; ------ ; buttons: - ; Port values are for the left hand joystick (right hand joystick - ; values were shifted to the right to be identical). - ; Why are there two bits indicating a pressed trigger? - ; According to the "Second book of programs for the Dick Smith Wizard" - ; (pg. 88ff), the left hand fire button gives the value of - ; %00010001 and the right hand button gives %00100010 - ; Why two bits? Am I missing something? Can there be cases that just - ; one of those bits is set? - ; We just test if any of those two bits is not zero... +; Port values are for the left hand joystick (right hand joystick +; values were shifted to the right to be identical). +; Why are there two bits indicating a pressed trigger? +; According to the "Second book of programs for the Dick Smith Wizard" +; (pg. 88ff), the left hand fire button gives the value of +; %00010001 and the right hand button gives %00100010 +; Why two bits? Can there be cases that just one of those bits is set? +; Until these questions have been answered, we only use the lower two +; bits and ignore the upper ones... - tay - and #%00010001 - beq cnv_1 - - inc retval ; left button pressed - -cnv_1: tya - and #%00100010 - beq cnv_2 - - lda #$02 - ora retval - sta retval ; right button pressed + and #%00000011 ; button status came in in A, strip high bits + sta retval ; initialize 'retval' with button status ; ------ ; direction: -cnv_2: txa - ; tested with https://sourceforge.net/projects/creativisionemulator - ; $49 - %01001001 - up - ; $41 - %01000001 - down - ; $4D - %01001101 - left - ; $45 - %01000101 - right - ; - ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different - ; ignored for now... - ; $85 - %10000101 - up + right - ; $8D - %10001101 - down + left - ; $89 - %10001001 - up + left - ; $85 - %10000101 - down + right (emulator bug?) +; CV has a 16-direction joystick +; +; port values: (compass points) +; N - $49 - %01001001 +; NNE - $48 - %01001000 +; NE - $47 - %01000111 +; ENE - $46 - %01000110 +; E - $45 - %01000101 +; ESE - $44 - %01000100 +; SE - $43 - %01000011 +; SSE - $42 - %01000010 +; S - $41 - %01000001 +; SSW - $40 - %01000000 +; SW - $4F - %01001111 +; WSW - $4E - %01001110 +; W - $4D - %01001101 +; WNW - $4C - %01001100 +; NW - $4B - %01001011 +; NNW - $4A - %01001010 +; center - $00 - %00000000 +; +; mapping to cc65 definitions (4-direction joystick with 8 possible directions thru combinations) +; N, E, S, W -> JOY_UP, JOY_RIGHT, JOY_DOWN, JOY_LEFT +; NE, SE, SW, NW -> (JOY_UP | JOY_RIGHT), (JOY_DOWN | JOY_RIGHT), (JOY_DOWN | JOY_LEFT), (JOY_UP | JOY_LEFT) +; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW: +; toggle between straight and diagonal direction for every call, e.g. +; NNE: +; call to READJOY: return JOY_UP | JOY_RIGHT +; call to READJOY: return JOY_UP +; call to READJOY: return JOY_UP | JOY_RIGHT +; call to READJOY: return JOY_UP +; call to READJOY: return JOY_UP | JOY_RIGHT +; etc... - bit testbit ; bit #0 set? - beq done ; no, no direction + txa ; move direction status into A + beq done ; center position (no bits are set), nothing to do - and #%00001100 ; mask out other bits - lsr a - lsr a - tax - lda #%00000100 ; init bitmask -loop: dex - bmi done2 - asl a - bne loop + and #$0F ; get rid of the "$40" bit + bit bit0 ; is it a "three letter" direction (NNE, ENE, etc.)? + beq special ; yes (bit #0 is zero) -done2: ora retval - rts + lsr a ; create index into table + tax + lda dirtable,x +done: ora retval ; include "button" bits + ldx #0 + rts -done: lda retval - rts +; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW + +special: lsr a + tax + + lda toggler ; toggle the toggler + eor #$01 + sta toggler + bne spec_1 ; toggler is 1, use spectable_1 entry + + lda spectable_0,x ; toggler is 0, use spectable_0 entry + bne done ; jump always + +spec_1: lda spectable_1,x + bne done ; jump always ; ------------------------------------------------------------------------ ; - .data -testbit:.byte $01 + .rodata + + ; a mapping table of "port values" to "cc65 values" + ; port value had been shifted one bit to the right (range 0..7) +dirtable: .byte JOY_DOWN ; S + .byte JOY_DOWN | JOY_RIGHT ; SE + .byte JOY_RIGHT ; E + .byte JOY_UP | JOY_RIGHT ; NE + .byte JOY_UP ; N + .byte JOY_UP | JOY_LEFT ; NW + .byte JOY_LEFT ; W + .byte JOY_DOWN | JOY_LEFT ; SW + + ; two "special" mapping tables for three-letter directions (NNE, etc.) +spectable_0: .byte JOY_DOWN ; SSW + .byte JOY_DOWN ; SSE + .byte JOY_RIGHT ; ESE + .byte JOY_RIGHT ; ENE + .byte JOY_RIGHT ; NNE + .byte JOY_UP ; NNW + .byte JOY_LEFT ; WNW + .byte JOY_LEFT ; WSW + +spectable_1: .byte JOY_DOWN | JOY_LEFT ; SSW + .byte JOY_DOWN | JOY_RIGHT ; SSE + .byte JOY_DOWN | JOY_RIGHT ; ESE + .byte JOY_UP | JOY_RIGHT ; ENE + .byte JOY_UP | JOY_RIGHT ; NNE + .byte JOY_UP | JOY_LEFT ; NNW + .byte JOY_UP | JOY_LEFT ; WNW + .byte JOY_DOWN | JOY_LEFT ; WSW ; ------------------------------------------------------------------------ ; - .bss -retval: .res 0 +bit0: .byte $01 + +; ------------------------------------------------------------------------ +; + .bss +toggler: .res 1 +retval: .res 1 + + .end From b332064cb5f2cd42e1c495d8e1cefcfd735d088e Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 9 Mar 2017 14:39:08 +0100 Subject: [PATCH 252/407] Just some minor style fix. --- libsrc/Makefile | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index 54b54860c..cb3517c7e 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -15,24 +15,24 @@ CBMS = c128 \ GEOS = geos-apple \ geos-cbm -TARGETS = apple2 \ - apple2enh \ - atari \ - atarixl \ - atari2600 \ - atari5200 \ - atmos \ +TARGETS = apple2 \ + apple2enh \ + atari \ + atarixl \ + atari2600 \ + atari5200 \ + atmos \ creativision \ - $(CBMS) \ - $(GEOS) \ - gamate \ - lynx \ - nes \ - osic1p \ - pce \ - sim6502 \ - sim65c02 \ - supervision\ + $(CBMS) \ + $(GEOS) \ + gamate \ + lynx \ + nes \ + osic1p \ + pce \ + sim6502 \ + sim65c02 \ + supervision \ telestrat DRVTYPES = emd \ @@ -41,13 +41,13 @@ DRVTYPES = emd \ ser \ tgi -OUTPUTDIRS := lib \ - asminc \ - cfg \ - include \ - $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))\ - $(subst ../,,$(wildcard ../target/*/drv/*))\ - $(subst ../,,$(wildcard ../target/*/util))\ +OUTPUTDIRS := lib \ + asminc \ + cfg \ + include \ + $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) \ + $(subst ../,,$(wildcard ../target/*/drv/*)) \ + $(subst ../,,$(wildcard ../target/*/util)) .PHONY: all mostlyclean clean install zip lib $(TARGETS) From d2c89d2ba9d0030c538257a74a5d732cbdca6a0b Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Thu, 9 Mar 2017 19:14:31 +0100 Subject: [PATCH 253/407] "static int n; int n;" is an error. Fixes test/err/static-4.c regression. --- src/cc65/symtab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index fdf459873..3275332c5 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -821,7 +821,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) } /* An extern declaration must not change the current linkage. */ - if (IsFunc || (Flags & (SC_EXTERN | SC_DEF)) == SC_EXTERN) { + if (IsFunc || (Flags & (SC_EXTERN | SC_STORAGE)) == SC_EXTERN) { Flags &= ~SC_EXTERN; } From ce0cf853867e7f1c51075499c264e7d48e845190 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Thu, 9 Mar 2017 20:40:20 +0100 Subject: [PATCH 254/407] Add regression test for #204. --- test/val/static-fwd-decl.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/val/static-fwd-decl.c diff --git a/test/val/static-fwd-decl.c b/test/val/static-fwd-decl.c new file mode 100644 index 000000000..420640d97 --- /dev/null +++ b/test/val/static-fwd-decl.c @@ -0,0 +1,35 @@ +/* + !!DESCRIPTION!! static forward declarations + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Bob Andrews +*/ + +/* + see: https://github.com/cc65/cc65/issues/204 +*/ + +#pragma warn(error, on) + +typedef struct _DIRMENU +{ + const char *name; + struct _DIRMENU *dest; +} DIRMENU; + +static DIRMENU rmenu; + +static DIRMENU lmenu = { + "left", + &rmenu +}; + +static DIRMENU rmenu = { + "right", + &lmenu +}; + +int main(void) +{ + return lmenu.dest == &rmenu && rmenu.dest == &lmenu ? 0 : 1; +} From 6c3873316b31f86b61ea11b67055ac66b2b66ebd Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Thu, 9 Mar 2017 20:49:20 +0100 Subject: [PATCH 255/407] Add regression tests for duplicate global/static variables detected by the compiler. --- test/err/duplicate-global.c | 20 ++++++++++++++++++++ test/err/duplicate-static.c | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/err/duplicate-global.c create mode 100644 test/err/duplicate-static.c diff --git a/test/err/duplicate-global.c b/test/err/duplicate-global.c new file mode 100644 index 000000000..bd4fcc24a --- /dev/null +++ b/test/err/duplicate-global.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! duplicate globals + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +#pragma warn(error, on) + +int n = 0; +int n = 0; /* should give an error */ + +int main(void) +{ + return n; +} diff --git a/test/err/duplicate-static.c b/test/err/duplicate-static.c new file mode 100644 index 000000000..394cc1e09 --- /dev/null +++ b/test/err/duplicate-static.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! duplicate static variables + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +#pragma warn(error, on) + +static int n = 0; +static int n = 0; /* should give an error */ + +int main(void) +{ + return n; +} From 05d1b8072b580b1a68e09a76f21c9b8599af7028 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Thu, 9 Mar 2017 21:18:48 +0100 Subject: [PATCH 256/407] Add regression tests for duplicate globals with different linkage. --- test/err/duplicate-global-static.c | 18 ++++++++++++++++++ test/err/duplicate-static-global.c | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/err/duplicate-global-static.c create mode 100644 test/err/duplicate-static-global.c diff --git a/test/err/duplicate-global-static.c b/test/err/duplicate-global-static.c new file mode 100644 index 000000000..6aa27f5b7 --- /dev/null +++ b/test/err/duplicate-global-static.c @@ -0,0 +1,18 @@ +/* + !!DESCRIPTION!! global duplicated with static variable + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +int n = 0; +static int n = 0; /* should give an error */ + +int main(void) +{ + return n; +} diff --git a/test/err/duplicate-static-global.c b/test/err/duplicate-static-global.c new file mode 100644 index 000000000..6e5e70a37 --- /dev/null +++ b/test/err/duplicate-static-global.c @@ -0,0 +1,18 @@ +/* + !!DESCRIPTION!! static duplicated with global variable + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +static int n = 0; +int n = 0; /* should give an error */ + +int main(void) +{ + return n; +} From 8a81f9c0c842611a9d329ca8902ec3d8ba9a221f Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Fri, 10 Mar 2017 11:21:14 +0100 Subject: [PATCH 257/407] Fix line endings (CRLF -> LF) on all affected files. --- asminc/opcodes.inc | 1018 +++++++++++++++++------------------ asminc/smc.inc | 534 +++++++++--------- include/osic1p.h | 94 ++-- include/zlib.h | 344 ++++++------ libsrc/c64/emd/c64-65816.s | 752 +++++++++++++------------- libsrc/osic1p/cgetc.s | 100 ++-- libsrc/osic1p/osic1p.inc | 8 +- libsrc/osic1p/osiscreen.inc | 364 ++++++------- test/ref/divmod.c | 74 +-- test/ref/init.c | 190 +++---- test/ref/pointer2.c | 224 ++++---- test/ref/switch2.c | 514 +++++++++--------- test/ref/varargs.c | 202 +++---- testcode/lib/mul-test.c | 340 ++++++------ 14 files changed, 2379 insertions(+), 2379 deletions(-) diff --git a/asminc/opcodes.inc b/asminc/opcodes.inc index 7c52871d2..96cdefb65 100644 --- a/asminc/opcodes.inc +++ b/asminc/opcodes.inc @@ -1,509 +1,509 @@ -; opcodes.inc -; ca65 6502 - opcode definitions, mainly for self modifying code -; -; Christian Krüger, latest change: 18-Sep-2010 -; -; This software is provided 'as-is', without any expressed or implied -; warranty. In no event will the authors be held liable for any damages -; arising from the use of this software. -; -; Permission is granted to anyone to use this software for any purpose, -; including commercial applications, and to alter it and redistribute it -; freely, subject to the following restrictions: -; -; 1. The origin of this software must not be misrepresented; you must not -; claim that you wrote the original software. If you use this software -; in a product, an acknowledgment in the product documentation would be -; appreciated but is not required. -; 2. Altered source versions must be plainly marked as such, and must not -; be misrepresented as being the original software. -; 3. This notice may not be removed or altered from any source -; distribution. -; - -; Opcode-Table -; ------------ -; Post fix explanation: -; imm = #$00 -; zp = $00 -; zpx = $00,X -; zpy = $00,Y -; izp = ($00) -; izx = ($00,X) -; izy = ($00),Y -; abs = $0000 -; abx = $0000,X -; aby = $0000,Y -; ind = ($0000) -; iax = ($0000,X) -; rel = $0000 (PC-relative) (supressed here) - -.macpack cpu - -OPC_BRK = $00 -OPC_ORA_izx = $01 -OPC_ORA_zp = $05 -OPC_ASL_zp = $06 -OPC_PHP = $08 -OPC_ORA_imm = $09 -OPC_ASL = $0A -OPC_ORA_abs = $0D -OPC_ASL_abs = $0E - -OPC_BPL = $10 -OPC_ORA_izy = $11 -OPC_ORA_zpx = $15 -OPC_ASL_zpx = $16 -OPC_CLC = $18 -OPC_ORA_aby = $19 -OPC_ORA_abx = $1D -OPC_ASL_abx = $1E - -OPC_JSR_abs = $20 -OPC_AND_izx = $21 -OPC_BIT_zp = $24 -OPC_AND_zp = $25 -OPC_ROL_zp = $26 -OPC_PLP = $28 -OPC_AND_imm = $29 -OPC_ROL = $2A -OPC_BIT_abs = $2C -OPC_AND_abs = $2D -OPC_ROL_abs = $2E - -OPC_BMI = $30 -OPC_AND_izy = $31 -OPC_AND_zpx = $35 -OPC_ROL_zpx = $36 -OPC_SEC = $38 -OPC_AND_aby = $39 -OPC_AND_abx = $3D -OPC_ROL_abx = $3E - - -OPC_RTI = $40 -OPC_EOR_izx = $41 -OPC_EOR_zp = $45 -OPC_LSR_zp = $46 -OPC_PHA = $48 -OPC_EOR_imm = $49 -OPC_LSR = $4A -OPC_JMP_abs = $4C -OPC_EOR_abs = $4D -OPC_LSR_abs = $4E - -OPC_BVC = $50 -OPC_EOR_izy = $51 -OPC_EOR_zpx = $55 -OPC_LSR_zpx = $56 -OPC_CLI = $58 -OPC_EOR_aby = $59 -OPC_EOR_abx = $5D -OPC_LSR_abx = $5E - -OPC_RTS = $60 -OPC_ADC_izx = $61 -OPC_ADC_zp = $65 -OPC_ROR_zp = $66 -OPC_PLA = $68 -OPC_ADC_imm = $69 -OPC_ROR = $6A -OPC_JMP_ind = $6C -OPC_ADC_abs = $6D -OPC_ROR_abs = $6E - -OPC_BVS = $70 -OPC_ADC_izy = $71 -OPC_ADC_zpx = $75 -OPC_ROR_zpx = $76 -OPC_SEI = $78 -OPC_ADC_aby = $79 -OPC_ADC_abx = $7D -OPC_ROR_abx = $7E - -OPC_STA_izx = $81 -OPC_STY_zp = $84 -OPC_STA_zp = $85 -OPC_STX_zp = $86 -OPC_DEY = $88 -OPC_TXA = $8A -OPC_STY_abs = $8C -OPC_STA_abs = $8D -OPC_STX_abs = $8E - -OPC_BCC = $90 -OPC_STA_izy = $91 -OPC_STY_zpx = $94 -OPC_STA_zpx = $95 -OPC_STX_zpy = $96 -OPC_TYA = $98 -OPC_STA_aby = $99 -OPC_TXS = $9A -OPC_STA_abx = $9D - -OPC_LDY_imm = $A0 -OPC_LDA_izx = $A1 -OPC_LDX_imm = $A2 -OPC_LDY_zp = $A4 -OPC_LDA_zp = $A5 -OPC_LDX_zp = $A6 -OPC_TAY = $A8 -OPC_LDA_imm = $A9 -OPC_TAX = $AA -OPC_LDY_abs = $AC -OPC_LDA_abs = $AD -OPC_LDX_abs = $AE - -OPC_BCS = $B0 -OPC_LDA_izy = $B1 -OPC_LDY_zpx = $B4 -OPC_LDA_zpx = $B5 -OPC_LDX_zpy = $B6 -OPC_CLV = $B8 -OPC_LDA_aby = $B9 -OPC_TSX = $BA -OPC_LDY_abx = $BC -OPC_LDA_abx = $BD -OPC_LDX_aby = $BE - -OPC_CPY_imm = $C0 -OPC_CMP_izx = $C1 -OPC_CPY_zp = $C4 -OPC_CMP_zp = $C5 -OPC_DEC_zp = $C6 -OPC_INY = $C8 -OPC_CMP_imm = $C9 -OPC_DEX = $CA -OPC_CPY_abs = $CC -OPC_CMP_abs = $CD -OPC_DEC_abs = $CE - -OPC_BNE = $D0 -OPC_CMP_izy = $D1 -OPC_CMP_zpx = $D5 -OPC_DEC_zpx = $D6 -OPC_CLD = $D8 -OPC_CMP_aby = $D9 -OPC_CMP_abx = $DD -OPC_DEC_abx = $DE - -OPC_CPX_imm = $E0 -OPC_SBC_izx = $E1 -OPC_CPX_zp = $E4 -OPC_SBC_zp = $E5 -OPC_INC_zp = $E6 -OPC_INX = $E8 -OPC_SBC_imm = $E9 -OPC_NOP = $EA -OPC_CPX_abs = $EC -OPC_SBC_abs = $ED -OPC_INC_abs = $EE - - -OPC_BEQ = $F0 -OPC_SBC_izy = $F1 -OPC_SBC_zpx = $F5 -OPC_INC_zpx = $F6 -OPC_SED = $F8 -OPC_SBC_aby = $F9 -OPC_SBC_abx = $FD -OPC_INC_abx = $FE - - -.if (.cpu .bitand ::CPU_ISET_65SC02) - -; OPC_NOP = $02 ; doublet -; OPC_NOP = $03 ; doublet -OPC_TSB_zp = $04 -; OPC_NOP = $0B ; doublet -OPC_TSB_abs = $0C - -OPC_ORA_izp = $12 -; OPC_NOP = $13 ; doublet -OPC_TRB_zp = $14 -OPC_INC = $1A -; OPC_NOP = $1B ; doublet -OPC_TRB_abs = $1C - -; OPC_NOP = $22 ; doublet -; OPC_NOP = $23 ; doublet -; OPC_NOP = $2B ; doublet - -OPC_AND_izp = $32 -; OPC_NOP = $33 ; doublet -OPC_BIT_zpx = $34 -OPC_DEC = $3A -; OPC_NOP = $3B ; doublet -OPC_BIT_abx = $3C - -; OPC_NOP = $42 ; doublet -; OPC_NOP = $43 ; doublet -; OPC_NOP = $44 ; doublet -; OPC_NOP = $4B ; doublet - -OPC_EOR_izp = $52 -; OPC_NOP = $53 ; doublet -; OPC_NOP = $54 ; doublet -; OPC_NOP = $5A ; doublet -; OPC_NOP = $5B ; doublet -OPC_EOR_abx = $5C - -; OPC_NOP = $62 ; doublet -; OPC_NOP = $63 ; doublet -OPC_STZ_zp = $64 -; OPC_NOP = $6B ; doublet - -OPC_ADC_izp = $72 -; OPC_NOP = $73 ; doublet -OPC_STZ_zpx = $74 -OPC_PLY = $7A -; OPC_NOP = $7B ; doublet -OPC_JMP_iax = $7C - -OPC_BRA = $80 -; OPC_NOP = $82 ; doublet -; OPC_NOP = $83 ; doublet -OPC_BIT_imm = $89 -; OPC_NOP = $8B ; doublet - -OPC_STA_izp = $92 -; OPC_NOP = $93 ; doublet -; OPC_NOP = $9B ; doublet -OPC_STZ_abs = $9C -OPC_STZ_abx = $9E - -; OPC_NOP = $A3 ; doublet -; OPC_NOP = $AB ; doublet - -OPC_LDA_izp = $B2 -; OPC_NOP = $B3 ; doublet -; OPC_NOP = $BB ; doublet - -; OPC_NOP = $C2 ; doublet -; OPC_NOP = $C3 ; doublet -; OPC_NOP = $CB ; doublet - -OPC_CMP_izp = $D2 -; OPC_NOP = $D3 ; doublet -; OPC_NOP = $D4 ; doublet -OPC_PHX = $DA -; OPC_NOP = $DB ; doublet -; OPC_NOP = $DC ; doublet - -; OPC_NOP = $E2 ; doublet -; OPC_NOP = $E3 ; doublet -; OPC_NOP = $EB ; doublet - -OPC_SBC_izp = $F2 -; OPC_NOP = $F3 ; doublet -; OPC_NOP = $F4 ; doublet -OPC_PLX = $FA -; OPC_NOP = $FB ; doublet -; OPC_NOP = $FC ; doublet - - -.if (.cpu .bitand ::CPU_ISET_65C02) - -; bit instructions for 65C02 - -OPC_RMB0 = $07 -OPC_RMB1 = $17 -OPC_RMB2 = $27 -OPC_RMB3 = $37 -OPC_RMB4 = $47 -OPC_RMB5 = $57 -OPC_RMB6 = $67 -OPC_RMB7 = $77 - -OPC_SMB0 = $87 -OPC_SMB1 = $97 -OPC_SMB2 = $A7 -OPC_SMB3 = $B7 -OPC_SMB4 = $C7 -OPC_SMB5 = $D7 -OPC_SMB6 = $E7 -OPC_SMB7 = $F7 - -OPC_BBR0 = $0F -OPC_BBR1 = $1F -OPC_BBR2 = $2F -OPC_BBR3 = $3F -OPC_BBR4 = $4F -OPC_BBR5 = $5F -OPC_BBR6 = $6F -OPC_BBR7 = $7F - -OPC_BBS0 = $8F -OPC_BBS1 = $9F -OPC_BBS2 = $AF -OPC_BBS3 = $BF -OPC_BBS4 = $CF -OPC_BBS5 = $DF -OPC_BBS6 = $EF -OPC_BBS7 = $FF - -.else - -; no bit instructions for 65SC02 - -; OPC_NOP = $07 ; doublet -; OPC_NOP = $17 ; doublet -; OPC_NOP = $27 ; doublet -; OPC_NOP = $37 ; doublet -; OPC_NOP = $47 ; doublet -; OPC_NOP = $57 ; doublet -; OPC_NOP = $67 ; doublet -; OPC_NOP = $77 ; doublet -; OPC_NOP = $87 ; doublet -; OPC_NOP = $97 ; doublet -; OPC_NOP = $A7 ; doublet -; OPC_NOP = $B7 ; doublet -; OPC_NOP = $C7 ; doublet -; OPC_NOP = $D7 ; doublet -; OPC_NOP = $E7 ; doublet -; OPC_NOP = $F7 ; doublet -; OPC_NOP = $0F ; doublet -; OPC_NOP = $1F ; doublet -; OPC_NOP = $2F ; doublet -; OPC_NOP = $3F ; doublet -; OPC_NOP = $4F ; doublet -; OPC_NOP = $5F ; doublet -; OPC_NOP = $6F ; doublet -; OPC_NOP = $7F ; doublet -; OPC_NOP = $8F ; doublet -; OPC_NOP = $9F ; doublet -; OPC_NOP = $AF ; doublet -; OPC_NOP = $BF ; doublet -; OPC_NOP = $CF ; doublet -; OPC_NOP = $DF ; doublet -; OPC_NOP = $EF ; doublet -; OPC_NOP = $FF ; doublet - -.endif - -.elseif (.cpu .bitand ::CPU_ISET_6502X) - -; stable, undocumented opcodes - -; OPC_KIL = $02 ; unstable -OPC_SLO_izx = $03 -OPC_NOP_zp = $04 -OPC_SLO_zp = $07 -OPC_ANC_imm = $0B -OPC_NOP_abs = $0C -OPC_SLO_abs = $0F - -; OPC_KIL = $12 ; unstable -OPC_SLO_izy = $13 -OPC_NOP_zpx = $14 -OPC_SLO_zpx = $17 -;OPC_NOP = $1A -OPC_SLO_aby = $1B -OPC_NOP_abx = $1C -OPC_SLO_abx = $1F - -; OPC_KIL = $22 ; unstable -OPC_RLA_izx = $23 -OPC_RLA_zp = $27 -OPC_ANC_imm = $2B -OPC_RLA_abs = $2F - -; OPC_KIL = $32 ; unstable -OPC_RLA_izy = $33 -OPC_NOP_zpx = $34 -OPC_RLA_zpx = $37 -; OPC_NOP = $3A ; doublet -OPC_RLA_aby = $3B -OPC_NOP_abx = $3C -OPC_RLA_abx = $3F - -; OPC_KIL = $42 ; unstable -OPC_SRE_izx = $43 -OPC_NOP_zp = $44 -OPC_SRE_zp = $47 -OPC_ALR_imm = $4B -OPC_SRE_abs = $4F - -; OPC_KIL = $52 ; unstable -OPC_SRE_izy = $53 -OPC_NOP_zpx = $54 -OPC_SRE_zpx = $57 -; OPC_NOP = $5A ; doublet -OPC_SRE_aby = $5B -OPC_NOP_abx = $5C -OPC_SRE_abx = $5F - -; OPC_KIL = $62 -OPC_RRA_izx = $63 -OPC_NOP_zp = $64 -OPC_RRA_zp = $67 -OPC_ARR_imm = $6B -OPC_RRA_abs = $6F - -; OPC_KIL = $72 -OPC_RRA_izy = $73 -OPC_NOP_zpx = $74 -OPC_RRA_zpx = $77 -; OPC_NOP = $7A ; doublet -OPC_RRA_aby = $7B -OPC_NOP_abx = $7C -OPC_RRA_abx = $7F - -OPC_NOP_imm = $80 -; OPC_NOP_imm = $82 ; doublet -OPC_SAX_izx = $83 -OPC_SAX_zp = $87 -; OPC_NOP_imm = $89 ; doublet -; OPC_XAA = $8B ; unstable -OPC_SAX_abs = $8F - -; OPC_KIL = $92 ; unstable -; OPC_AHX_izy = $93 ; unstable -OPC_SAX_zpy = $97 -; OPC_TAS_aby = $9B ; unstable -; OPC_SHY_abx = $9C ; unstable -; OPC_SHX_aby = $9E ; unstable -; OPC_AHX_aby = $9F ; unstable - -OPC_LAX_izx = $A3 -OPC_LAX_zp = $A7 -; OPC_LAX_imm = $AB ; unstable -OPC_LAX_abs = $AF - -; OPC_KIL = $B2 ; unstable -OPC_LAX_izy = $B3 -OPC_LAX_zpy = $B7 -OPC_LAS_aby = $BB -OPC_LAX_aby = $BF - -; OPC_NOP_imm = $C2 ; doublet -OPC_DCP_izx = $C3 -OPC_DCP_zp = $C7 -OPC_AXS_imm = $CB -OPC_DCP_abs = $CF - -; OPC_KIL = $D2 ; unstable -OPC_DCP_izy = $D3 -OPC_NOP_zpx = $D4 -OPC_DCP_zpx = $D7 -OPC_NOP_DA = $DA -OPC_DCP_aby = $DB -OPC_NOP_abx = $DC -OPC_DCP_abx = $DF - -; OPC_NOP_imm = $E2 ; doublet -OPC_ISC_izx = $E3 -OPC_ISC_zp = $E7 -; OPC_SBC_imm = $EB ; doublet -OPC_ISC_abs = $EF - -; OPC_KIL = $F2 ; unstable -OPC_ISC_izy = $F3 -OPC_NOP_zpx = $F4 -OPC_ISC_zpx = $F7 -OPC_NOP_FA = $FA -OPC_ISC_aby = $FB -OPC_NOP_abx = $FC -OPC_ISC_abx = $FF - -.endif +; opcodes.inc +; ca65 6502 - opcode definitions, mainly for self modifying code +; +; Christian Krüger, latest change: 18-Sep-2010 +; +; This software is provided 'as-is', without any expressed or implied +; warranty. In no event will the authors be held liable for any damages +; arising from the use of this software. +; +; Permission is granted to anyone to use this software for any purpose, +; including commercial applications, and to alter it and redistribute it +; freely, subject to the following restrictions: +; +; 1. The origin of this software must not be misrepresented; you must not +; claim that you wrote the original software. If you use this software +; in a product, an acknowledgment in the product documentation would be +; appreciated but is not required. +; 2. Altered source versions must be plainly marked as such, and must not +; be misrepresented as being the original software. +; 3. This notice may not be removed or altered from any source +; distribution. +; + +; Opcode-Table +; ------------ +; Post fix explanation: +; imm = #$00 +; zp = $00 +; zpx = $00,X +; zpy = $00,Y +; izp = ($00) +; izx = ($00,X) +; izy = ($00),Y +; abs = $0000 +; abx = $0000,X +; aby = $0000,Y +; ind = ($0000) +; iax = ($0000,X) +; rel = $0000 (PC-relative) (supressed here) + +.macpack cpu + +OPC_BRK = $00 +OPC_ORA_izx = $01 +OPC_ORA_zp = $05 +OPC_ASL_zp = $06 +OPC_PHP = $08 +OPC_ORA_imm = $09 +OPC_ASL = $0A +OPC_ORA_abs = $0D +OPC_ASL_abs = $0E + +OPC_BPL = $10 +OPC_ORA_izy = $11 +OPC_ORA_zpx = $15 +OPC_ASL_zpx = $16 +OPC_CLC = $18 +OPC_ORA_aby = $19 +OPC_ORA_abx = $1D +OPC_ASL_abx = $1E + +OPC_JSR_abs = $20 +OPC_AND_izx = $21 +OPC_BIT_zp = $24 +OPC_AND_zp = $25 +OPC_ROL_zp = $26 +OPC_PLP = $28 +OPC_AND_imm = $29 +OPC_ROL = $2A +OPC_BIT_abs = $2C +OPC_AND_abs = $2D +OPC_ROL_abs = $2E + +OPC_BMI = $30 +OPC_AND_izy = $31 +OPC_AND_zpx = $35 +OPC_ROL_zpx = $36 +OPC_SEC = $38 +OPC_AND_aby = $39 +OPC_AND_abx = $3D +OPC_ROL_abx = $3E + + +OPC_RTI = $40 +OPC_EOR_izx = $41 +OPC_EOR_zp = $45 +OPC_LSR_zp = $46 +OPC_PHA = $48 +OPC_EOR_imm = $49 +OPC_LSR = $4A +OPC_JMP_abs = $4C +OPC_EOR_abs = $4D +OPC_LSR_abs = $4E + +OPC_BVC = $50 +OPC_EOR_izy = $51 +OPC_EOR_zpx = $55 +OPC_LSR_zpx = $56 +OPC_CLI = $58 +OPC_EOR_aby = $59 +OPC_EOR_abx = $5D +OPC_LSR_abx = $5E + +OPC_RTS = $60 +OPC_ADC_izx = $61 +OPC_ADC_zp = $65 +OPC_ROR_zp = $66 +OPC_PLA = $68 +OPC_ADC_imm = $69 +OPC_ROR = $6A +OPC_JMP_ind = $6C +OPC_ADC_abs = $6D +OPC_ROR_abs = $6E + +OPC_BVS = $70 +OPC_ADC_izy = $71 +OPC_ADC_zpx = $75 +OPC_ROR_zpx = $76 +OPC_SEI = $78 +OPC_ADC_aby = $79 +OPC_ADC_abx = $7D +OPC_ROR_abx = $7E + +OPC_STA_izx = $81 +OPC_STY_zp = $84 +OPC_STA_zp = $85 +OPC_STX_zp = $86 +OPC_DEY = $88 +OPC_TXA = $8A +OPC_STY_abs = $8C +OPC_STA_abs = $8D +OPC_STX_abs = $8E + +OPC_BCC = $90 +OPC_STA_izy = $91 +OPC_STY_zpx = $94 +OPC_STA_zpx = $95 +OPC_STX_zpy = $96 +OPC_TYA = $98 +OPC_STA_aby = $99 +OPC_TXS = $9A +OPC_STA_abx = $9D + +OPC_LDY_imm = $A0 +OPC_LDA_izx = $A1 +OPC_LDX_imm = $A2 +OPC_LDY_zp = $A4 +OPC_LDA_zp = $A5 +OPC_LDX_zp = $A6 +OPC_TAY = $A8 +OPC_LDA_imm = $A9 +OPC_TAX = $AA +OPC_LDY_abs = $AC +OPC_LDA_abs = $AD +OPC_LDX_abs = $AE + +OPC_BCS = $B0 +OPC_LDA_izy = $B1 +OPC_LDY_zpx = $B4 +OPC_LDA_zpx = $B5 +OPC_LDX_zpy = $B6 +OPC_CLV = $B8 +OPC_LDA_aby = $B9 +OPC_TSX = $BA +OPC_LDY_abx = $BC +OPC_LDA_abx = $BD +OPC_LDX_aby = $BE + +OPC_CPY_imm = $C0 +OPC_CMP_izx = $C1 +OPC_CPY_zp = $C4 +OPC_CMP_zp = $C5 +OPC_DEC_zp = $C6 +OPC_INY = $C8 +OPC_CMP_imm = $C9 +OPC_DEX = $CA +OPC_CPY_abs = $CC +OPC_CMP_abs = $CD +OPC_DEC_abs = $CE + +OPC_BNE = $D0 +OPC_CMP_izy = $D1 +OPC_CMP_zpx = $D5 +OPC_DEC_zpx = $D6 +OPC_CLD = $D8 +OPC_CMP_aby = $D9 +OPC_CMP_abx = $DD +OPC_DEC_abx = $DE + +OPC_CPX_imm = $E0 +OPC_SBC_izx = $E1 +OPC_CPX_zp = $E4 +OPC_SBC_zp = $E5 +OPC_INC_zp = $E6 +OPC_INX = $E8 +OPC_SBC_imm = $E9 +OPC_NOP = $EA +OPC_CPX_abs = $EC +OPC_SBC_abs = $ED +OPC_INC_abs = $EE + + +OPC_BEQ = $F0 +OPC_SBC_izy = $F1 +OPC_SBC_zpx = $F5 +OPC_INC_zpx = $F6 +OPC_SED = $F8 +OPC_SBC_aby = $F9 +OPC_SBC_abx = $FD +OPC_INC_abx = $FE + + +.if (.cpu .bitand ::CPU_ISET_65SC02) + +; OPC_NOP = $02 ; doublet +; OPC_NOP = $03 ; doublet +OPC_TSB_zp = $04 +; OPC_NOP = $0B ; doublet +OPC_TSB_abs = $0C + +OPC_ORA_izp = $12 +; OPC_NOP = $13 ; doublet +OPC_TRB_zp = $14 +OPC_INC = $1A +; OPC_NOP = $1B ; doublet +OPC_TRB_abs = $1C + +; OPC_NOP = $22 ; doublet +; OPC_NOP = $23 ; doublet +; OPC_NOP = $2B ; doublet + +OPC_AND_izp = $32 +; OPC_NOP = $33 ; doublet +OPC_BIT_zpx = $34 +OPC_DEC = $3A +; OPC_NOP = $3B ; doublet +OPC_BIT_abx = $3C + +; OPC_NOP = $42 ; doublet +; OPC_NOP = $43 ; doublet +; OPC_NOP = $44 ; doublet +; OPC_NOP = $4B ; doublet + +OPC_EOR_izp = $52 +; OPC_NOP = $53 ; doublet +; OPC_NOP = $54 ; doublet +; OPC_NOP = $5A ; doublet +; OPC_NOP = $5B ; doublet +OPC_EOR_abx = $5C + +; OPC_NOP = $62 ; doublet +; OPC_NOP = $63 ; doublet +OPC_STZ_zp = $64 +; OPC_NOP = $6B ; doublet + +OPC_ADC_izp = $72 +; OPC_NOP = $73 ; doublet +OPC_STZ_zpx = $74 +OPC_PLY = $7A +; OPC_NOP = $7B ; doublet +OPC_JMP_iax = $7C + +OPC_BRA = $80 +; OPC_NOP = $82 ; doublet +; OPC_NOP = $83 ; doublet +OPC_BIT_imm = $89 +; OPC_NOP = $8B ; doublet + +OPC_STA_izp = $92 +; OPC_NOP = $93 ; doublet +; OPC_NOP = $9B ; doublet +OPC_STZ_abs = $9C +OPC_STZ_abx = $9E + +; OPC_NOP = $A3 ; doublet +; OPC_NOP = $AB ; doublet + +OPC_LDA_izp = $B2 +; OPC_NOP = $B3 ; doublet +; OPC_NOP = $BB ; doublet + +; OPC_NOP = $C2 ; doublet +; OPC_NOP = $C3 ; doublet +; OPC_NOP = $CB ; doublet + +OPC_CMP_izp = $D2 +; OPC_NOP = $D3 ; doublet +; OPC_NOP = $D4 ; doublet +OPC_PHX = $DA +; OPC_NOP = $DB ; doublet +; OPC_NOP = $DC ; doublet + +; OPC_NOP = $E2 ; doublet +; OPC_NOP = $E3 ; doublet +; OPC_NOP = $EB ; doublet + +OPC_SBC_izp = $F2 +; OPC_NOP = $F3 ; doublet +; OPC_NOP = $F4 ; doublet +OPC_PLX = $FA +; OPC_NOP = $FB ; doublet +; OPC_NOP = $FC ; doublet + + +.if (.cpu .bitand ::CPU_ISET_65C02) + +; bit instructions for 65C02 + +OPC_RMB0 = $07 +OPC_RMB1 = $17 +OPC_RMB2 = $27 +OPC_RMB3 = $37 +OPC_RMB4 = $47 +OPC_RMB5 = $57 +OPC_RMB6 = $67 +OPC_RMB7 = $77 + +OPC_SMB0 = $87 +OPC_SMB1 = $97 +OPC_SMB2 = $A7 +OPC_SMB3 = $B7 +OPC_SMB4 = $C7 +OPC_SMB5 = $D7 +OPC_SMB6 = $E7 +OPC_SMB7 = $F7 + +OPC_BBR0 = $0F +OPC_BBR1 = $1F +OPC_BBR2 = $2F +OPC_BBR3 = $3F +OPC_BBR4 = $4F +OPC_BBR5 = $5F +OPC_BBR6 = $6F +OPC_BBR7 = $7F + +OPC_BBS0 = $8F +OPC_BBS1 = $9F +OPC_BBS2 = $AF +OPC_BBS3 = $BF +OPC_BBS4 = $CF +OPC_BBS5 = $DF +OPC_BBS6 = $EF +OPC_BBS7 = $FF + +.else + +; no bit instructions for 65SC02 + +; OPC_NOP = $07 ; doublet +; OPC_NOP = $17 ; doublet +; OPC_NOP = $27 ; doublet +; OPC_NOP = $37 ; doublet +; OPC_NOP = $47 ; doublet +; OPC_NOP = $57 ; doublet +; OPC_NOP = $67 ; doublet +; OPC_NOP = $77 ; doublet +; OPC_NOP = $87 ; doublet +; OPC_NOP = $97 ; doublet +; OPC_NOP = $A7 ; doublet +; OPC_NOP = $B7 ; doublet +; OPC_NOP = $C7 ; doublet +; OPC_NOP = $D7 ; doublet +; OPC_NOP = $E7 ; doublet +; OPC_NOP = $F7 ; doublet +; OPC_NOP = $0F ; doublet +; OPC_NOP = $1F ; doublet +; OPC_NOP = $2F ; doublet +; OPC_NOP = $3F ; doublet +; OPC_NOP = $4F ; doublet +; OPC_NOP = $5F ; doublet +; OPC_NOP = $6F ; doublet +; OPC_NOP = $7F ; doublet +; OPC_NOP = $8F ; doublet +; OPC_NOP = $9F ; doublet +; OPC_NOP = $AF ; doublet +; OPC_NOP = $BF ; doublet +; OPC_NOP = $CF ; doublet +; OPC_NOP = $DF ; doublet +; OPC_NOP = $EF ; doublet +; OPC_NOP = $FF ; doublet + +.endif + +.elseif (.cpu .bitand ::CPU_ISET_6502X) + +; stable, undocumented opcodes + +; OPC_KIL = $02 ; unstable +OPC_SLO_izx = $03 +OPC_NOP_zp = $04 +OPC_SLO_zp = $07 +OPC_ANC_imm = $0B +OPC_NOP_abs = $0C +OPC_SLO_abs = $0F + +; OPC_KIL = $12 ; unstable +OPC_SLO_izy = $13 +OPC_NOP_zpx = $14 +OPC_SLO_zpx = $17 +;OPC_NOP = $1A +OPC_SLO_aby = $1B +OPC_NOP_abx = $1C +OPC_SLO_abx = $1F + +; OPC_KIL = $22 ; unstable +OPC_RLA_izx = $23 +OPC_RLA_zp = $27 +OPC_ANC_imm = $2B +OPC_RLA_abs = $2F + +; OPC_KIL = $32 ; unstable +OPC_RLA_izy = $33 +OPC_NOP_zpx = $34 +OPC_RLA_zpx = $37 +; OPC_NOP = $3A ; doublet +OPC_RLA_aby = $3B +OPC_NOP_abx = $3C +OPC_RLA_abx = $3F + +; OPC_KIL = $42 ; unstable +OPC_SRE_izx = $43 +OPC_NOP_zp = $44 +OPC_SRE_zp = $47 +OPC_ALR_imm = $4B +OPC_SRE_abs = $4F + +; OPC_KIL = $52 ; unstable +OPC_SRE_izy = $53 +OPC_NOP_zpx = $54 +OPC_SRE_zpx = $57 +; OPC_NOP = $5A ; doublet +OPC_SRE_aby = $5B +OPC_NOP_abx = $5C +OPC_SRE_abx = $5F + +; OPC_KIL = $62 +OPC_RRA_izx = $63 +OPC_NOP_zp = $64 +OPC_RRA_zp = $67 +OPC_ARR_imm = $6B +OPC_RRA_abs = $6F + +; OPC_KIL = $72 +OPC_RRA_izy = $73 +OPC_NOP_zpx = $74 +OPC_RRA_zpx = $77 +; OPC_NOP = $7A ; doublet +OPC_RRA_aby = $7B +OPC_NOP_abx = $7C +OPC_RRA_abx = $7F + +OPC_NOP_imm = $80 +; OPC_NOP_imm = $82 ; doublet +OPC_SAX_izx = $83 +OPC_SAX_zp = $87 +; OPC_NOP_imm = $89 ; doublet +; OPC_XAA = $8B ; unstable +OPC_SAX_abs = $8F + +; OPC_KIL = $92 ; unstable +; OPC_AHX_izy = $93 ; unstable +OPC_SAX_zpy = $97 +; OPC_TAS_aby = $9B ; unstable +; OPC_SHY_abx = $9C ; unstable +; OPC_SHX_aby = $9E ; unstable +; OPC_AHX_aby = $9F ; unstable + +OPC_LAX_izx = $A3 +OPC_LAX_zp = $A7 +; OPC_LAX_imm = $AB ; unstable +OPC_LAX_abs = $AF + +; OPC_KIL = $B2 ; unstable +OPC_LAX_izy = $B3 +OPC_LAX_zpy = $B7 +OPC_LAS_aby = $BB +OPC_LAX_aby = $BF + +; OPC_NOP_imm = $C2 ; doublet +OPC_DCP_izx = $C3 +OPC_DCP_zp = $C7 +OPC_AXS_imm = $CB +OPC_DCP_abs = $CF + +; OPC_KIL = $D2 ; unstable +OPC_DCP_izy = $D3 +OPC_NOP_zpx = $D4 +OPC_DCP_zpx = $D7 +OPC_NOP_DA = $DA +OPC_DCP_aby = $DB +OPC_NOP_abx = $DC +OPC_DCP_abx = $DF + +; OPC_NOP_imm = $E2 ; doublet +OPC_ISC_izx = $E3 +OPC_ISC_zp = $E7 +; OPC_SBC_imm = $EB ; doublet +OPC_ISC_abs = $EF + +; OPC_KIL = $F2 ; unstable +OPC_ISC_izy = $F3 +OPC_NOP_zpx = $F4 +OPC_ISC_zpx = $F7 +OPC_NOP_FA = $FA +OPC_ISC_aby = $FB +OPC_NOP_abx = $FC +OPC_ISC_abx = $FF + +.endif diff --git a/asminc/smc.inc b/asminc/smc.inc index d5752a5f5..0583f79e0 100644 --- a/asminc/smc.inc +++ b/asminc/smc.inc @@ -1,267 +1,267 @@ -; smc.mac -; ca65 Macro-Pack for Self Modifying Code (SMC) -; -; (c) Christian Krüger, latest change: 17-Jul-2016 -; -; This software is provided 'as-is', without any expressed or implied -; warranty. In no event will the authors be held liable for any damages -; arising from the use of this software. -; -; Permission is granted to anyone to use this software for any purpose, -; including commercial applications, and to alter it and redistribute it -; freely, subject to the following restrictions: -; -; 1. The origin of this software must not be misrepresented; you must not -; claim that you wrote the original software. If you use this software -; in a product, an acknowledgment in the product documentation would be -; appreciated but is not required. -; 2. Altered source versions must be plainly marked as such, and must not -; be misrepresented as being the original software. -; 3. This notice may not be removed or altered from any source -; distribution. -; - -.define _SMCDesignator .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC")) -.define _SMCAlias .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC")) -.define SMC_AbsAdr $FADE -.define SMC_ZpAdr $00 -.define SMC_Opcode nop -.define SMC_Value $42 - -.macro SMC_OperateOnValue opcode, label - opcode _SMCDesignator+1 -.endmacro - -.macro SMC_OperateOnLowByte opcode, label - SMC_OperateOnValue opcode, label -.endmacro - -.macro SMC_OperateOnHighByte opcode, label - opcode _SMCDesignator + 2 -.endmacro - -.macro SMC_Import alias -.import _SMCAlias -.endmacro - -.macro SMC_Export alias, label -.export _SMCAlias := _SMCDesignator -.endmacro - -.macro SMC label, statement -_SMCDesignator: statement -.endmacro - -.macro SMC_TransferOpcode label, opcode, register -.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) - lda #opcode - sta _SMCDesignator -.elseif .match ({register}, x) - ldx #opcode - stx _SMCDesignator -.elseif .match ({register}, y) - ldy #opcode - sty _SMCDesignator -.else - .error "Invalid usage of macro 'SMC_TransferOpcode'" -.endif -.endmacro - -.macro SMC_LoadOpcode label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - lda _SMCDesignator -.elseif .match ({register}, x) - ldx _SMCDesignator -.elseif .match ({register}, y) - ldy _SMCDesignator -.else - .error "Invalid usage of macro 'SMC_LoadOpcode'" -.endif -.endmacro - -.macro SMC_StoreOpcode label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - sta _SMCDesignator -.elseif .match ({register}, x) - stx _SMCDesignator -.elseif .match ({register}, y) - sty _SMCDesignator -.else - .error "Invalid usage of macro 'SMC_StoreOpcode'" -.endif -.endmacro - -.macro SMC_ChangeBranch label, destination, register -.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) - lda #(<(destination - _SMCDesignator -2)) - sta _SMCDesignator+1 -.elseif .match ({register}, x) - ldx #(<(destination - _SMCDesignator - 2)) - stx _SMCDesignator+1 -.elseif .match ({register}, y) - ldy #(<(destination - _SMCDesignator - 2)) - sty _SMCDesignator+1 -.else - .error "Invalid usage of macro 'SMC_ChangeBranch'" -.endif -.endmacro - -.macro SMC_TransferValue label, value, register -.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) - lda value - sta _SMCDesignator+1 -.elseif .match ({register}, x) - ldx value - stx _SMCDesignator+1 -.elseif .match ({register}, y) - ldy value - sty _SMCDesignator+1 -.else - .error "Invalid usage of macro 'SMC_TransferValue'" -.endif -.endmacro - -.macro SMC_LoadValue label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - lda _SMCDesignator+1 -.elseif .match ({register}, x) - ldx _SMCDesignator+1 -.elseif .match ({register}, y) - ldy _SMCDesignator+1 -.else - .error "Invalid usage of macro 'SMC_LoadValue'" -.endif -.endmacro - -.macro SMC_StoreValue label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - sta _SMCDesignator+1 -.elseif .match ({register}, x) - stx _SMCDesignator+1 -.elseif .match ({register}, y) - sty _SMCDesignator+1 -.else - .error "Invalid usage of macro 'SMC_StoreValue'" -.endif -.endmacro - - -.macro SMC_TransferLowByte label, value, register -SMC_TransferValue label, value, register -.endmacro - -.macro SMC_LoadLowByte label, register -SMC_LoadValue label, register -.endmacro - -.macro SMC_StoreLowByte label, register -SMC_StoreValue label, register -.endmacro - -.macro SMC_TransferHighByte label, value, register -.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) - lda value - sta _SMCDesignator+2 -.elseif .match ({register}, x) - ldx value - stx _SMCDesignator+2 -.elseif .match ({register}, y) - ldy value - sty _SMCDesignator+2 -.else - .error "Invalid usage of macro 'SMC_TransferHighByte'" -.endif -.endmacro - -.macro SMC_LoadHighByte label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - lda _SMCDesignator+2 -.elseif .match ({register}, x) - ldx _SMCDesignator+2 -.elseif .match ({register}, y) - ldy _SMCDesignator+2 -.else - .error "Invalid usage of macro 'SMC_LoadHighByte'" -.endif -.endmacro - -.macro SMC_StoreHighByte label, register -.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) - sta _SMCDesignator+2 -.elseif .match ({register}, x) - stx _SMCDesignator+2 -.elseif .match ({register}, y) - sty _SMCDesignator+2 -.else - .error "Invalid usage of macro 'SMC_StoreHighByte'" -.endif -.endmacro - -.macro SMC_TransferAddressSingle label, address, register -.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, ) - .if (.match (.left (1, {address}), #)) - ; immediate mode - lda #<(.right (.tcount ({address})-1, {address})) - sta _SMCDesignator+1 - lda #>(.right (.tcount ({address})-1, {address})) - sta _SMCDesignator+2 - .else - ; assume absolute or zero page - lda address - sta _SMCDesignator+1 - lda 1+(address) - sta _SMCDesignator+2 - .endif -.elseif .match ((register), x) - .if (.match (.left (1, {address}), #)) - ; immediate mode - ldx #<(.right (.tcount ({address})-1, {address})) - stx _SMCDesignator+1 - ldx #>(.right (.tcount ({address})-1, {address})) - stx _SMCDesignator+2 - .else - ; assume absolute or zero page - ldx address - stx _SMCDesignator+1 - ldx 1+(address) - stx _SMCDesignator+2 - .endif -.elseif .match ((register), y) - .if (.match (.left (1, {address}), #)) - ; immediate mode - ldy #<(.right (.tcount ({address})-1, {address})) - sty _SMCDesignator+1 - ldy #>(.right (.tcount ({address})-1, {address})) - sty _SMCDesignator+2 - .else - ; assume absolute or zero page - ldy address - sty _SMCDesignator+1 - ldy 1+(address) - sty _SMCDesignator+2 - .endif -.else - .error "Invalid usage of macro 'SMC_TransferAddressSingle'" -.endif -.endmacro - -.macro SMC_TransferAddress label, address -.if (.match (.left (1, {address}), #)) - ; immediate mode - lda #<(.right (.tcount ({address})-1, {address})) - sta _SMCDesignator+1 - ldx #>(.right (.tcount ({address})-1, {address})) - stx _SMCDesignator+2 -.else - ; assume absolute or zero page - lda {address} - sta _SMCDesignator+1 - ldx 1+{address} - stx _SMCDesignator)+2 -.endif -.endmacro - -.macro SMC_StoreAddress label - sta _SMCDesignator+1 - stx _SMCDesignator+2 -.endmacro +; smc.mac +; ca65 Macro-Pack for Self Modifying Code (SMC) +; +; (c) Christian Krüger, latest change: 17-Jul-2016 +; +; This software is provided 'as-is', without any expressed or implied +; warranty. In no event will the authors be held liable for any damages +; arising from the use of this software. +; +; Permission is granted to anyone to use this software for any purpose, +; including commercial applications, and to alter it and redistribute it +; freely, subject to the following restrictions: +; +; 1. The origin of this software must not be misrepresented; you must not +; claim that you wrote the original software. If you use this software +; in a product, an acknowledgment in the product documentation would be +; appreciated but is not required. +; 2. Altered source versions must be plainly marked as such, and must not +; be misrepresented as being the original software. +; 3. This notice may not be removed or altered from any source +; distribution. +; + +.define _SMCDesignator .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC")) +.define _SMCAlias .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC")) +.define SMC_AbsAdr $FADE +.define SMC_ZpAdr $00 +.define SMC_Opcode nop +.define SMC_Value $42 + +.macro SMC_OperateOnValue opcode, label + opcode _SMCDesignator+1 +.endmacro + +.macro SMC_OperateOnLowByte opcode, label + SMC_OperateOnValue opcode, label +.endmacro + +.macro SMC_OperateOnHighByte opcode, label + opcode _SMCDesignator + 2 +.endmacro + +.macro SMC_Import alias +.import _SMCAlias +.endmacro + +.macro SMC_Export alias, label +.export _SMCAlias := _SMCDesignator +.endmacro + +.macro SMC label, statement +_SMCDesignator: statement +.endmacro + +.macro SMC_TransferOpcode label, opcode, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda #opcode + sta _SMCDesignator +.elseif .match ({register}, x) + ldx #opcode + stx _SMCDesignator +.elseif .match ({register}, y) + ldy #opcode + sty _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_TransferOpcode'" +.endif +.endmacro + +.macro SMC_LoadOpcode label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + lda _SMCDesignator +.elseif .match ({register}, x) + ldx _SMCDesignator +.elseif .match ({register}, y) + ldy _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_LoadOpcode'" +.endif +.endmacro + +.macro SMC_StoreOpcode label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + sta _SMCDesignator +.elseif .match ({register}, x) + stx _SMCDesignator +.elseif .match ({register}, y) + sty _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_StoreOpcode'" +.endif +.endmacro + +.macro SMC_ChangeBranch label, destination, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda #(<(destination - _SMCDesignator -2)) + sta _SMCDesignator+1 +.elseif .match ({register}, x) + ldx #(<(destination - _SMCDesignator - 2)) + stx _SMCDesignator+1 +.elseif .match ({register}, y) + ldy #(<(destination - _SMCDesignator - 2)) + sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_ChangeBranch'" +.endif +.endmacro + +.macro SMC_TransferValue label, value, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda value + sta _SMCDesignator+1 +.elseif .match ({register}, x) + ldx value + stx _SMCDesignator+1 +.elseif .match ({register}, y) + ldy value + sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_TransferValue'" +.endif +.endmacro + +.macro SMC_LoadValue label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + lda _SMCDesignator+1 +.elseif .match ({register}, x) + ldx _SMCDesignator+1 +.elseif .match ({register}, y) + ldy _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_LoadValue'" +.endif +.endmacro + +.macro SMC_StoreValue label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + sta _SMCDesignator+1 +.elseif .match ({register}, x) + stx _SMCDesignator+1 +.elseif .match ({register}, y) + sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_StoreValue'" +.endif +.endmacro + + +.macro SMC_TransferLowByte label, value, register +SMC_TransferValue label, value, register +.endmacro + +.macro SMC_LoadLowByte label, register +SMC_LoadValue label, register +.endmacro + +.macro SMC_StoreLowByte label, register +SMC_StoreValue label, register +.endmacro + +.macro SMC_TransferHighByte label, value, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda value + sta _SMCDesignator+2 +.elseif .match ({register}, x) + ldx value + stx _SMCDesignator+2 +.elseif .match ({register}, y) + ldy value + sty _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_TransferHighByte'" +.endif +.endmacro + +.macro SMC_LoadHighByte label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + lda _SMCDesignator+2 +.elseif .match ({register}, x) + ldx _SMCDesignator+2 +.elseif .match ({register}, y) + ldy _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_LoadHighByte'" +.endif +.endmacro + +.macro SMC_StoreHighByte label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + sta _SMCDesignator+2 +.elseif .match ({register}, x) + stx _SMCDesignator+2 +.elseif .match ({register}, y) + sty _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_StoreHighByte'" +.endif +.endmacro + +.macro SMC_TransferAddressSingle label, address, register +.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, ) + .if (.match (.left (1, {address}), #)) + ; immediate mode + lda #<(.right (.tcount ({address})-1, {address})) + sta _SMCDesignator+1 + lda #>(.right (.tcount ({address})-1, {address})) + sta _SMCDesignator+2 + .else + ; assume absolute or zero page + lda address + sta _SMCDesignator+1 + lda 1+(address) + sta _SMCDesignator+2 + .endif +.elseif .match ((register), x) + .if (.match (.left (1, {address}), #)) + ; immediate mode + ldx #<(.right (.tcount ({address})-1, {address})) + stx _SMCDesignator+1 + ldx #>(.right (.tcount ({address})-1, {address})) + stx _SMCDesignator+2 + .else + ; assume absolute or zero page + ldx address + stx _SMCDesignator+1 + ldx 1+(address) + stx _SMCDesignator+2 + .endif +.elseif .match ((register), y) + .if (.match (.left (1, {address}), #)) + ; immediate mode + ldy #<(.right (.tcount ({address})-1, {address})) + sty _SMCDesignator+1 + ldy #>(.right (.tcount ({address})-1, {address})) + sty _SMCDesignator+2 + .else + ; assume absolute or zero page + ldy address + sty _SMCDesignator+1 + ldy 1+(address) + sty _SMCDesignator+2 + .endif +.else + .error "Invalid usage of macro 'SMC_TransferAddressSingle'" +.endif +.endmacro + +.macro SMC_TransferAddress label, address +.if (.match (.left (1, {address}), #)) + ; immediate mode + lda #<(.right (.tcount ({address})-1, {address})) + sta _SMCDesignator+1 + ldx #>(.right (.tcount ({address})-1, {address})) + stx _SMCDesignator+2 +.else + ; assume absolute or zero page + lda {address} + sta _SMCDesignator+1 + ldx 1+{address} + stx _SMCDesignator)+2 +.endif +.endmacro + +.macro SMC_StoreAddress label + sta _SMCDesignator+1 + stx _SMCDesignator+2 +.endmacro diff --git a/include/osic1p.h b/include/osic1p.h index 57fe0cd24..d6ab5fee1 100644 --- a/include/osic1p.h +++ b/include/osic1p.h @@ -1,47 +1,47 @@ -/*****************************************************************************/ -/* */ -/* osic1p.h */ -/* */ -/* Challenger 1P system specific definitions */ -/* */ -/* */ -/* */ -/* (C) 2015 Stephan Muehlstrasser */ -/* */ -/* */ -/* This software is provided 'as-is', without any expressed or implied */ -/* warranty. In no event will the authors be held liable for any damages */ -/* arising from the use of this software. */ -/* */ -/* Permission is granted to anyone to use this software for any purpose, */ -/* including commercial applications, and to alter it and redistribute it */ -/* freely, subject to the following restrictions: */ -/* */ -/* 1. The origin of this software must not be misrepresented; you must not */ -/* claim that you wrote the original software. If you use this software */ -/* in a product, an acknowledgment in the product documentation would be */ -/* appreciated but is not required. */ -/* 2. Altered source versions must be plainly marked as such, and must not */ -/* be misrepresented as being the original software. */ -/* 3. This notice may not be removed or altered from any source */ -/* distribution. */ -/* */ -/*****************************************************************************/ - -#ifndef _OSIC1P_H -#define _OSIC1P_H - -/* Check for errors */ -#if !defined(__OSIC1P__) -# error "This module may only be used when compiling for the Challenger 1P!" -#endif - -/* The following #defines will cause the matching functions calls in conio.h -** to be overlaid by macros with the same names, saving the function call -** overhead. -*/ -#define _textcolor(color) COLOR_WHITE -#define _bgcolor(color) COLOR_BLACK -#define _bordercolor(color) COLOR_BLACK - -#endif +/*****************************************************************************/ +/* */ +/* osic1p.h */ +/* */ +/* Challenger 1P system specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2015 Stephan Muehlstrasser */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +#ifndef _OSIC1P_H +#define _OSIC1P_H + +/* Check for errors */ +#if !defined(__OSIC1P__) +# error "This module may only be used when compiling for the Challenger 1P!" +#endif + +/* The following #defines will cause the matching functions calls in conio.h +** to be overlaid by macros with the same names, saving the function call +** overhead. +*/ +#define _textcolor(color) COLOR_WHITE +#define _bgcolor(color) COLOR_BLACK +#define _bordercolor(color) COLOR_BLACK + +#endif diff --git a/include/zlib.h b/include/zlib.h index 8fa6a2bd1..8ced89800 100644 --- a/include/zlib.h +++ b/include/zlib.h @@ -1,172 +1,172 @@ -/*****************************************************************************/ -/* */ -/* zlib.h */ -/* */ -/* Decompression routines for the 'deflate' format */ -/* */ -/* */ -/* */ -/* (C) 2000-2015 Piotr Fusik <fox@scene.pl> */ -/* */ -/* This file is based on the zlib.h from 'zlib' general purpose compression */ -/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler. */ -/* */ -/* Jean-loup Gailly Mark Adler */ -/* jloup@gzip.org madler@alumni.caltech.edu */ -/* */ -/* This software is provided 'as-is', without any expressed or implied */ -/* warranty. In no event will the authors be held liable for any damages */ -/* arising from the use of this software. */ -/* */ -/* Permission is granted to anyone to use this software for any purpose, */ -/* including commercial applications, and to alter it and redistribute it */ -/* freely, subject to the following restrictions: */ -/* */ -/* 1. The origin of this software must not be misrepresented; you must not */ -/* claim that you wrote the original software. If you use this software */ -/* in a product, an acknowledgment in the product documentation would be */ -/* appreciated but is not required. */ -/* 2. Altered source versions must be plainly marked as such, and must not */ -/* be misrepresented as being the original software. */ -/* 3. This notice may not be removed or altered from any source */ -/* distribution. */ -/* */ -/*****************************************************************************/ - - - -#ifndef _ZLIB_H -#define _ZLIB_H - -#define Z_OK 0 -#define Z_DATA_ERROR (-3) -/* Return codes for uncompress() */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported) */ - -#define Z_NULL 0 - - -unsigned __fastcall__ inflatemem (char* dest, const char* source); -/* - Decompresses the source buffer into the destination buffer. - Returns the size of the uncompressed data (number of bytes written starting - from dest). - - This function expects data in the DEFLATE format, described in RFC - (Request for Comments) 1951 in the file - ftp://ds.internic.net/rfc/rfc1951.txt. - - This function does not exist in the original zlib. Its implementation - using original zlib might be following: - - unsigned inflatemem (char* dest, const char* source) - { - z_stream stream; - - stream.next_in = (Bytef*) source; - stream.avail_in = 65535; - - stream.next_out = dest; - stream.avail_out = 65535; - - stream.zalloc = (alloc_func) 0; - stream.zfree = (free_func) 0; - - inflateInit2(&stream, -MAX_WBITS); - inflate(&stream, Z_FINISH); - inflateEnd(&stream); - - return stream.total_out; - } -*/ - - -int __fastcall__ uncompress (char* dest, unsigned* destLen, - const char* source, unsigned sourceLen); -/* - Original zlib description: - - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. - - Implementation notes: - - This function expects data in the ZLIB format, described in RFC 1950 - in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is - essentially the DEFLATE format plus a very small header and Adler-32 - checksum. - - Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation. -*/ - - -unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf, - unsigned len); - -/* - Original zlib description: - - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - unsigned long adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); - - Implementation notes: - - This function isn't actually much faster than crc32(), but it is smaller - and does not use any lookup tables. -*/ - - -unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf, - unsigned len); -/* - Original zlib description: - - Update a running crc with the bytes buf[0..len-1] and return the updated - crc. If buf is NULL, this function returns the required initial value - for the crc. Pre- and post-conditioning (one's complement) is performed - within this function so it shouldn't be done by the application. - Usage example: - - unsigned long crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); - - Implementation notes: - - This function uses statically allocated 1 KB lookup table. The table is - initialised before it is used for the first time (that is, if buffer is - NULL or length is zero, then the lookup table isn't initialised). -*/ - - -/* end of zlib.h */ -#endif - - - +/*****************************************************************************/ +/* */ +/* zlib.h */ +/* */ +/* Decompression routines for the 'deflate' format */ +/* */ +/* */ +/* */ +/* (C) 2000-2015 Piotr Fusik <fox@scene.pl> */ +/* */ +/* This file is based on the zlib.h from 'zlib' general purpose compression */ +/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler. */ +/* */ +/* Jean-loup Gailly Mark Adler */ +/* jloup@gzip.org madler@alumni.caltech.edu */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef _ZLIB_H +#define _ZLIB_H + +#define Z_OK 0 +#define Z_DATA_ERROR (-3) +/* Return codes for uncompress() */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported) */ + +#define Z_NULL 0 + + +unsigned __fastcall__ inflatemem (char* dest, const char* source); +/* + Decompresses the source buffer into the destination buffer. + Returns the size of the uncompressed data (number of bytes written starting + from dest). + + This function expects data in the DEFLATE format, described in RFC + (Request for Comments) 1951 in the file + ftp://ds.internic.net/rfc/rfc1951.txt. + + This function does not exist in the original zlib. Its implementation + using original zlib might be following: + + unsigned inflatemem (char* dest, const char* source) + { + z_stream stream; + + stream.next_in = (Bytef*) source; + stream.avail_in = 65535; + + stream.next_out = dest; + stream.avail_out = 65535; + + stream.zalloc = (alloc_func) 0; + stream.zfree = (free_func) 0; + + inflateInit2(&stream, -MAX_WBITS); + inflate(&stream, Z_FINISH); + inflateEnd(&stream); + + return stream.total_out; + } +*/ + + +int __fastcall__ uncompress (char* dest, unsigned* destLen, + const char* source, unsigned sourceLen); +/* + Original zlib description: + + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. + + Implementation notes: + + This function expects data in the ZLIB format, described in RFC 1950 + in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is + essentially the DEFLATE format plus a very small header and Adler-32 + checksum. + + Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation. +*/ + + +unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf, + unsigned len); + +/* + Original zlib description: + + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + unsigned long adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); + + Implementation notes: + + This function isn't actually much faster than crc32(), but it is smaller + and does not use any lookup tables. +*/ + + +unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf, + unsigned len); +/* + Original zlib description: + + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + unsigned long crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); + + Implementation notes: + + This function uses statically allocated 1 KB lookup table. The table is + initialised before it is used for the first time (that is, if buffer is + NULL or length is zero, then the lookup table isn't initialised). +*/ + + +/* end of zlib.h */ +#endif + + + diff --git a/libsrc/c64/emd/c64-65816.s b/libsrc/c64/emd/c64-65816.s index bf44a0ecc..39f323d28 100644 --- a/libsrc/c64/emd/c64-65816.s +++ b/libsrc/c64/emd/c64-65816.s @@ -1,376 +1,376 @@ -; -; Extended memory driver for 65816 based extra RAM. Driver works without -; problems when statically linked. -; -; Marco van den Heuvel, 2015-12-01 -; - - .include "zeropage.inc" - - .include "em-kernel.inc" - .include "em-error.inc" - - - .macpack generic - .macpack module - - -; ------------------------------------------------------------------------ -; Header. Includes jump table - - module_header _c64_65816_emd - -; Driver signature - - .byte $65, $6d, $64 ; "emd" - .byte EMD_API_VERSION ; EM API version number - -; Library reference - - .addr $0000 - -; Jump table - - .addr INSTALL - .addr UNINSTALL - .addr PAGECOUNT - .addr MAP - .addr USE - .addr COMMIT - .addr COPYFROM - .addr COPYTO - -; ------------------------------------------------------------------------ -; Data. - -.bss -isnotscpu: .res 1 ; SuperCPU not present -curpage: .res 1 ; Current page number -curbank: .res 1 ; Current bank number (+1) -bankcount: .res 1 ; Number of available banks (pages = banks * 256) -window: .res 256 ; Memory "window" - -.code - -; ------------------------------------------------------------------------ -; INSTALL routine. Is called after the driver is loaded into memory. If -; possible, check if the hardware is present and determine the amount of -; memory available. -; Must return an EM_ERR_xx code in a/x. -; - -INSTALL: - sei - clc - sed - lda #$99 - adc #$01 ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly - cld - bne @not_present - clc -.P816 - sep #$01 ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02 -.P02 - bcc @not_present - lda $d0bc - and #$80 - sta isnotscpu - lda $07e8 - pha ; save value incase it was used somewhere else - ldx #$ff -@fillloop: ; fill from top (bank 255) to bottom - txa - pha -.P816 - plb ; pull dbr -.P02 - stx $07e8 - dex - cpx #$ff - bne @fillloop - inx -@compareloop: ; check from bottom to top - txa - pha -.P816 - plb -.P02 - cmp $07e8 - bne @found_pages -.P816 - inc -.P02 - sta $07e8 - cmp $07e8 - bne @found_pages - inx - bne @compareloop -@found_pages: - dex - lda #$00 - pha -.P816 - plb -.P02 - pla - sta $07e8 - cli - lda isnotscpu - bne @noextradex - dex -@noextradex: - stx bankcount - lda #<EM_ERR_OK - ldx #>EM_ERR_OK - rts -@not_present: - cli - lda #<EM_ERR_NO_DEVICE - ldx #>EM_ERR_NO_DEVICE -; rts ; Run into UNINSTALL instead - - -; ------------------------------------------------------------------------ -; UNINSTALL routine. Is called before the driver is removed from memory. -; Can do cleanup or whatever. Must not return anything. -; - -UNINSTALL: - rts - - -; ------------------------------------------------------------------------ -; PAGECOUNT: Return the total number of available pages in a/x. -; - -PAGECOUNT: - lda #$00 ; a whole bank is either usable or not - ldx bankcount - rts - -; ------------------------------------------------------------------------ -; MAP: Map the page in a/x into memory and return a pointer to the page in -; a/x. The contents of the currently mapped page (if any) may be discarded -; by the driver. -; - -MAP: sta curpage ; Remember the new page - stx curbank ; Remember the new bank - - sta ptr2+1 ; src address low - lda #$00 - sta ptr2 ; src address high - inx - ldy isnotscpu ; check if not scpu - bne @notscpu - inx -@notscpu: - stx tmp2 ; src bank - - sta tmp1 ; dst bank - - sta ptr3+1 ; length high - lda #$ff - sta ptr3 ; length low - - lda #<window - sta ptr1 ; dst address low - ldx #>window - stx ptr1+1 ; dst address high - - jsr transfer - - rts - -; ------------------------------------------------------------------------ -; USE: Tell the driver that the window is now associated with a given page. - -USE: sta curpage ; Remember the page - stx curbank ; Remember the bank - lda #<window - ldx #>window ; Return the window - rts - -; ------------------------------------------------------------------------ -; COMMIT: Commit changes in the memory window to extended storage. - -COMMIT: lda curpage ; Get the current page - sta ptr1+1 ; dst high - ldx #$00 - stx ptr1 ; dst low - - lda #<window - sta ptr2 ; src low - lda #>window - sta ptr2+1 ; src high - - stx ptr3+1 ; length high - lda #$ff - sta ptr3 ; length low - - stx tmp2 ; src bank - ldy curbank ; Get the current bank - iny - ldx isnotscpu - bne @notascpu - iny -@notascpu: - sty tmp1 ; dst bank - - jsr transfer - - rts - -; ------------------------------------------------------------------------ -; COPYFROM: Copy from extended into linear memory. A pointer to a structure -; describing the request is passed in a/x. -; The function must not return anything. -; - -COPYFROM: - sta ptr4 - stx ptr4+1 ; Save the passed em_copy pointer - - ldy #EM_COPY::COUNT+1 ; start at the end of the struct - lda (ptr4),y ; get high byte of count - tax - dey - lda (ptr4),y ; get low byte of count - bne @nodex - dex -@nodex: -.P816 - dec -.P02 - sta ptr3 ; length low - stx ptr3+1 ; length high - dey - lda (ptr4),y ; get bank -.P816 - inc -.P02 - ldx isnotscpu - bne @notscpu64 -.P816 - inc -.P02 -@notscpu64: - sta tmp2 ; src bank - dey - lda (ptr4),y ; get page - sta ptr2+1 ; src high - dey - lda (ptr4),y ; get offset in page - sta ptr2 ; src low - dey - lda (ptr4),y ; get memory buffer high - sta ptr1+1 ; dst high - dey - lda (ptr4),y ; get memory buffer low - sta ptr1 ; dst low - lda #$00 - sta tmp1 ; dst bank - - jsr transfer - - rts - -; ------------------------------------------------------------------------ -; COPYTO: Copy from linear into extended memory. A pointer to a structure -; describing the request is passed in a/x. -; The function must not return anything. -; - -COPYTO: sta ptr4 - stx ptr4+1 ; Save the passed em_copy pointer - - ldy #EM_COPY::COUNT+1 ; start at the end of the struct - lda (ptr4),y ; get high byte of count - tax - dey - lda (ptr4),y ; get low byte of count - bne @nodex2 - dex -@nodex2: -.P816 - dec -.P02 - sta ptr3 ; length low - txa - sta ptr3+1 ; length high - dey - lda (ptr4),y ; get bank -.P816 - inc -.P02 - ldx isnotscpu - bne @notascpu64 -.P816 - inc -.P02 -@notascpu64: - sta tmp1 ; dst bank - dey - lda (ptr4),y ; get page - sta ptr1+1 ; dst high - dey - lda (ptr4),y ; get page offset - sta ptr1 ; dst low - dey - lda (ptr4),y ; get memory buffer high - sta ptr2+1 ; src low - dey - lda (ptr4),y ; get memory buffer low - sta ptr2 ; src high - lda #$00 - sta tmp2 ; src bank - - jsr transfer - - rts - -; ------------------------------------------------------------------------ -; Helper function for moving a block, the following is used: -; ptr1: dst -; ptr2: src -; ptr3: length -; tmp1: dst bank -; tmp2: src bank - -transfer: -.P816 -.A8 -.I8 - sei - pha - phx - phy - ldx tmp1 ; load srcbank - stx @move+1 ; store srcbank in move + 1 - ldy tmp2 ; load dstbank - sty @move+2 ; store dstbank in move + 2 - clc ; switch to native mode - xce - php ; save status bits - rep #%00110000 ; set A and index to 16bit -.A16 -.I16 - ldy ptr1 - ldx ptr2 - lda ptr3 -@move: - mvn 0,0 - plp ; restore status bits -.A8 -.I8 - lda #$00 - pha - plb ; restore dbr - sec - xce ; switch to emul mode - ply - plx - pla - cli - rts -.P02 +; +; Extended memory driver for 65816 based extra RAM. Driver works without +; problems when statically linked. +; +; Marco van den Heuvel, 2015-12-01 +; + + .include "zeropage.inc" + + .include "em-kernel.inc" + .include "em-error.inc" + + + .macpack generic + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _c64_65816_emd + +; Driver signature + + .byte $65, $6d, $64 ; "emd" + .byte EMD_API_VERSION ; EM API version number + +; Library reference + + .addr $0000 + +; Jump table + + .addr INSTALL + .addr UNINSTALL + .addr PAGECOUNT + .addr MAP + .addr USE + .addr COMMIT + .addr COPYFROM + .addr COPYTO + +; ------------------------------------------------------------------------ +; Data. + +.bss +isnotscpu: .res 1 ; SuperCPU not present +curpage: .res 1 ; Current page number +curbank: .res 1 ; Current bank number (+1) +bankcount: .res 1 ; Number of available banks (pages = banks * 256) +window: .res 256 ; Memory "window" + +.code + +; ------------------------------------------------------------------------ +; INSTALL routine. Is called after the driver is loaded into memory. If +; possible, check if the hardware is present and determine the amount of +; memory available. +; Must return an EM_ERR_xx code in a/x. +; + +INSTALL: + sei + clc + sed + lda #$99 + adc #$01 ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly + cld + bne @not_present + clc +.P816 + sep #$01 ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02 +.P02 + bcc @not_present + lda $d0bc + and #$80 + sta isnotscpu + lda $07e8 + pha ; save value incase it was used somewhere else + ldx #$ff +@fillloop: ; fill from top (bank 255) to bottom + txa + pha +.P816 + plb ; pull dbr +.P02 + stx $07e8 + dex + cpx #$ff + bne @fillloop + inx +@compareloop: ; check from bottom to top + txa + pha +.P816 + plb +.P02 + cmp $07e8 + bne @found_pages +.P816 + inc +.P02 + sta $07e8 + cmp $07e8 + bne @found_pages + inx + bne @compareloop +@found_pages: + dex + lda #$00 + pha +.P816 + plb +.P02 + pla + sta $07e8 + cli + lda isnotscpu + bne @noextradex + dex +@noextradex: + stx bankcount + lda #<EM_ERR_OK + ldx #>EM_ERR_OK + rts +@not_present: + cli + lda #<EM_ERR_NO_DEVICE + ldx #>EM_ERR_NO_DEVICE +; rts ; Run into UNINSTALL instead + + +; ------------------------------------------------------------------------ +; UNINSTALL routine. Is called before the driver is removed from memory. +; Can do cleanup or whatever. Must not return anything. +; + +UNINSTALL: + rts + + +; ------------------------------------------------------------------------ +; PAGECOUNT: Return the total number of available pages in a/x. +; + +PAGECOUNT: + lda #$00 ; a whole bank is either usable or not + ldx bankcount + rts + +; ------------------------------------------------------------------------ +; MAP: Map the page in a/x into memory and return a pointer to the page in +; a/x. The contents of the currently mapped page (if any) may be discarded +; by the driver. +; + +MAP: sta curpage ; Remember the new page + stx curbank ; Remember the new bank + + sta ptr2+1 ; src address low + lda #$00 + sta ptr2 ; src address high + inx + ldy isnotscpu ; check if not scpu + bne @notscpu + inx +@notscpu: + stx tmp2 ; src bank + + sta tmp1 ; dst bank + + sta ptr3+1 ; length high + lda #$ff + sta ptr3 ; length low + + lda #<window + sta ptr1 ; dst address low + ldx #>window + stx ptr1+1 ; dst address high + + jsr transfer + + rts + +; ------------------------------------------------------------------------ +; USE: Tell the driver that the window is now associated with a given page. + +USE: sta curpage ; Remember the page + stx curbank ; Remember the bank + lda #<window + ldx #>window ; Return the window + rts + +; ------------------------------------------------------------------------ +; COMMIT: Commit changes in the memory window to extended storage. + +COMMIT: lda curpage ; Get the current page + sta ptr1+1 ; dst high + ldx #$00 + stx ptr1 ; dst low + + lda #<window + sta ptr2 ; src low + lda #>window + sta ptr2+1 ; src high + + stx ptr3+1 ; length high + lda #$ff + sta ptr3 ; length low + + stx tmp2 ; src bank + ldy curbank ; Get the current bank + iny + ldx isnotscpu + bne @notascpu + iny +@notascpu: + sty tmp1 ; dst bank + + jsr transfer + + rts + +; ------------------------------------------------------------------------ +; COPYFROM: Copy from extended into linear memory. A pointer to a structure +; describing the request is passed in a/x. +; The function must not return anything. +; + +COPYFROM: + sta ptr4 + stx ptr4+1 ; Save the passed em_copy pointer + + ldy #EM_COPY::COUNT+1 ; start at the end of the struct + lda (ptr4),y ; get high byte of count + tax + dey + lda (ptr4),y ; get low byte of count + bne @nodex + dex +@nodex: +.P816 + dec +.P02 + sta ptr3 ; length low + stx ptr3+1 ; length high + dey + lda (ptr4),y ; get bank +.P816 + inc +.P02 + ldx isnotscpu + bne @notscpu64 +.P816 + inc +.P02 +@notscpu64: + sta tmp2 ; src bank + dey + lda (ptr4),y ; get page + sta ptr2+1 ; src high + dey + lda (ptr4),y ; get offset in page + sta ptr2 ; src low + dey + lda (ptr4),y ; get memory buffer high + sta ptr1+1 ; dst high + dey + lda (ptr4),y ; get memory buffer low + sta ptr1 ; dst low + lda #$00 + sta tmp1 ; dst bank + + jsr transfer + + rts + +; ------------------------------------------------------------------------ +; COPYTO: Copy from linear into extended memory. A pointer to a structure +; describing the request is passed in a/x. +; The function must not return anything. +; + +COPYTO: sta ptr4 + stx ptr4+1 ; Save the passed em_copy pointer + + ldy #EM_COPY::COUNT+1 ; start at the end of the struct + lda (ptr4),y ; get high byte of count + tax + dey + lda (ptr4),y ; get low byte of count + bne @nodex2 + dex +@nodex2: +.P816 + dec +.P02 + sta ptr3 ; length low + txa + sta ptr3+1 ; length high + dey + lda (ptr4),y ; get bank +.P816 + inc +.P02 + ldx isnotscpu + bne @notascpu64 +.P816 + inc +.P02 +@notascpu64: + sta tmp1 ; dst bank + dey + lda (ptr4),y ; get page + sta ptr1+1 ; dst high + dey + lda (ptr4),y ; get page offset + sta ptr1 ; dst low + dey + lda (ptr4),y ; get memory buffer high + sta ptr2+1 ; src low + dey + lda (ptr4),y ; get memory buffer low + sta ptr2 ; src high + lda #$00 + sta tmp2 ; src bank + + jsr transfer + + rts + +; ------------------------------------------------------------------------ +; Helper function for moving a block, the following is used: +; ptr1: dst +; ptr2: src +; ptr3: length +; tmp1: dst bank +; tmp2: src bank + +transfer: +.P816 +.A8 +.I8 + sei + pha + phx + phy + ldx tmp1 ; load srcbank + stx @move+1 ; store srcbank in move + 1 + ldy tmp2 ; load dstbank + sty @move+2 ; store dstbank in move + 2 + clc ; switch to native mode + xce + php ; save status bits + rep #%00110000 ; set A and index to 16bit +.A16 +.I16 + ldy ptr1 + ldx ptr2 + lda ptr3 +@move: + mvn 0,0 + plp ; restore status bits +.A8 +.I8 + lda #$00 + pha + plb ; restore dbr + sec + xce ; switch to emul mode + ply + plx + pla + cli + rts +.P02 diff --git a/libsrc/osic1p/cgetc.s b/libsrc/osic1p/cgetc.s index 9161645c7..f05ad33e0 100644 --- a/libsrc/osic1p/cgetc.s +++ b/libsrc/osic1p/cgetc.s @@ -1,50 +1,50 @@ -; -; char cgetc (void); -; - - .constructor initcgetc - .export _cgetc - .import cursor - - .include "osic1p.inc" - .include "extzp.inc" - .include "zeropage.inc" - -; Initialize one-character buffer that is filled by kbhit() - .segment "ONCE" -initcgetc: - lda #$00 - sta CHARBUF ; No character in buffer initially - rts - -; Input routine from 65V PROM MONITOR, show cursor if enabled - .code -_cgetc: - lda CHARBUF ; character in buffer available? - beq nobuffer - tax ; save character in X - lda #$00 - sta CHARBUF ; empty buffer - beq restorex ; restore X and return -nobuffer: - lda cursor ; show cursor? - beq nocursor - ldy CURS_X - lda (SCREEN_PTR),y ; fetch current character - sta tmp1 ; save it - lda #$A1 ; full white square - sta (SCREEN_PTR),y ; store at cursor position -nocursor: - jsr INPUTC ; get input character in A - ldx cursor - beq done ; was cursor on? - tax ; save A in X - lda tmp1 ; fetch saved character - ldy CURS_X - sta (SCREEN_PTR),y ; store at cursor position - -restorex: - txa ; restore saved character from X -done: - ldx #$00 ; high byte of int return value - rts +; +; char cgetc (void); +; + + .constructor initcgetc + .export _cgetc + .import cursor + + .include "osic1p.inc" + .include "extzp.inc" + .include "zeropage.inc" + +; Initialize one-character buffer that is filled by kbhit() + .segment "ONCE" +initcgetc: + lda #$00 + sta CHARBUF ; No character in buffer initially + rts + +; Input routine from 65V PROM MONITOR, show cursor if enabled + .code +_cgetc: + lda CHARBUF ; character in buffer available? + beq nobuffer + tax ; save character in X + lda #$00 + sta CHARBUF ; empty buffer + beq restorex ; restore X and return +nobuffer: + lda cursor ; show cursor? + beq nocursor + ldy CURS_X + lda (SCREEN_PTR),y ; fetch current character + sta tmp1 ; save it + lda #$A1 ; full white square + sta (SCREEN_PTR),y ; store at cursor position +nocursor: + jsr INPUTC ; get input character in A + ldx cursor + beq done ; was cursor on? + tax ; save A in X + lda tmp1 ; fetch saved character + ldy CURS_X + sta (SCREEN_PTR),y ; store at cursor position + +restorex: + txa ; restore saved character from X +done: + ldx #$00 ; high byte of int return value + rts diff --git a/libsrc/osic1p/osic1p.inc b/libsrc/osic1p/osic1p.inc index eabeaf79e..aaa03ba61 100644 --- a/libsrc/osic1p/osic1p.inc +++ b/libsrc/osic1p/osic1p.inc @@ -1,4 +1,4 @@ -; Addresses -INPUTC := $FD00 ; Input character from keyboard -RESET := $FF00 ; Reset address, show boot prompt -KBD := $DF00 ; Polled keyboard register +; Addresses +INPUTC := $FD00 ; Input character from keyboard +RESET := $FF00 ; Reset address, show boot prompt +KBD := $DF00 ; Polled keyboard register diff --git a/libsrc/osic1p/osiscreen.inc b/libsrc/osic1p/osiscreen.inc index fc8324781..9399d7eee 100644 --- a/libsrc/osic1p/osiscreen.inc +++ b/libsrc/osic1p/osiscreen.inc @@ -1,183 +1,183 @@ -; -; Macro definitions for screen layout modules -; - - .include "extzp.inc" - -.linecont + - -; -; Internal function for screensize() -; -.macro osi_screensize ScrWidth, ScrHeight - ; Macro implementation of internal screensize - ; function for given width and height in - ; characters - - .export screensize - -.proc screensize - ldx #ScrWidth - ldy #ScrHeight - rts -.endproc -.endmacro - -; -; void clrscr (void); -; -.macro osi_clrscr ScrBase, ScrRamSize - - .export _clrscr - -.proc _clrscr - lda #<ScrBase ; Fill whole video RAM with blanks by calling - ldx #>ScrBase ; memset appropriately - jsr pushax - - lda #' ' - ldx #$00 - jsr pushax - - lda #<ScrRamSize - ldx #>ScrRamSize - jsr _memset - - lda #$00 ; Cursor in upper left corner - sta CURS_X - sta CURS_Y - - jmp plot ; Set the cursor position -.endproc - -.endmacro - -; -; cputc/cputcxy for Challenger 1P -; Based on PET/CBM implementation -; - -.macro osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ - ScrollDist, ScrLo, ScrHi - - ; Number of characters to move for scrolling - ; by one line -ScrollLength = (ScrHeight - 1) * ScrollDist - -; -; void cputcxy (unsigned char x, unsigned char y, char c); -; void cputc (char c); -; - .export _cputcxy, _cputc, cputdirect, putchar - .export newline, plot - -_cputcxy: - pha ; Save C - jsr gotoxy ; Set cursor, drop x and y - pla ; Restore C - -; Plot a character - also used as internal function - -_cputc: cmp #$0A ; CR? - bne L1 - lda #0 - sta CURS_X - beq plot ; Recalculate pointers - -L1: cmp #$0D ; LF? - beq newline ; Recalculate pointers - -cputdirect: - jsr putchar ; Write the character to the screen - -; Advance cursor position, register Y contains horizontal position after -; putchar - - cpy #(ScrWidth - 1) ; Check whether line is full - bne L3 - jsr newline ; New line - ldy #$FF ; + cr -L3: iny - sty CURS_X - rts - -newline: - inc CURS_Y - lda CURS_Y - cmp #ScrHeight ; Screen height - bne plot - dec CURS_Y ; Bottom of screen reached, scroll - - ; Scroll destination address - lda #<(ScrBase + ScrFirstChar) - ldx #>(ScrBase + ScrFirstChar) - jsr pushax - - ; Scroll source address - lda #<(ScrBase + ScrFirstChar + ScrollDist) - ldx #>(ScrBase + ScrFirstChar + ScrollDist) - jsr pushax - - ; Number of characters to move - lda #<ScrollLength - ldx #>ScrollLength - jsr _memmove - - ; Address of first character in last line - ; of screen - lda #<(ScrBase + ScrFirstChar + ScrollLength) - sta ptr1 - lda #>(ScrBase + ScrFirstChar + ScrollLength) - sta ptr1+1 - - ldy #ScrWidth ; Fill last line with blanks - lda #' ' -clrln: sta (ptr1),y - dey - bpl clrln - -plot: ldy CURS_Y - lda ScrLo,y - sta SCREEN_PTR - lda ScrHi,y - sta SCREEN_PTR+1 - rts - -; Write one character to the screen without doing anything else, return X -; position in register Y - -putchar: - ldy CURS_X - sta (SCREEN_PTR),y ; Set char - rts - -.endmacro - -.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \ - ScrWidth, ScrHeight, ScrollDist - - .import gotoxy - .import _memmove, _memset, pushax - .importzp ptr1 - -.rodata - -; Screen address tables - offset to real screen -ScrTabLo: - .repeat ScrHeight, I - .byte <(ScrBase + ScrFirstChar + I * ScrollDist) - .endrep - -ScrTabHi: - .repeat ScrHeight, I - .byte >(ScrBase + ScrFirstChar + I * ScrollDist) - .endrep - -.code - -osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ - ScrollDist, ScrTabLo, ScrTabHi -osi_screensize ScrWidth, ScrHeight -osi_clrscr ScrBase, ScrRamSize - +; +; Macro definitions for screen layout modules +; + + .include "extzp.inc" + +.linecont + + +; +; Internal function for screensize() +; +.macro osi_screensize ScrWidth, ScrHeight + ; Macro implementation of internal screensize + ; function for given width and height in + ; characters + + .export screensize + +.proc screensize + ldx #ScrWidth + ldy #ScrHeight + rts +.endproc +.endmacro + +; +; void clrscr (void); +; +.macro osi_clrscr ScrBase, ScrRamSize + + .export _clrscr + +.proc _clrscr + lda #<ScrBase ; Fill whole video RAM with blanks by calling + ldx #>ScrBase ; memset appropriately + jsr pushax + + lda #' ' + ldx #$00 + jsr pushax + + lda #<ScrRamSize + ldx #>ScrRamSize + jsr _memset + + lda #$00 ; Cursor in upper left corner + sta CURS_X + sta CURS_Y + + jmp plot ; Set the cursor position +.endproc + +.endmacro + +; +; cputc/cputcxy for Challenger 1P +; Based on PET/CBM implementation +; + +.macro osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ + ScrollDist, ScrLo, ScrHi + + ; Number of characters to move for scrolling + ; by one line +ScrollLength = (ScrHeight - 1) * ScrollDist + +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + .export _cputcxy, _cputc, cputdirect, putchar + .export newline, plot + +_cputcxy: + pha ; Save C + jsr gotoxy ; Set cursor, drop x and y + pla ; Restore C + +; Plot a character - also used as internal function + +_cputc: cmp #$0A ; CR? + bne L1 + lda #0 + sta CURS_X + beq plot ; Recalculate pointers + +L1: cmp #$0D ; LF? + beq newline ; Recalculate pointers + +cputdirect: + jsr putchar ; Write the character to the screen + +; Advance cursor position, register Y contains horizontal position after +; putchar + + cpy #(ScrWidth - 1) ; Check whether line is full + bne L3 + jsr newline ; New line + ldy #$FF ; + cr +L3: iny + sty CURS_X + rts + +newline: + inc CURS_Y + lda CURS_Y + cmp #ScrHeight ; Screen height + bne plot + dec CURS_Y ; Bottom of screen reached, scroll + + ; Scroll destination address + lda #<(ScrBase + ScrFirstChar) + ldx #>(ScrBase + ScrFirstChar) + jsr pushax + + ; Scroll source address + lda #<(ScrBase + ScrFirstChar + ScrollDist) + ldx #>(ScrBase + ScrFirstChar + ScrollDist) + jsr pushax + + ; Number of characters to move + lda #<ScrollLength + ldx #>ScrollLength + jsr _memmove + + ; Address of first character in last line + ; of screen + lda #<(ScrBase + ScrFirstChar + ScrollLength) + sta ptr1 + lda #>(ScrBase + ScrFirstChar + ScrollLength) + sta ptr1+1 + + ldy #ScrWidth ; Fill last line with blanks + lda #' ' +clrln: sta (ptr1),y + dey + bpl clrln + +plot: ldy CURS_Y + lda ScrLo,y + sta SCREEN_PTR + lda ScrHi,y + sta SCREEN_PTR+1 + rts + +; Write one character to the screen without doing anything else, return X +; position in register Y + +putchar: + ldy CURS_X + sta (SCREEN_PTR),y ; Set char + rts + +.endmacro + +.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \ + ScrWidth, ScrHeight, ScrollDist + + .import gotoxy + .import _memmove, _memset, pushax + .importzp ptr1 + +.rodata + +; Screen address tables - offset to real screen +ScrTabLo: + .repeat ScrHeight, I + .byte <(ScrBase + ScrFirstChar + I * ScrollDist) + .endrep + +ScrTabHi: + .repeat ScrHeight, I + .byte >(ScrBase + ScrFirstChar + I * ScrollDist) + .endrep + +.code + +osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ + ScrollDist, ScrTabLo, ScrTabHi +osi_screensize ScrWidth, ScrHeight +osi_clrscr ScrBase, ScrRamSize + .endmacro \ No newline at end of file diff --git a/test/ref/divmod.c b/test/ref/divmod.c index 68a0198e1..8fcc951a6 100644 --- a/test/ref/divmod.c +++ b/test/ref/divmod.c @@ -1,38 +1,38 @@ -/* - !!DESCRIPTION!! div/mod test - !!ORIGIN!! - !!LICENCE!! public domain -*/ - -#include <stdio.h> - -void printc(signed char a,signed char b){ -signed char x=a/b,y=a%b,z=a*b; - printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); -} -void prints(short a,short b){ -short x=a/b,y=a%b,z=a*b; - printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); -} -void printl(long a,long b){ -long x=a/b,y=a%b,z=a*b; - printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z); -} - -int main(void) { - printl( 3,-2); - printl(-3,-2); - printl(-3, 2); - printl( 3, 2); - printf("-\n"); - prints( 3,-2); - prints(-3,-2); - prints(-3, 2); - prints( 3, 2); - printf("-\n"); - printc( 3,-2); - printc(-3,-2); - printc(-3, 2); - printc( 3, 2); +/* + !!DESCRIPTION!! div/mod test + !!ORIGIN!! + !!LICENCE!! public domain +*/ + +#include <stdio.h> + +void printc(signed char a,signed char b){ +signed char x=a/b,y=a%b,z=a*b; + printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); +} +void prints(short a,short b){ +short x=a/b,y=a%b,z=a*b; + printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z); +} +void printl(long a,long b){ +long x=a/b,y=a%b,z=a*b; + printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z); +} + +int main(void) { + printl( 3,-2); + printl(-3,-2); + printl(-3, 2); + printl( 3, 2); + printf("-\n"); + prints( 3,-2); + prints(-3,-2); + prints(-3, 2); + prints( 3, 2); + printf("-\n"); + printc( 3,-2); + printc(-3,-2); + printc(-3, 2); + printc( 3, 2); return 0; -} +} diff --git a/test/ref/init.c b/test/ref/init.c index 5a5816753..44cd544fd 100644 --- a/test/ref/init.c +++ b/test/ref/init.c @@ -1,95 +1,95 @@ -/* - !!DESCRIPTION!! variable initialization - !!ORIGIN!! LCC 4.1 Testsuite - !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC -*/ - -#include "common.h" -/* todo: add back conditional stuff here ! */ - -typedef struct { int codes[3]; char name[6]; } Word; - -#ifdef NO_IMPLICIT_FUNC_PROTOTYPES - -#ifdef NO_OLD_FUNC_DECL -f(); -void g(Word *p); -h(); -#else -f(); -g(); -h(); -#endif - -#endif - -/* -Word words[] = { - 1, 2, 3,"if", - { { 4, 5 }, { 'f', 'o', 'r' } }, - 6, 7, 8, {"else"}, - { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', }, - { 0 }, -}, *wordlist = words; -*/ - -Word words[] = { - {{1, 2, 3},"if"}, - { { 4, 5 }, { 'f', 'o', 'r' } }, - {{6, 7, 8}, "else"}, - { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }}, - {{ 0 }}, -}, *wordlist = words; - -/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/ -int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } }; -int *y[] = { x[0], x[1], x[2], 0 }; - -main() -{ - int i, j; - - for (i = 0; y[i]; i++) { - for (j = 0; y[i][j]; j++) - printf(" %d", y[i][j]); - printf("\n"); - } - f(); - g(wordlist); - return 0; -} - -f() { - static char *keywords[] = {"if", "for", "else", "while", 0, }; - char **p; - - for (p = keywords; *p; p++) - printf("%s\n", *p); -} - -#ifdef NO_OLD_FUNC_DECL -void g(Word *p) -#else -g(p) -Word *p; -#endif -{ - int i; - - for ( ; p->codes[0]; p++) { - for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++) - printf("%d ", p->codes[i]); - printf("%s\n", p->name); - } - h(); -} - -h() -{ - int i; - - for (i = 0; i < sizeof(words)/sizeof(Word); i++) - printf("%d %d %d %s\n", words[i].codes[0], - words[i].codes[1], words[i].codes[2], - &words[i].name[0]); -} +/* + !!DESCRIPTION!! variable initialization + !!ORIGIN!! LCC 4.1 Testsuite + !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC +*/ + +#include "common.h" +/* todo: add back conditional stuff here ! */ + +typedef struct { int codes[3]; char name[6]; } Word; + +#ifdef NO_IMPLICIT_FUNC_PROTOTYPES + +#ifdef NO_OLD_FUNC_DECL +f(); +void g(Word *p); +h(); +#else +f(); +g(); +h(); +#endif + +#endif + +/* +Word words[] = { + 1, 2, 3,"if", + { { 4, 5 }, { 'f', 'o', 'r' } }, + 6, 7, 8, {"else"}, + { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', }, + { 0 }, +}, *wordlist = words; +*/ + +Word words[] = { + {{1, 2, 3},"if"}, + { { 4, 5 }, { 'f', 'o', 'r' } }, + {{6, 7, 8}, "else"}, + { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }}, + {{ 0 }}, +}, *wordlist = words; + +/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/ +int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } }; +int *y[] = { x[0], x[1], x[2], 0 }; + +main() +{ + int i, j; + + for (i = 0; y[i]; i++) { + for (j = 0; y[i][j]; j++) + printf(" %d", y[i][j]); + printf("\n"); + } + f(); + g(wordlist); + return 0; +} + +f() { + static char *keywords[] = {"if", "for", "else", "while", 0, }; + char **p; + + for (p = keywords; *p; p++) + printf("%s\n", *p); +} + +#ifdef NO_OLD_FUNC_DECL +void g(Word *p) +#else +g(p) +Word *p; +#endif +{ + int i; + + for ( ; p->codes[0]; p++) { + for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++) + printf("%d ", p->codes[i]); + printf("%s\n", p->name); + } + h(); +} + +h() +{ + int i; + + for (i = 0; i < sizeof(words)/sizeof(Word); i++) + printf("%d %d %d %s\n", words[i].codes[0], + words[i].codes[1], words[i].codes[2], + &words[i].name[0]); +} diff --git a/test/ref/pointer2.c b/test/ref/pointer2.c index d8c064ef3..29f9e3de4 100644 --- a/test/ref/pointer2.c +++ b/test/ref/pointer2.c @@ -1,112 +1,112 @@ -/* - !!DESCRIPTION!! pointer test - !!ORIGIN!! - !!LICENCE!! public domain -*/ - -#include "common.h" -#include <stdio.h> - -/* - check behaviour on incompletely declared arrays -*/ - -char i1[]; - -void test1(void) { -int a; - - a=sizeof(i1[0]); - printf("%04x - ",a); - if(sizeof(i1[0])==sizeof(char)) { - /* gcc gives size of element */ - printf("sizeof(i1[0]) gives size of element\n"); - } - if(sizeof(i1[0])==sizeof(char*)) { - printf("sizeof(i1[0]) gives size of pointer to element\n"); - } -} - -/* - check behaviour on string init -*/ - -char t1[]="abcde"; -char t2[]={"abcde"}; - -char *t3="abcde"; -char *t4={"abcde"}; - -void test2(void) { -char c1,c2,c3,c4; -int i,e=0; - for(i=0;i<5;i++){ - c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i]; -/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */ - printf("%c %c %c %c\n",c1,c2,c3,c4); - if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1; - } - if(e) printf("test2 failed.\n"); - else printf("test2 ok.\n"); -} - -/* - check behaviour on extern-declarations inside functions -*/ - -typedef struct { - char *name; - void *func; -} A3; - -#ifdef NO_SLOPPY_STRUCT_INIT -A3 a3[] = { - { "test3", (void*) NULL }, - { "test3", (void*) NULL }, -}; -#else -/*gcc warning: missing braces around initializer (near initialization for `a3[0]') - this type of struct-initialization seems to be kinda common */ -A3 a3[] = { - "test3", (void*) NULL , - "test3", (void*) NULL , -}; -#endif - -void test3a(A3 *list, int number){ - printf("%s %d\n",list->name,number); -} - -static void test31(void) -{ - extern A3 a3[]; - test3a(a3, -1); -} - -#if 0 -/* this variation compiles and works with cc65, but gives an error with gcc :=P */ -static void test32(void) -{ - extern A3 *a3; - test3a(a3, -1); -} -#endif - -static void test30(void) -{ - test3a(a3, -1); -} - -/* - todo: add test on function pointers in the form of (*func)(arg) ... - cc65 seems to have problems here aswell ;/ -*/ - -int main(void) { - test1(); - test2(); - test30(); - test31(); -/* test32(); */ - return 0; -} +/* + !!DESCRIPTION!! pointer test + !!ORIGIN!! + !!LICENCE!! public domain +*/ + +#include "common.h" +#include <stdio.h> + +/* + check behaviour on incompletely declared arrays +*/ + +char i1[]; + +void test1(void) { +int a; + + a=sizeof(i1[0]); + printf("%04x - ",a); + if(sizeof(i1[0])==sizeof(char)) { + /* gcc gives size of element */ + printf("sizeof(i1[0]) gives size of element\n"); + } + if(sizeof(i1[0])==sizeof(char*)) { + printf("sizeof(i1[0]) gives size of pointer to element\n"); + } +} + +/* + check behaviour on string init +*/ + +char t1[]="abcde"; +char t2[]={"abcde"}; + +char *t3="abcde"; +char *t4={"abcde"}; + +void test2(void) { +char c1,c2,c3,c4; +int i,e=0; + for(i=0;i<5;i++){ + c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i]; +/* printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */ + printf("%c %c %c %c\n",c1,c2,c3,c4); + if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1; + } + if(e) printf("test2 failed.\n"); + else printf("test2 ok.\n"); +} + +/* + check behaviour on extern-declarations inside functions +*/ + +typedef struct { + char *name; + void *func; +} A3; + +#ifdef NO_SLOPPY_STRUCT_INIT +A3 a3[] = { + { "test3", (void*) NULL }, + { "test3", (void*) NULL }, +}; +#else +/*gcc warning: missing braces around initializer (near initialization for `a3[0]') + this type of struct-initialization seems to be kinda common */ +A3 a3[] = { + "test3", (void*) NULL , + "test3", (void*) NULL , +}; +#endif + +void test3a(A3 *list, int number){ + printf("%s %d\n",list->name,number); +} + +static void test31(void) +{ + extern A3 a3[]; + test3a(a3, -1); +} + +#if 0 +/* this variation compiles and works with cc65, but gives an error with gcc :=P */ +static void test32(void) +{ + extern A3 *a3; + test3a(a3, -1); +} +#endif + +static void test30(void) +{ + test3a(a3, -1); +} + +/* + todo: add test on function pointers in the form of (*func)(arg) ... + cc65 seems to have problems here aswell ;/ +*/ + +int main(void) { + test1(); + test2(); + test30(); + test31(); +/* test32(); */ + return 0; +} diff --git a/test/ref/switch2.c b/test/ref/switch2.c index e75cfe71e..7a9bcecd7 100644 --- a/test/ref/switch2.c +++ b/test/ref/switch2.c @@ -1,262 +1,262 @@ -/* - !!DESCRIPTION!! switch test - !!ORIGIN!! - !!LICENCE!! public domain -*/ - -/*#define STANDALONE*/ - -#include <stdio.h> - +/* + !!DESCRIPTION!! switch test + !!ORIGIN!! + !!LICENCE!! public domain +*/ + +/*#define STANDALONE*/ + +#include <stdio.h> + void testlimits(int i) { - printf("%d:",i); - + printf("%d:",i); + switch(i) { - case -1: /* works */ - /* case 0xffff: */ /* 'range error' (-1) */ - - printf("-1\n"); - break; - /* max int */ - -/* case 0x7fff: */ /* works */ - case 32767: /* works */ - /* case 32768: */ /* 'range error' (correct for that one!) */ - - printf("max\n"); - break; - /* min int */ - - case -32768: /* 'warning. constant is long' */ - /* case 0x8000: */ /* 'range error' */ - /* case -32769: */ /* 'range error' (correct for that one!) */ - printf("min\n"); - break; - } - printf("\n"); -} - -void testdefault1(unsigned char i) { -/* we want a signed char */ -#ifdef REFCC - -#ifdef REFCC_UNSIGNED_CHARS -signed char k; -#else -char k; -#endif - -#else - -#ifdef UNSIGNED_CHARS -signed char k; -#else -char k; -#endif - -#endif - - for(;i<254;) { - k = i; - printf(">%d\n",i);i++; - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - break; - case 10: - break; - case 11: - break; - case 12: - break; - case 13: - break; - case 14: - break; - case 15: - break; - case 17: - break; - /* triggers bug ? */ - /* gcc warning: case label value exceeds maximum value for type */ - /* cc65 error: range error */ - - /* - case 170: - break; - */ - case 18: - break; - case 19: - break; - case 20: - break; - case 21: - break; - case 22: - break; - case 23: - break; - case 24: - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - case 5: - break; - case 6: - case 7: - break; - case 8: - case 9: - break; - } - break; - case 100: - break; - default: - printf(">>>default\n"); - /* triggers bug if this break; is missing? */ - /* break; */ - } - } -} - -void testdefault2(unsigned char i) { -/* we want a unsigned char */ -#ifdef REFCC - -#ifdef REFCC_UNSIGNED_CHARS -char k; -#else -unsigned char k; -#endif - -#else - -#ifdef UNSIGNED_CHARS -char k; -#else -unsigned char k; -#endif - -#endif - - for(;i<254;) { - k = i; - printf(">%d\n",i);i++; - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - break; - case 10: - break; - case 11: - break; - case 12: - break; - case 13: - break; - case 14: - break; - case 15: - break; - case 17: - break; - /* triggers bug ? */ - - case 170: - break; - - case 18: - break; - case 19: - break; - case 20: - break; - case 21: - break; - case 22: - break; - case 23: - break; - case 24: - switch(k) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - case 5: - break; - case 6: - case 7: - break; - case 8: - case 9: - break; - } - break; - case 100: - break; - default: - printf(">>>default\n"); - /* triggers bug if this break; is missing? */ - /* break; */ - } - } + case -1: /* works */ + /* case 0xffff: */ /* 'range error' (-1) */ + + printf("-1\n"); + break; + /* max int */ + +/* case 0x7fff: */ /* works */ + case 32767: /* works */ + /* case 32768: */ /* 'range error' (correct for that one!) */ + + printf("max\n"); + break; + /* min int */ + + case -32768: /* 'warning. constant is long' */ + /* case 0x8000: */ /* 'range error' */ + /* case -32769: */ /* 'range error' (correct for that one!) */ + printf("min\n"); + break; + } + printf("\n"); +} + +void testdefault1(unsigned char i) { +/* we want a signed char */ +#ifdef REFCC + +#ifdef REFCC_UNSIGNED_CHARS +signed char k; +#else +char k; +#endif + +#else + +#ifdef UNSIGNED_CHARS +signed char k; +#else +char k; +#endif + +#endif + + for(;i<254;) { + k = i; + printf(">%d\n",i);i++; + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 17: + break; + /* triggers bug ? */ + /* gcc warning: case label value exceeds maximum value for type */ + /* cc65 error: range error */ + + /* + case 170: + break; + */ + case 18: + break; + case 19: + break; + case 20: + break; + case 21: + break; + case 22: + break; + case 23: + break; + case 24: + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + case 5: + break; + case 6: + case 7: + break; + case 8: + case 9: + break; + } + break; + case 100: + break; + default: + printf(">>>default\n"); + /* triggers bug if this break; is missing? */ + /* break; */ + } + } +} + +void testdefault2(unsigned char i) { +/* we want a unsigned char */ +#ifdef REFCC + +#ifdef REFCC_UNSIGNED_CHARS +char k; +#else +unsigned char k; +#endif + +#else + +#ifdef UNSIGNED_CHARS +char k; +#else +unsigned char k; +#endif + +#endif + + for(;i<254;) { + k = i; + printf(">%d\n",i);i++; + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 17: + break; + /* triggers bug ? */ + + case 170: + break; + + case 18: + break; + case 19: + break; + case 20: + break; + case 21: + break; + case 22: + break; + case 23: + break; + case 24: + switch(k) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + case 5: + break; + case 6: + case 7: + break; + case 8: + case 9: + break; + } + break; + case 100: + break; + default: + printf(">>>default\n"); + /* triggers bug if this break; is missing? */ + /* break; */ + } + } } int main(void) { - testlimits(32767); - testlimits(-32768); - testlimits(-1); - - testdefault1(1); - testdefault1(2); - testdefault1(3); - testdefault1(4); - - testdefault2(1); - testdefault2(2); - testdefault2(3); - testdefault2(4); - - return 0; -} + testlimits(32767); + testlimits(-32768); + testlimits(-1); + + testdefault1(1); + testdefault1(2); + testdefault1(3); + testdefault1(4); + + testdefault2(1); + testdefault2(2); + testdefault2(3); + testdefault2(4); + + return 0; +} diff --git a/test/ref/varargs.c b/test/ref/varargs.c index 11fd33b38..3d61fdbd0 100644 --- a/test/ref/varargs.c +++ b/test/ref/varargs.c @@ -1,105 +1,105 @@ /* - !!DESCRIPTION!! varargs test - !!ORIGIN!! - !!LICENCE!! public domain -*/ - -#include <stdlib.h> -#include <stdio.h> -#include <stdarg.h> - -void chk0(char *format,...); -void chk1(int fd,char *format,...); - -#if 0 -// old workaround for broken varargs - -void chk0(char *format,...){ - __asm__ ("pha"); // save argument size - { -//va_list ap; -char *ap; -char *_format; -static char string[0x100]; - -// va_start(ap,format); - __asm__ ("pla"); // restore argument size - __asm__ ("ldx #$00"); // clear hibyte of AX - ap=__AX__; - ap+=(char*)&format; - // get value of format - ap-=2; - _format=*((char**)ap); - -// vsprintf(string,format,ap); - vsprintf(&string[0],_format,ap); - printf("format:%s,string:%s\n",_format,string); -// va_end(ap); - - } -} - -void chk1(int fd,char *format,...){ - __asm__ ("pha"); // save argument size - { -//va_list ap; -char *ap; -char *_format; -int _fd; -static char string[0x100]; - -// va_start(ap,format); - __asm__ ("pla"); // restore argument size - __asm__ ("ldx #$00"); // clear hibyte of AX - ap=__AX__; - ap+=(char*)&format; - // get value of fd - ap-=2; - _fd=*((int*)ap); - // get value of format - ap-=2; - _format=*((char**)ap); - -// vsprintf(string,format,ap); - vsprintf(&string[0],_format,ap); - printf("fd:%d,format:%s,string:%s\n",_fd,_format,string); -// va_end(ap); - - } -} - -#endif - -void chk0(char *format,...){ -va_list ap; -static char string[0x100]; - va_start(ap,format); - vsprintf(string,format,ap); - printf("format:%s,string:%s\n",format,string); - va_end(ap); -} - -void chk1(int fd,char *format,...){ -va_list ap; -static char string[0x100]; - - va_start(ap,format); - - vsprintf(string,format,ap); - printf("fd:%d,format:%s,string:%s\n",fd,format,string); - va_end(ap); + !!DESCRIPTION!! varargs test + !!ORIGIN!! + !!LICENCE!! public domain +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> + +void chk0(char *format,...); +void chk1(int fd,char *format,...); + +#if 0 +// old workaround for broken varargs + +void chk0(char *format,...){ + __asm__ ("pha"); // save argument size + { +//va_list ap; +char *ap; +char *_format; +static char string[0x100]; + +// va_start(ap,format); + __asm__ ("pla"); // restore argument size + __asm__ ("ldx #$00"); // clear hibyte of AX + ap=__AX__; + ap+=(char*)&format; + // get value of format + ap-=2; + _format=*((char**)ap); + +// vsprintf(string,format,ap); + vsprintf(&string[0],_format,ap); + printf("format:%s,string:%s\n",_format,string); +// va_end(ap); + + } } -int main(int argc,char **argv) { - printf("varargs test\n"); - - printf("\nchk0/0:\n");chk0("chk0 %s","arg0"); - printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1"); - printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2"); - - printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0"); - printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1"); - printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2"); - +void chk1(int fd,char *format,...){ + __asm__ ("pha"); // save argument size + { +//va_list ap; +char *ap; +char *_format; +int _fd; +static char string[0x100]; + +// va_start(ap,format); + __asm__ ("pla"); // restore argument size + __asm__ ("ldx #$00"); // clear hibyte of AX + ap=__AX__; + ap+=(char*)&format; + // get value of fd + ap-=2; + _fd=*((int*)ap); + // get value of format + ap-=2; + _format=*((char**)ap); + +// vsprintf(string,format,ap); + vsprintf(&string[0],_format,ap); + printf("fd:%d,format:%s,string:%s\n",_fd,_format,string); +// va_end(ap); + + } +} + +#endif + +void chk0(char *format,...){ +va_list ap; +static char string[0x100]; + va_start(ap,format); + vsprintf(string,format,ap); + printf("format:%s,string:%s\n",format,string); + va_end(ap); +} + +void chk1(int fd,char *format,...){ +va_list ap; +static char string[0x100]; + + va_start(ap,format); + + vsprintf(string,format,ap); + printf("fd:%d,format:%s,string:%s\n",fd,format,string); + va_end(ap); +} + +int main(int argc,char **argv) { + printf("varargs test\n"); + + printf("\nchk0/0:\n");chk0("chk0 %s","arg0"); + printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1"); + printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2"); + + printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0"); + printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1"); + printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2"); + return 0; -} +} diff --git a/testcode/lib/mul-test.c b/testcode/lib/mul-test.c index 2daf5aa06..f9db3f641 100644 --- a/testcode/lib/mul-test.c +++ b/testcode/lib/mul-test.c @@ -1,170 +1,170 @@ -/* mul-test.c -- Test the multiplication operator. */ - -#include <time.h> -#include <conio.h> -#include <ctype.h> - - -/* Number of elements in the progress bar. Use a power of 2, to avoid the -** multiplication (which is about to be tested). -*/ -#define BAR_ELEMENTS 32U - -#if defined(__CBM__) -static const unsigned char revers_bar[8] = { - 0, 0, 0, 0, 0, 1, 1, 1 -}; -static const unsigned char small_bar[8] = { - ' ', 0xa5, 0xb4, 0xb5, 0xa1, 0xb6, 0xaa, 0xa7 -}; - -#elif defined(__ATARI__) -#endif - -/* Screen co-ordinates for the progress meter */ -static unsigned char Width, Height; -static unsigned char X, Y; - -static void ProgressMeter (unsigned Val) -/* Print the progress bar. */ -{ - gotoxy (X, Y); - cprintf (" %5lu/65536\r\n", (unsigned long) Val); - revers (1); - cclear (Val / (unsigned)(65536U / BAR_ELEMENTS)); - -/* Commodore and Atari computers can show eight times greater precision. */ -#if defined(__CBM__) - Val = (Val / (unsigned)(65536U / BAR_ELEMENTS / 8)) % 8; - revers (revers_bar[Val]); - cputc (small_bar[Val]); - -#elif defined(__ATARI__) -#endif - - revers (0); -} - - - -int main(void) -{ - char C; - - /* Clock variables */ - clock_t Ticks; - clock_t Wait; - unsigned Days; - unsigned Hours; - unsigned Minu; - unsigned Sec; - unsigned Milli; - - /* Actual test variables */ - register unsigned lhs = 0; - register unsigned rhs = 0; - register unsigned res; - - /* Clear the screen, and output an informational message. */ - clrscr (); - screensize (&Width, &Height); - cprintf ("This program does an exhaustive test of\r\n" - "the multiplication routine. It runs for\r\n" - "several days; so, please wait very\r\n" - "patiently (or, speed up your emulator).\r\n" - "\n" - "Progress: "); - - /* Remember the current position for the progress bar */ - X = wherex (); - Y = wherey (); - - /* Mark the maximum limit of the bar. */ - revers (1); - cputcxy (BAR_ELEMENTS, Y, ' '); - cputcxy (BAR_ELEMENTS, Y + 1, ' '); - revers (0); - -/* [Targets that have clock() will define CLOCKS_PER_SEC.] */ -#ifdef CLOCKS_PER_SEC - - /* Start timing the test. */ - Ticks = clock(); -#endif - - do { - - /* Update the progress bar */ - ProgressMeter (lhs); - -/* Enable this to test the progress-meter code. -** (And, run emulators at their maximun speed.) -*/ -#if 0 - continue; -#endif - - /* Do one row of tests */ - res = 0; - do { - if (lhs * rhs != res) { -#ifdef CLOCKS_PER_SEC - Wait = clock (); -#endif - gotoxy (0, Y+3); - cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res); - cprintf ("Press a key -- 'Q' to quit. "); - cursor (1); - C = toupper (cgetc ()); - cclearxy (0, Y+3, Width); - cclearxy (0, Y+4, Width); - -#ifdef CLOCKS_PER_SEC - - /* Don't time the user's interaction. */ - Ticks += clock () - Wait; -#endif - - if (C == 'Q') { - goto Done; - } - } - - if (kbhit () && toupper (cgetc ()) == 'Q') { - goto Done; - } - - res += lhs; - } while (++rhs != 0); - - } while (++lhs != 0); - -Done: -#ifdef CLOCKS_PER_SEC - - /* Calculate the time used */ - Ticks = clock() - Ticks; - Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC; - Sec = (unsigned) (Ticks / CLOCKS_PER_SEC); - Minu = Sec / 60; - Hours = Minu / 60; - Days = Hours / 24; - Hours %= 24; - Minu %= 60; - Sec %= 60; - - /* Print the time used */ - gotoxy (0, Y+3); - cprintf ("Time used:\r\n" - " %u days,\r\n" - " %u hours,\r\n" - " %u minutes,\r\n" - " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli); -#endif - - cprintf ("\rTap a key, to exit. "); - cgetc(); - return 0; -} - - +/* mul-test.c -- Test the multiplication operator. */ + +#include <time.h> +#include <conio.h> +#include <ctype.h> + + +/* Number of elements in the progress bar. Use a power of 2, to avoid the +** multiplication (which is about to be tested). +*/ +#define BAR_ELEMENTS 32U + +#if defined(__CBM__) +static const unsigned char revers_bar[8] = { + 0, 0, 0, 0, 0, 1, 1, 1 +}; +static const unsigned char small_bar[8] = { + ' ', 0xa5, 0xb4, 0xb5, 0xa1, 0xb6, 0xaa, 0xa7 +}; + +#elif defined(__ATARI__) +#endif + +/* Screen co-ordinates for the progress meter */ +static unsigned char Width, Height; +static unsigned char X, Y; + +static void ProgressMeter (unsigned Val) +/* Print the progress bar. */ +{ + gotoxy (X, Y); + cprintf (" %5lu/65536\r\n", (unsigned long) Val); + revers (1); + cclear (Val / (unsigned)(65536U / BAR_ELEMENTS)); + +/* Commodore and Atari computers can show eight times greater precision. */ +#if defined(__CBM__) + Val = (Val / (unsigned)(65536U / BAR_ELEMENTS / 8)) % 8; + revers (revers_bar[Val]); + cputc (small_bar[Val]); + +#elif defined(__ATARI__) +#endif + + revers (0); +} + + + +int main(void) +{ + char C; + + /* Clock variables */ + clock_t Ticks; + clock_t Wait; + unsigned Days; + unsigned Hours; + unsigned Minu; + unsigned Sec; + unsigned Milli; + + /* Actual test variables */ + register unsigned lhs = 0; + register unsigned rhs = 0; + register unsigned res; + + /* Clear the screen, and output an informational message. */ + clrscr (); + screensize (&Width, &Height); + cprintf ("This program does an exhaustive test of\r\n" + "the multiplication routine. It runs for\r\n" + "several days; so, please wait very\r\n" + "patiently (or, speed up your emulator).\r\n" + "\n" + "Progress: "); + + /* Remember the current position for the progress bar */ + X = wherex (); + Y = wherey (); + + /* Mark the maximum limit of the bar. */ + revers (1); + cputcxy (BAR_ELEMENTS, Y, ' '); + cputcxy (BAR_ELEMENTS, Y + 1, ' '); + revers (0); + +/* [Targets that have clock() will define CLOCKS_PER_SEC.] */ +#ifdef CLOCKS_PER_SEC + + /* Start timing the test. */ + Ticks = clock(); +#endif + + do { + + /* Update the progress bar */ + ProgressMeter (lhs); + +/* Enable this to test the progress-meter code. +** (And, run emulators at their maximun speed.) +*/ +#if 0 + continue; +#endif + + /* Do one row of tests */ + res = 0; + do { + if (lhs * rhs != res) { +#ifdef CLOCKS_PER_SEC + Wait = clock (); +#endif + gotoxy (0, Y+3); + cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res); + cprintf ("Press a key -- 'Q' to quit. "); + cursor (1); + C = toupper (cgetc ()); + cclearxy (0, Y+3, Width); + cclearxy (0, Y+4, Width); + +#ifdef CLOCKS_PER_SEC + + /* Don't time the user's interaction. */ + Ticks += clock () - Wait; +#endif + + if (C == 'Q') { + goto Done; + } + } + + if (kbhit () && toupper (cgetc ()) == 'Q') { + goto Done; + } + + res += lhs; + } while (++rhs != 0); + + } while (++lhs != 0); + +Done: +#ifdef CLOCKS_PER_SEC + + /* Calculate the time used */ + Ticks = clock() - Ticks; + Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC; + Sec = (unsigned) (Ticks / CLOCKS_PER_SEC); + Minu = Sec / 60; + Hours = Minu / 60; + Days = Hours / 24; + Hours %= 24; + Minu %= 60; + Sec %= 60; + + /* Print the time used */ + gotoxy (0, Y+3); + cprintf ("Time used:\r\n" + " %u days,\r\n" + " %u hours,\r\n" + " %u minutes,\r\n" + " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli); +#endif + + cprintf ("\rTap a key, to exit. "); + cgetc(); + return 0; +} + + From acb7c6130274d7c2ad91ac82c6b64b741fa47d97 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Fri, 10 Mar 2017 08:47:48 -0500 Subject: [PATCH 258/407] Removed a pointless cc65 command-line option from the samples makefile. "-Oi --codesize 500" is the same as "-O --codesize 200 --codesize 500". That first "--codesize" is replaced by the second one. Don't set it twice. --- samples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index edfeca689..949940022 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -90,7 +90,7 @@ LDFLAGS_tgidemo_atarixl = --start-addr 0x4000 %: %.s .c.o: - $(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $< + $(CC) $(CFLAGS) -Ors --codesize 500 -T -g -t $(SYS) $< $(AS) $(<:.c=.s) .s.o: From 73261ea48f84ccca6ce3608fab6a9c8802ddb874 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sat, 11 Mar 2017 15:11:15 -0500 Subject: [PATCH 259/407] Fixed a pointer test again -- but, it's better than in pull request #391. This time, the expression compares the pointer directly, instead of comparing the pointer's target. The new expression avoids an array underrun. --- test/ref/yacc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/ref/yacc.c b/test/ref/yacc.c index d0b9190e4..ab72e24c0 100644 --- a/test/ref/yacc.c +++ b/test/ref/yacc.c @@ -562,13 +562,13 @@ yylook() } # ifdef LEXDEBUG - if (*(lsp-1) < yysvec + 1) + if (lsp == yylstate) { fprintf(yyout,"yylook: stopped (end)\n"); } else { - fprintf(yyout,"yylook: stopped at %d with\n",*(lsp-1)-yysvec-1); + fprintf(yyout,"yylook: stopped at %d with:\n",*(lsp-1)-(yysvec+1)); } # endif while (lsp-- > yylstate) @@ -594,7 +594,7 @@ yylook() yyleng = yylastch-yytext+1; yytext[yyleng] = 0; # ifdef LEXDEBUG - fprintf(yyout,"\nyylook: match action %d\n",*yyfnd); + fprintf(yyout,"yylook: match action %d\n",*yyfnd); fprintf(yyout,"yylook: done loops: %d\n",testbreak); # endif return(*yyfnd++); From 2e8d792f9a1b55bb19942e02b91b1294dbc37e87 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 12 Mar 2017 18:13:18 +0100 Subject: [PATCH 260/407] Added .gitattributes to force LF line endings on commit. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..176a458f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto From 750a527100526dfd33e31152819a87533ca95d1f Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 12 Mar 2017 12:55:31 -0400 Subject: [PATCH 261/407] Made C's sizeof operator work with initialized void variables. Added regression tests that check cc65's handling of void variables. --- doc/cc65.sgml | 47 +++++++++++++--------- src/cc65/datatype.c | 7 +++- src/cc65/declare.c | 10 +++-- test/err/void-empty.c | 9 +++++ test/err/void-size2.c | 11 +++++ test/val/void-size1.c | 56 ++++++++++++++++++++++++++ testcode/lib/atari/displaylist.c | 69 +++++++++++++++----------------- 7 files changed, 147 insertions(+), 62 deletions(-) create mode 100644 test/err/void-empty.c create mode 100644 test/err/void-size2.c create mode 100644 test/val/void-size1.c diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 80dba89b8..6a08cc3c3 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -4,7 +4,7 @@ <title>cc65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:gregdk@users.sf.net" name="Greg King"> -<date>2016-06-11 +<date>2017-02-27 <abstract> cc65 is a C compiler for 6502 targets. It supports several 6502 based home @@ -687,30 +687,37 @@ This cc65 version has some extensions to the ISO C standard. string. <p> -<item> cc65 allows the initialization of <tt/void/ variables. This may be - used to create variable structures that are more compatible with - interfaces written for assembler languages. Here is an example: +<item> cc65 allows the initialization of <tt/void/ variables. This may be + used to create arbitrary structures that are more compatible with + interfaces written for assembler languages. Here is an example: - <tscreen><verb> - void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 }; - </verb></tscreen> + <tscreen><verb> + void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 }; + </verb></tscreen> - This will be translated as follows: + That will be translated as follows: - <tscreen><verb> - _GCmd: - .byte 3 - .word $2000 - .word $3000 - </verb></tscreen> + <tscreen><verb> + _GCmd: + .byte 3 + .word $2000 + .word $3000 + </verb></tscreen> - Since the variable is of type <tt/void/ you may not use it as is. - However, taking the address of the variable results in a <tt/void*/ - which may be passed to any function expecting a pointer. + Since the variable is of type <tt/void/, you may not use it as-is. + However, taking the address of the variable results in a <tt/void*/ + which may be passed to any function expecting a pointer. Also, the + <tt/sizeof/ operator will give the length of the initializer: - See the <url url="geos.html" name="GEOS library document"> for examples - on how to use this feature. - <p> + <tscreen><verb> + GLen = sizeof GCmd; + </verb></tscreen> + + will assign the value 5 to <tt/GLen/. + + See the <url url="geos.html" name="GEOS library document"> for examples + on how to use that feature. + <p> <item> cc65 implements flexible array struct members as defined in the C99 ISO standard. As an extension, these fields may be initialized. There are diff --git a/src/cc65/datatype.c b/src/cc65/datatype.c index 8c9d6dcb0..2d54316cd 100644 --- a/src/cc65/datatype.c +++ b/src/cc65/datatype.c @@ -389,7 +389,10 @@ unsigned SizeOf (const Type* T) switch (UnqualifiedType (T->C)) { case T_VOID: - return 0; /* Assume voids have size zero */ + /* A void variable is a cc65 extension. + ** Get its size (in bytes). + */ + return T->A.U; /* Beware: There's a chance that this triggers problems in other parts of the compiler. The solution is to fix the callers, because calling @@ -438,7 +441,7 @@ unsigned SizeOf (const Type* T) /* Array with unspecified size */ return 0; } else { - return T->A.L * SizeOf (T + 1); + return T->A.U * SizeOf (T + 1); } default: diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 163084835..7b543aa55 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -891,6 +891,7 @@ static void ParseTypeSpec (DeclSpec* D, long Default, TypeCode Qualifiers) case TOK_VOID: NextToken (); D->Type[0].C = T_VOID; + D->Type[0].A.U = 0; D->Type[1].C = T_END; break; @@ -2114,7 +2115,7 @@ NextMember: -static unsigned ParseVoidInit (void) +static unsigned ParseVoidInit (Type* T) /* Parse an initialization of a void variable (special cc65 extension). ** Return the number of bytes initialized. */ @@ -2181,6 +2182,9 @@ static unsigned ParseVoidInit (void) /* Closing brace */ ConsumeRCurly (); + /* Number of bytes determined by initializer */ + T->A.U = Size; + /* Return the number of bytes initialized */ return Size; } @@ -2216,8 +2220,8 @@ static unsigned ParseInitInternal (Type* T, int AllowFlexibleMembers) case T_VOID: if (IS_Get (&Standard) == STD_CC65) { - /* Special cc65 extension in non ANSI mode */ - return ParseVoidInit (); + /* Special cc65 extension in non-ANSI mode */ + return ParseVoidInit (T); } /* FALLTHROUGH */ diff --git a/test/err/void-empty.c b/test/err/void-empty.c new file mode 100644 index 000000000..900918222 --- /dev/null +++ b/test/err/void-empty.c @@ -0,0 +1,9 @@ +/* + !!DESCRIPTION!! Uninitialized void variables + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +void test; +const void list; diff --git a/test/err/void-size2.c b/test/err/void-size2.c new file mode 100644 index 000000000..3d4f13322 --- /dev/null +++ b/test/err/void-size2.c @@ -0,0 +1,11 @@ +/* + !!DESCRIPTION!! Size of void cast + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +unsigned test (void) +{ + return sizeof ((void)12345); +} diff --git a/test/val/void-size1.c b/test/val/void-size1.c new file mode 100644 index 000000000..0c2dccaa7 --- /dev/null +++ b/test/val/void-size1.c @@ -0,0 +1,56 @@ +/* + !!DESCRIPTION!! Getting the size of a void-type variable (cc65 extension) + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +static const void list1 = { + (char)1, + (char)2, + (char)3, + (char)4, + (char)5, + (char)6, + (char)7, + (char)8, + (char)9, + (char)0 +}; + +static void list2 = { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 0 +}; + +void list3 = { + (char)1, + (char)2, + (char)3, + (char)4, + &list1, + (char)6, + (char)7, + (char)8, + (char)9, + &list2 +}; + +/* We know that the expression is constant; don't tell us. */ + +#pragma warn (const-comparison, off) + +int main (void) +{ + return sizeof list1 != 10 + || sizeof list2 != 20 + || sizeof list3 != 12; +} diff --git a/testcode/lib/atari/displaylist.c b/testcode/lib/atari/displaylist.c index 04c599878..ae1931e64 100644 --- a/testcode/lib/atari/displaylist.c +++ b/testcode/lib/atari/displaylist.c @@ -1,59 +1,55 @@ /* -** testprogram for ANTIC instructions as defined in "_antic.h" +** test program for ANTIC instructions as defined in "_antic.h" ** ** 23-Feb-2017, Christian Krueger */ #include <conio.h> #include <atari.h> -#include <peekpoke.h> -#include <string.h> -// code is only for testing purposes, as screen and display list are not aligned +// code is only for testing purposes, as screen and display list are not aligned, // and jumps not set! unsigned char DummyScreen[400]; void DisplayList = { - DL_BLK1, - DL_BLK2, - DL_BLK3, - DL_BLK4, - DL_BLK5, - DL_BLK6, - DL_BLK7, - DL_DLI(DL_BLK8), - DL_LMS(DL_CHR40x8x1), - DummyScreen, - DL_HSCROL(DL_CHR40x10x1), - DL_VSCROL(DL_CHR40x8x4), - DL_CHR40x16x4, - DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_CHR20x8x2)))), - DummyScreen+120, - DL_CHR20x16x2, - DL_MAP40x8x4, - DL_MAP80x4x2, - DL_MAP80x4x4, - DL_MAP160x2x2, - DL_MAP160x1x2, - DL_MAP160x2x4, - DL_MAP160x1x4, - DL_MAP320x1x1, - DL_JVB, - DL_JMP + DL_BLK1, + DL_BLK2, + DL_BLK3, + DL_BLK4, + DL_BLK5, + DL_BLK6, + DL_BLK7, + DL_DLI(DL_BLK8), + DL_LMS(DL_CHR40x8x1), + DummyScreen, + DL_HSCROL(DL_CHR40x10x1), + DL_VSCROL(DL_CHR40x8x4), + DL_CHR40x16x4, + DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_CHR20x8x2)))), + DummyScreen+120, + DL_CHR20x16x2, + DL_MAP40x8x4, + DL_MAP80x4x2, + DL_MAP80x4x4, + DL_MAP160x2x2, + DL_MAP160x1x2, + DL_MAP160x2x4, + DL_MAP160x1x4, + DL_MAP320x1x1, + DL_JVB, + DL_JMP }; -unsigned char dlend = 0; +/* We know that the sizeof expression is constant; don't tell us. */ + +#pragma warn (const-comparison, off) int main(void) { - // unfortunately "sizeof()" doesn't work with void data - // (Error: Size of data type is unknown) - // so we trick with the addresses at front and end... - - int returnValue = (((unsigned int)&dlend-(unsigned int)&DisplayList) != 28); // assure only one byte per instruction! + int returnValue = (sizeof DisplayList != 28); // assure only one byte per instruction! clrscr(); if (returnValue) @@ -66,4 +62,3 @@ main(void) return returnValue; } - From 0de44517ac5780b59969dd92ad081d5a68b2dc47 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sun, 12 Mar 2017 23:21:43 +0100 Subject: [PATCH 262/407] few 6502 and some 65SC02 optimizations --- libsrc/runtime/add.s | 59 ++++++++++++++++++++++++--------------- libsrc/runtime/along.s | 17 +++++------ libsrc/runtime/laddeq.s | 12 ++++++-- libsrc/runtime/land.s | 14 +++++++++- libsrc/runtime/leave.s | 19 +++++++++++++ libsrc/runtime/lmod.s | 9 +++++- libsrc/runtime/lmul.s | 15 +++++++++- libsrc/runtime/lor.s | 16 +++++++++-- libsrc/runtime/lpop.s | 6 ++++ libsrc/runtime/lpush.s | 16 +++++++++-- libsrc/runtime/lrsub.s | 19 +++++++++++-- libsrc/runtime/lsave.s | 10 +++---- libsrc/runtime/lsub.s | 9 ++++-- libsrc/runtime/lsubeq.s | 15 +++++++--- libsrc/runtime/ludiv.s | 15 +++++++++- libsrc/runtime/lumod.s | 8 ++++++ libsrc/runtime/lxor.s | 17 +++++++++-- libsrc/runtime/makebool.s | 23 ++++++--------- libsrc/runtime/or.s | 10 ++++++- libsrc/runtime/rsub.s | 12 ++++++-- libsrc/runtime/staxspi.s | 7 +++++ libsrc/runtime/swap.s | 12 +++++++- libsrc/runtime/xor.s | 10 ++++++- 23 files changed, 272 insertions(+), 78 deletions(-) diff --git a/libsrc/runtime/add.s b/libsrc/runtime/add.s index 6fb2dacf7..e644671c0 100644 --- a/libsrc/runtime/add.s +++ b/libsrc/runtime/add.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, spend two bytes for one cycle, improved 65SC02 optimization ; ; CC65 runtime: add ints ; @@ -8,32 +9,46 @@ ; called a lot! .export tosadda0, tosaddax - .importzp sp + .importzp sp, tmp1 .macpack cpu tosadda0: ldx #0 tosaddax: - clc -.if (.cpu .bitand CPU_ISET_65SC02) - adc (sp) ; 65SC02 version - saves 2 cycles - ldy #1 -.else - ldy #0 - adc (sp),y ; lo byte - iny -.endif - pha ; save it - txa - adc (sp),y ; hi byte - tax - clc - lda sp - adc #2 - sta sp - bcc L1 - inc sp+1 -L1: pla ; Restore low byte - rts + clc ; (2) +.if (.cpu .bitand ::CPU_ISET_65SC02) + + adc (sp) ; (7) + tay ; (9) + inc sp ; (14) + bne hiadd ; (17) + inc sp+1 ; (-1+5) +hiadd: txa ; (19) + adc (sp) ; (24) + tax ; (26) + inc sp ; (31) + bne done ; (34) + inc sp+1 ; (-1+5) +done: tya ; (36) + +.else + + ldy #0 ; (4) + adc (sp),y ; (9) lo byte + iny ; (11) + sta tmp1 ; (14) save it + txa ; (16) + adc (sp),y ; (21) hi byte + tax ; (23) + clc ; (25) + lda sp ; (28) + adc #2 ; (30) + sta sp ; (33) + bcc L1 ; (36) + inc sp+1 ; (-1+5) +L1: lda tmp1 ; (39) restore low byte + +.endif + rts ; (6502: 45 cycles, 26 bytes <-> 65SC02: 42 cycles, 22 bytes ) diff --git a/libsrc/runtime/along.s b/libsrc/runtime/along.s index 661b3124a..25eb78c45 100644 --- a/libsrc/runtime/along.s +++ b/libsrc/runtime/along.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 23.11.2002 +; Christian Krueger, 11-Mar-2017, saved 5 bytes ; ; CC65 runtime: Convert char in ax into a long ; @@ -9,16 +10,12 @@ ; Convert A from char to long in EAX +along: ldx #$ff + cmp #$80 ; Positive? + bcs store ; no, apply $FF + aulong: ldx #0 - stx sreg +store: stx sreg stx sreg+1 rts - -along: cmp #$80 ; Positive? - bcc aulong ; Yes, handle like unsigned type - ldx #$ff - stx sreg - stx sreg+1 - rts - - + \ No newline at end of file diff --git a/libsrc/runtime/laddeq.s b/libsrc/runtime/laddeq.s index 2632ec909..57bec0629 100644 --- a/libsrc/runtime/laddeq.s +++ b/libsrc/runtime/laddeq.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 07.04.2000 +; Christian Krueger, 12-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: += operator ; @@ -10,6 +11,7 @@ .export laddeq1, laddeqa, laddeq .importzp sreg, ptr1, tmp1 + .macpack cpu laddeq1: lda #$01 @@ -20,14 +22,20 @@ laddeqa: stx sreg+1 laddeq: sty ptr1+1 ; Store high byte of address - ldy #$00 ; Address low byte clc +.if (.cpu .bitand ::CPU_ISET_65SC02) + adc (ptr1) + sta (ptr1) + ldy #$01 ; Address byte 1 +.else + ldy #$00 ; Address low byte adc (ptr1),y sta (ptr1),y + iny ; Address byte 1 +.endif pha ; Save byte 0 of result for later - iny ; Address byte 1 txa adc (ptr1),y ; Load byte 1 sta (ptr1),y diff --git a/libsrc/runtime/land.s b/libsrc/runtime/land.s index 506c071a4..6ea4e5bcb 100644 --- a/libsrc/runtime/land.s +++ b/libsrc/runtime/land.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: and on longs ; @@ -8,17 +9,28 @@ .import addysp1 .importzp sp, sreg, tmp1 + .macpack cpu tosand0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosandeax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + and (sp) ; byte 0 + ldy #1 +.else ldy #0 and (sp),y ; byte 0 - sta tmp1 iny +.endif + sta tmp1 txa and (sp),y ; byte 1 tax diff --git a/libsrc/runtime/leave.s b/libsrc/runtime/leave.s index 8f4e055f5..4a9ff7994 100644 --- a/libsrc/runtime/leave.s +++ b/libsrc/runtime/leave.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: function epilogue ; @@ -13,6 +14,8 @@ .import addysp .importzp sp + .macpack cpu + leave00: lda #0 leave0: ldx #0 @@ -24,6 +27,20 @@ leavey0: ldx #0 ; return < 256 leavey: jsr addysp ; drop stack frame + +.if (.cpu .bitand ::CPU_ISET_65SC02) + +leave: tay ; save A a sec + lda (sp) ; that's the pushed arg size + sec ; Count the byte, the count's stored in + adc sp + sta sp + bcc L1 + inc sp+1 +L1: tya ; Get return value back + +.else + leave: pha ; save A a sec ldy #0 lda (sp),y ; that's the pushed arg size @@ -33,5 +50,7 @@ leave: pha ; save A a sec bcc L1 inc sp+1 L1: pla ; Get return value back + +.endif rts diff --git a/libsrc/runtime/lmod.s b/libsrc/runtime/lmod.s index 74deb23f0..caeb0c4f6 100644 --- a/libsrc/runtime/lmod.s +++ b/libsrc/runtime/lmod.s @@ -1,6 +1,6 @@ ; ; Ullrich von Bassewitz, 07.08.1998 -; +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; CC65 runtime: modulo operation for long signed ints ; @@ -11,10 +11,17 @@ .import poplsargs, udiv32, negeax .importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4 + .macpack cpu + tosmod0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosmodeax: jsr poplsargs ; Get arguments from stack, adjust sign diff --git a/libsrc/runtime/lmul.s b/libsrc/runtime/lmul.s index 7ad2b2aa4..860d58cba 100644 --- a/libsrc/runtime/lmul.s +++ b/libsrc/runtime/lmul.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 13.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: multiplication for long (unsigned) ints ; @@ -8,20 +9,32 @@ .import addysp1 .importzp sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4 + .macpack cpu + tosmul0ax: tosumul0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosmuleax: tosumuleax: mul32: sta ptr1 stx ptr1+1 ; op2 now in ptr1/sreg +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) + ldy #1 +.else ldy #0 lda (sp),y - sta ptr3 iny +.endif + sta ptr3 lda (sp),y sta ptr3+1 iny diff --git a/libsrc/runtime/lor.s b/libsrc/runtime/lor.s index a74b33059..94ab3c890 100644 --- a/libsrc/runtime/lor.s +++ b/libsrc/runtime/lor.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: or on longs ; @@ -8,17 +9,28 @@ .import addysp1 .importzp sp, sreg, tmp1 + .macpack cpu tosor0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg - sty sreg+1 + sty sreg+1 +.endif tosoreax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + ora (sp) + ldy #1 +.else ldy #0 ora (sp),y ; byte 0 - sta tmp1 iny +.endif + sta tmp1 txa ora (sp),y ; byte 1 tax diff --git a/libsrc/runtime/lpop.s b/libsrc/runtime/lpop.s index 7d281db52..ffff5ffc1 100644 --- a/libsrc/runtime/lpop.s +++ b/libsrc/runtime/lpop.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 29.12.1999 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: long pop ; @@ -8,6 +9,7 @@ .import incsp4 .importzp sp, sreg + .macpack cpu popeax: ldy #3 lda (sp),y @@ -18,8 +20,12 @@ popeax: ldy #3 dey lda (sp),y tax +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) +.else dey lda (sp),y +.endif jmp incsp4 diff --git a/libsrc/runtime/lpush.s b/libsrc/runtime/lpush.s index 074b4320a..4fed77f05 100644 --- a/libsrc/runtime/lpush.s +++ b/libsrc/runtime/lpush.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: long push ; @@ -11,13 +12,20 @@ .import decsp4 .importzp sp, sreg + .macpack cpu + pushl0: lda #0 tax push0ax: - ldy #0 +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else + ldy #$00 sty sreg sty sreg+1 +.endif pusheax: pha ; decsp will destroy A (but not X) jsr decsp4 @@ -30,8 +38,12 @@ pusheax: dey txa sta (sp),y - dey pla +.if (.cpu .bitand ::CPU_ISET_65SC02) + sta (sp) +.else + dey sta (sp),y +.endif rts diff --git a/libsrc/runtime/lrsub.s b/libsrc/runtime/lrsub.s index fd519ca4f..928164f40 100644 --- a/libsrc/runtime/lrsub.s +++ b/libsrc/runtime/lrsub.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: long sub reversed ; @@ -11,18 +12,30 @@ .import addysp1 .importzp sp, sreg, tmp1 + .macpack cpu + tosrsub0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif -tosrsubeax: - ldy #0 +tosrsubeax: sec +.if (.cpu .bitand ::CPU_ISET_65SC02) + sbc (sp) + ldy #1 +.else + ldy #0 sbc (sp),y ; byte 0 + iny +.endif sta tmp1 ; use as temp storage txa - iny sbc (sp),y ; byte 1 tax iny diff --git a/libsrc/runtime/lsave.s b/libsrc/runtime/lsave.s index fa21e463e..82703073a 100644 --- a/libsrc/runtime/lsave.s +++ b/libsrc/runtime/lsave.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 08.08.1998 +; Christian Krueger, 11-Mar-2017, optimization ; ; CC65 runtime: save ax into temp storage/restore ax from temp storage ; @@ -10,11 +11,10 @@ saveeax: sta regsave stx regsave+1 - lda sreg - sta regsave+2 - lda sreg+1 - sta regsave+3 - lda regsave + ldy sreg + sty regsave+2 + ldy sreg+1 + sty regsave+3 rts resteax: diff --git a/libsrc/runtime/lsub.s b/libsrc/runtime/lsub.s index 926d52e51..6f80491ca 100644 --- a/libsrc/runtime/lsub.s +++ b/libsrc/runtime/lsub.s @@ -1,6 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 -; +; Christian Krueger, 11-Mar-2017, ímproved 65SC02 optimization ; CC65 runtime: long sub ; @@ -14,14 +14,19 @@ .macpack cpu tossub0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tossubeax: sec eor #$FF -.if (.cpu .bitand CPU_ISET_65SC02) +.if (.cpu .bitand ::CPU_ISET_65SC02) adc (sp) ; 65SC02 version - saves 2 cycles ldy #1 .else diff --git a/libsrc/runtime/lsubeq.s b/libsrc/runtime/lsubeq.s index 9f5853d29..5e3d25783 100644 --- a/libsrc/runtime/lsubeq.s +++ b/libsrc/runtime/lsubeq.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 07.04.2000 +; Christian Krueger, 12-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: -= operator ; @@ -10,6 +11,7 @@ .export lsubeq1, lsubeqa, lsubeq .importzp sreg, ptr1 + .macpack cpu lsubeq1: lda #$01 @@ -20,15 +22,20 @@ lsubeqa: stx sreg+1 lsubeq: sty ptr1+1 ; Store high byte of address - ldy #$00 ; Address low byte + sec - eor #$FF + .if (.cpu .bitand ::CPU_ISET_65SC02) + adc (ptr1) ; Subtract byte 0 + sta (ptr1) + ldy #$01 ; Address byte 1 + .else + ldy #$00 ; Address low byte adc (ptr1),y ; Subtract byte 0 sta (ptr1),y + iny ; Address byte 1 + .endif pha ; Save byte 0 of result for later - - iny ; Address byte 1 txa eor #$FF adc (ptr1),y ; Subtract byte 1 diff --git a/libsrc/runtime/ludiv.s b/libsrc/runtime/ludiv.s index 149c98a78..54af4780e 100644 --- a/libsrc/runtime/ludiv.s +++ b/libsrc/runtime/ludiv.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 17.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: division for long unsigned ints ; @@ -8,10 +9,17 @@ .import addysp1 .importzp sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 + .macpack cpu + tosudiv0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosudiveax: jsr getlop ; Get the paramameters @@ -30,10 +38,15 @@ getlop: sta ptr3 ; Put right operand in place lda sreg+1 sta ptr4+1 +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) + ldy #1 +.else ldy #0 ; Put left operand in place lda (sp),y - sta ptr1 iny +.endif + sta ptr1 lda (sp),y sta ptr1+1 iny diff --git a/libsrc/runtime/lumod.s b/libsrc/runtime/lumod.s index e290e1167..241801a90 100644 --- a/libsrc/runtime/lumod.s +++ b/libsrc/runtime/lumod.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 27.09.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: modulo operation for long unsigned ints ; @@ -8,10 +9,17 @@ .import getlop, udiv32 .importzp sreg, tmp3, tmp4, ptr2 + .macpack cpu + tosumod0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif tosumodeax: jsr getlop ; Get the paramameters diff --git a/libsrc/runtime/lxor.s b/libsrc/runtime/lxor.s index ce21ef35b..4ec9a4129 100644 --- a/libsrc/runtime/lxor.s +++ b/libsrc/runtime/lxor.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: xor on longs ; @@ -8,16 +9,28 @@ .import addysp1 .importzp sp, sreg, tmp1 + .macpack cpu + tosxor0ax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + stz sreg + stz sreg+1 +.else ldy #$00 sty sreg sty sreg+1 +.endif -tosxoreax: +tosxoreax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + eor (sp) ; byte 0 + ldy #1 +.else ldy #0 eor (sp),y ; byte 0 - sta tmp1 iny +.endif + sta tmp1 txa eor (sp),y ; byte 1 tax diff --git a/libsrc/runtime/makebool.s b/libsrc/runtime/makebool.s index a15b24b93..643f418aa 100644 --- a/libsrc/runtime/makebool.s +++ b/libsrc/runtime/makebool.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.10.1998 +; Christian Krueger, 11-Mar-2017, optimization ; ; CC65 runtime: Make boolean according to flags ; @@ -9,14 +10,14 @@ boolne: bne ret1 - ldx #$00 +ret0: ldx #$00 txa rts -booleq: beq ret1 - ldx #$00 - txa +booleq: bne ret0 +ret1: ldx #$00 + lda #$01 rts @@ -44,17 +45,9 @@ boolult: boolugt: - beq L1 + beq ret0 booluge: - bcs ret1 -L1: ldx #$00 + ldx #$00 txa + rol a rts - - -ret1: ldx #$00 - lda #$01 - rts - - - diff --git a/libsrc/runtime/or.s b/libsrc/runtime/or.s index 8570c0cd7..1c2c4125e 100644 --- a/libsrc/runtime/or.s +++ b/libsrc/runtime/or.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: or on ints ; @@ -8,13 +9,20 @@ .import addysp1 .importzp sp, tmp1 + .macpack cpu + tosora0: ldx #$00 tosorax: +.if (.cpu .bitand ::CPU_ISET_65SC02) + ora (sp) + ldy #1 +.else ldy #0 ora (sp),y - sta tmp1 iny +.endif + sta tmp1 txa ora (sp),y tax diff --git a/libsrc/runtime/rsub.s b/libsrc/runtime/rsub.s index 475a69e76..69ee6da22 100644 --- a/libsrc/runtime/rsub.s +++ b/libsrc/runtime/rsub.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: sub ints reversed ; @@ -8,6 +9,8 @@ .import addysp1 .importzp sp, tmp1 + .macpack cpu + ; ; AX = AX - TOS ; @@ -15,12 +18,17 @@ tosrsuba0: ldx #0 tosrsubax: - ldy #0 sec +.if (.cpu .bitand CPU_ISET_65SC02) + sbc (sp) + ldy #1 +.else + ldy #0 sbc (sp),y ; lo byte + iny +.endif sta tmp1 ; save lo byte txa - iny sbc (sp),y ; hi byte tax lda tmp1 diff --git a/libsrc/runtime/staxspi.s b/libsrc/runtime/staxspi.s index 90738e0d2..3114f449c 100644 --- a/libsrc/runtime/staxspi.s +++ b/libsrc/runtime/staxspi.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 26.10.2000 +; Christian Krueger, 12-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: Store a/x indirect into address at top of stack with index ; @@ -8,6 +9,8 @@ .import incsp2 .importzp sp, tmp1, ptr1 + .macpack cpu + .proc staxspidx sty tmp1 ; Save Y @@ -15,8 +18,12 @@ ldy #1 lda (sp),y sta ptr1+1 +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) +.else dey lda (sp),y +.endif sta ptr1 ; Address now in ptr1 ldy tmp1 ; Restore Y iny ; Address high byte diff --git a/libsrc/runtime/swap.s b/libsrc/runtime/swap.s index e91eeca31..d4a74df5f 100644 --- a/libsrc/runtime/swap.s +++ b/libsrc/runtime/swap.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 06.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: swap ax with TOS ; @@ -7,6 +8,8 @@ .export swapstk .importzp sp, ptr4 + .macpack cpu + swapstk: sta ptr4 stx ptr4+1 @@ -15,11 +18,18 @@ swapstk: tax lda ptr4+1 sta (sp),y +.if (.cpu .bitand ::CPU_ISET_65SC02) + lda (sp) + tay + lda ptr4 + sta (sp) + tya +.else dey lda (sp),y pha lda ptr4 sta (sp),y pla +.endif rts ; whew! - diff --git a/libsrc/runtime/xor.s b/libsrc/runtime/xor.s index 825c576d1..e03922926 100644 --- a/libsrc/runtime/xor.s +++ b/libsrc/runtime/xor.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 05.08.1998 +; Christian Krueger, 11-Mar-2017, added 65SC02 optimization ; ; CC65 runtime: xor on ints ; @@ -8,13 +9,20 @@ .import addysp1 .importzp sp, tmp1 + .macpack cpu + tosxora0: ldx #$00 tosxorax: +.if (.cpu .bitand CPU_ISET_65SC02) + eor (sp) + ldy #1 +.else ldy #0 eor (sp),y - sta tmp1 iny +.endif + sta tmp1 txa eor (sp),y tax From a3d8829be92032d262cbea686c400a098e9e5242 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Fri, 17 Mar 2017 21:42:51 +0100 Subject: [PATCH 263/407] Creativison changes. This change includes some cleanups, removal of mainargs.s (game console programs never have arguments), and a workaround for a problem I'm seeing. The problem is that sometimes (in fact, more often than not) the clrscr() call in testcode/lib/joy-test.c writes some garbage chars on the screen (most often a "P"). Could be my hardware (I haven't seen it on MAME), but to me the root cause is still unknown. --- asminc/creativision.inc | 7 ++++--- cfg/creativision.cfg | 2 +- libsrc/creativision/clrscr.s | 6 +++--- libsrc/creativision/cputc.s | 6 +++--- libsrc/creativision/crt0.s | 15 ++++++++++----- libsrc/creativision/mainargs.s | 22 ---------------------- 6 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 libsrc/creativision/mainargs.s diff --git a/asminc/creativision.inc b/asminc/creativision.inc index 83a63ba07..49d55a342 100644 --- a/asminc/creativision.inc +++ b/asminc/creativision.inc @@ -10,10 +10,10 @@ CURSOR_X = $3C CURSOR_Y = $3D ;** VDP -VDP_CONTROL_W = $3001 -VDP_DATA_W = $3000 -VDP_STATUS_R = $2001 VDP_DATA_R = $2000 +VDP_STATUS_R = $2001 +VDP_DATA_W = $3000 +VDP_CONTROL_W = $3001 ;** PIA PIA0_DATA = $1000 @@ -58,3 +58,4 @@ JOY_NNW = $4A BIOS_IRQ1_ADDR = $FF3F BIOS_IRQ2_ADDR = $FF52 BIOS_NMI_RESET_ADDR = $F808 +BIOS_WRITE_VDP_REG = $FE1F diff --git a/cfg/creativision.cfg b/cfg/creativision.cfg index 06e39b36f..9e4ecd8ce 100644 --- a/cfg/creativision.cfg +++ b/cfg/creativision.cfg @@ -4,7 +4,7 @@ SYMBOLS { MEMORY { ZP: file = "", define = yes, start = $0020, size = $00E0; RAM: file = "", define = yes, start = $01FA, size = $0206; - ROM: file = %O, define = yes, start = $B000, size = $1000; + ROM: file = %O, define = yes, start = $B000, size = $1000, fill = yes, fillval = $FF; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; diff --git a/libsrc/creativision/clrscr.s b/libsrc/creativision/clrscr.s index 9e7238345..3c4856446 100644 --- a/libsrc/creativision/clrscr.s +++ b/libsrc/creativision/clrscr.s @@ -18,7 +18,7 @@ _clrscr: lda #$50 ; VRAM offset high ($10 OR $40) sta VDP_CONTROL_W - lda #$C0 ; Space from ROM setup + lda #$40 ; Space char from ROM setup ldx #0 ldy #3 @@ -34,8 +34,8 @@ L1: sta VDP_DATA_W lda #0 sta CURSOR_X sta CURSOR_Y - sta <SCREEN_PTR + sta SCREEN_PTR lda #$10 - sta >SCREEN_PTR + sta SCREEN_PTR+1 rts diff --git a/libsrc/creativision/cputc.s b/libsrc/creativision/cputc.s index ff60494b9..437b738b2 100644 --- a/libsrc/creativision/cputc.s +++ b/libsrc/creativision/cputc.s @@ -96,8 +96,8 @@ BAD_CHAR: jmp plot ;----------------------------------------------------------------------------- -; Initialize the conio subsystem. Code goes into the INIT segment, which may -; be reused after startup. +; Initialize the conio subsystem. "INIT" segment is nothing special on the +; Creativision, it is part of the "ROM" memory. .segment "INIT" @@ -122,4 +122,4 @@ LL: lda boxchars,x bne LL cli - jmp plot + jmp plot diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s index 420ac71ef..5185ff237 100644 --- a/libsrc/creativision/crt0.s +++ b/libsrc/creativision/crt0.s @@ -31,9 +31,6 @@ entry: ldx #<__RAM_START__ - 1 txs - ; Start interrupts - cli - ; Clear the BSS data jsr zerobss @@ -49,13 +46,21 @@ entry: ; Call module constructors jsr initlib + ; enable vertical blank interrupts in the display controller + lda #$E0 ; 16K RAM, Active Display, Mode 1, VBI enabled + ldx #$01 ; Register 1 + jsr BIOS_WRITE_VDP_REG + + ; Start interrupts + cli + ; Call main() jsr callmain ; Call module destructors. This is also the _exit entry. _exit: jsr donelib - ; TODO: Replace with some sort of reset + ; A Creativision program isn't supposed to exit. loop: jmp loop ; ------------------------------------------------------------------------ @@ -81,7 +86,7 @@ irq2: jmp BIOS_IRQ2_ADDR ; VDP Setup ; This sets to Graphics Mode 1 .byte $00 ; Register 0 - .byte $E0 ; Register 1 16K RAM, Active Display, Mode 1, VBI enabled + .byte $C0 ; Register 1 16K RAM, Active Display, Mode 1, VBI disabled .byte $04 ; Register 2 Name Table at $1000 - $12FF .byte $60 ; Register 3 Colour Table at $1800 - $181F .byte $00 ; Register 4 Pattern Table at $0000 - $07FF diff --git a/libsrc/creativision/mainargs.s b/libsrc/creativision/mainargs.s deleted file mode 100644 index cda76d8d0..000000000 --- a/libsrc/creativision/mainargs.s +++ /dev/null @@ -1,22 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-03-07 -; -; Setup arguments for main -; - - - .constructor initmainargs, 24 - .import __argc, __argv - - -;--------------------------------------------------------------------------- -; Get possible command-line arguments. Goes into the special INIT segment, -; which may be reused after the startup code is run - -.segment "INIT" - -.proc initmainargs - - rts - -.endproc From 360372420bf1592345a0f8977924ce88102d00ec Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 16:33:08 +0100 Subject: [PATCH 264/407] Added 65SC02 support for simulator. --- src/sim65/6502.c | 662 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 546 insertions(+), 116 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index e6f358295..b6559ee46 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -11,6 +11,7 @@ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ +/* Mar-2017, Christian Krueger, added support for 65SC02 */ /* */ /* This software is provided 'as-is', without any expressed or implied */ /* warranty. In no event will the authors be held liable for any damages */ @@ -31,7 +32,14 @@ /* */ /*****************************************************************************/ - +/* Known bugs and limitations of the 65C02 simulation: + * support currently only on the level of 65SC02: + BBRx, BBSx, RMBx, SMBx, WAI and STP are unsupported + * BCD flag handling equals 6502 (unchecked if bug is simulated or wrong for + 6502) + * one cycle win for fetch-modify-write instructions ignored + (e.g. ROL abs,x takes only 6 cycles if no page break occurs) + */ #include "memory.h" #include "error.h" @@ -205,7 +213,22 @@ int PrintCycles; unsigned Addr; \ Cycles = 5; \ ZPAddr = MemReadByte (Regs.PC+1); \ - Addr = MemReadZPWord (ZPAddr) + Regs.YR; \ + Addr = MemReadZPWord (ZPAddr); \ + if (PAGE_CROSS (Addr, Regs.YR)) \ + ++Cycles; \ + Addr += Regs.YR; \ + Regs.AC = Regs.AC op MemReadByte (Addr); \ + TEST_ZF (Regs.AC); \ + TEST_SF (Regs.AC); \ + Regs.PC += 2 + +/* (zp) */ +#define AC_OP_ZPIND(op) \ + unsigned char ZPAddr; \ + unsigned Addr; \ + Cycles = 5; \ + ZPAddr = MemReadByte (Regs.PC+1); \ + Addr = MemReadZPWord (ZPAddr); \ Regs.AC = Regs.AC op MemReadByte (Addr); \ TEST_ZF (Regs.AC); \ TEST_SF (Regs.AC); \ @@ -234,6 +257,8 @@ int PrintCycles; } \ TEST_CF (Regs.AC); \ SET_OF ((res < -128) || (res > 127)); \ + if (CPU!=CPU_6502) \ + ++Cycles; \ } else { \ Regs.AC += rhs + GET_CF (); \ TEST_ZF (Regs.AC); \ @@ -313,6 +338,8 @@ int PrintCycles; TEST_SF (res); \ SET_CF (res <= 0xFF); \ SET_OF (((old^rhs) & (old^res) & 0x80)); \ + if (CPU!=CPU_6502) \ + ++Cycles; \ } else { \ Regs.AC -= rhs + (!GET_CF ()); \ TEST_ZF (Regs.AC); \ @@ -362,6 +389,21 @@ static void OPC_6502_01 (void) +static void OPC_65SC02_04 (void) +/* Opcode $04: TSB zp */ +{ + unsigned char ZPAddr; + unsigned char Val; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Val = MemReadByte (ZPAddr); + SET_ZF ((Val & Regs.AC) == 0); + MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC)); + Regs.PC += 2; +} + + + static void OPC_6502_05 (void) /* Opcode $05: ORA zp */ { @@ -419,6 +461,21 @@ static void OPC_6502_0A (void) +static void OPC_65SC02_0C (void) +/* Opcode $0C: TSB abs */ +{ + unsigned Addr; + unsigned char Val; + Cycles = 6; + Addr = MemReadByte (Regs.PC+1); + Val = MemReadByte (Addr); + SET_ZF ((Val & Regs.AC) == 0); + MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); + Regs.PC += 3; +} + + + static void OPC_6502_0D (void) /* Opcode $0D: ORA abs */ { @@ -460,6 +517,29 @@ static void OPC_6502_11 (void) +static void OPC_65SC02_12 (void) +/* Opcode $12: ORA (zp) */ +{ + AC_OP_ZPIND (|); +} + + + +static void OPC_65SC02_14 (void) +/* Opcode $14: TRB zp */ +{ + unsigned char ZPAddr; + unsigned char Val; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Val = MemReadByte (ZPAddr); + SET_ZF ((Val & Regs.AC) == 0); + MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC)); + Regs.PC += 2; +} + + + static void OPC_6502_15 (void) /* Opcode $15: ORA zp,x */ { @@ -503,6 +583,33 @@ static void OPC_6502_19 (void) +static void OPC_65SC02_1A (void) +/* Opcode $1A: INC a */ +{ + Cycles = 2; + Regs.AC = (Regs.AC + 1) & 0xFF; + TEST_ZF (Regs.AC); + TEST_SF (Regs.AC); + Regs.PC += 1; +} + + + +static void OPC_65SC02_1C (void) +/* Opcode $1C: TRB abs */ +{ + unsigned Addr; + unsigned char Val; + Cycles = 6; + Addr = MemReadByte (Regs.PC+1); + Val = MemReadByte (Addr); + SET_ZF ((Val & Regs.AC) == 0); + MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); + Regs.PC += 3; +} + + + static void OPC_6502_1D (void) /* Opcode $1D: ORA abs,x */ { @@ -675,6 +782,30 @@ static void OPC_6502_31 (void) +static void OPC_65SC02_32 (void) +/* Opcode $32: AND (zp) */ +{ + AC_OP_ZPIND (&); +} + + + +static void OPC_65SC02_34 (void) +/* Opcode $34: BIT zp,x */ +{ + unsigned char ZPAddr; + unsigned char Val; + Cycles = 4; + ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; + Val = MemReadByte (ZPAddr); + SET_SF (Val & 0x80); + SET_OF (Val & 0x40); + SET_ZF ((Val & Regs.AC) == 0); + Regs.PC += 2; +} + + + static void OPC_6502_35 (void) /* Opcode $35: AND zp,x */ { @@ -716,6 +847,36 @@ static void OPC_6502_39 (void) +static void OPC_65SC02_3A (void) +/* Opcode $3A: DEC a */ +{ + Cycles = 2; + Regs.AC = (Regs.AC - 1) & 0xFF; + TEST_ZF (Regs.AC); + TEST_SF (Regs.AC); + Regs.PC += 1; +} + + + +static void OPC_65SC02_3C (void) +/* Opcode $3C: BIT abs,x */ +{ + unsigned Addr; + unsigned char Val; + Cycles = 4; + Addr = MemReadByte (Regs.PC+1) + if (PAGE_CROSS (Addr, Regs.XR)) + ++Cycles; + Val = MemReadByte (Addr + Regs.XR;); + SET_SF (Val & 0x80); + SET_OF (Val & 0x40); + SET_ZF ((Val & Regs.AC) == 0); + Regs.PC += 3; +} + + + static void OPC_6502_3D (void) /* Opcode $3D: AND abs,x */ { @@ -758,6 +919,15 @@ static void OPC_6502_41 (void) +static void OPC_65C02_44 (void) +/* Opcode $44: 'zp' 3 cycle NOP */ +{ + Cycles = 3; + Regs.PC += 2; +} + + + static void OPC_6502_45 (void) /* Opcode $45: EOR zp */ { @@ -868,6 +1038,14 @@ static void OPC_6502_51 (void) +static void OPC_65SC02_52 (void) +/* Opcode $52: EOR (zp) */ +{ + AC_OP_ZPIND (^); +} + + + static void OPC_6502_55 (void) /* Opcode $55: EOR zp,x */ { @@ -912,6 +1090,25 @@ static void OPC_6502_59 (void) +static void OPC_65SC02_5A (void) +/* Opcode $5A: PHY */ +{ + Cycles = 3; + PUSH (Regs.YR); + Regs.PC += 1; +} + + + +static void OPC_65C02_5C (void) +/* Opcode $5C: 'Absolute' 8 cycle NOP */ +{ + Cycles = 8; + Regs.PC += 3; +} + + + static void OPC_6502_5D (void) /* Opcode $5D: EOR abs,x */ { @@ -963,6 +1160,18 @@ static void OPC_6502_61 (void) +static void OPC_65SC02_64 (void) +/* Opcode $64: STZ zp */ +{ + unsigned char ZPAddr; + Cycles = 3; + ZPAddr = MemReadByte (Regs.PC+1); + MemWriteByte (ZPAddr, 0); + Regs.PC += 2; +} + + + static void OPC_6502_65 (void) /* Opcode $65: ADC zp */ { @@ -1026,19 +1235,28 @@ static void OPC_6502_6C (void) /* Opcode $6C: JMP (ind) */ { unsigned PC, Lo, Hi; - Cycles = 5; PC = Regs.PC; Lo = MemReadWord (PC+1); - /* Emulate the 6502 bug */ - Regs.PC = MemReadByte (Lo); - Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF); - Regs.PC |= (MemReadByte (Hi) << 8); + if (CPU==CPU_6502) + { + /* Emulate the 6502 bug */ + Cycles = 5; + Regs.PC = MemReadByte (Lo); + Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF); + Regs.PC |= (MemReadByte (Hi) << 8); - /* Output a warning if the bug is triggered */ - if (Hi != Lo + 1) { - Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X", - PC, Lo); + /* Output a warning if the bug is triggered */ + if (Hi != Lo + 1) + { + Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X", + PC, Lo); + } + } + else + { + Cycles = 6; + Regs.PC = MemReadWord(Lo); } } @@ -1106,6 +1324,32 @@ static void OPC_6502_71 (void) +static void OPC_65SC02_72 (void) +/* Opcode $72: ADC (zp) */ +{ + unsigned char ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadZPWord (ZPAddr); + ADC (MemReadByte (Addr)); + Regs.PC += 2; +} + + + +static void OPC_65SC02_74 (void) +/* Opcode $74: STZ zp,x */ +{ + unsigned char ZPAddr; + Cycles = 4; + ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; + MemWriteByte (ZPAddr, 0); + Regs.PC += 2; +} + + + static void OPC_6502_75 (void) /* Opcode $75: ADC zp,x */ { @@ -1158,6 +1402,30 @@ static void OPC_6502_79 (void) +static void OPC_65SC02_7A (void) +/* Opcode $7A: PLY */ +{ + Cycles = 4; + Regs.YR = POP (); + TEST_ZF (Regs.YR); + TEST_SF (Regs.YR); + Regs.PC += 1; +} + + + +static void OPC_65SC02_7C (void) +/* Opcode $7C: JMP (ind,X) */ +{ + unsigned PC, Adr; + Cycles = 6; + PC = Regs.PC; + Adr = MemReadWord (PC+1); + Regs.PC = MemReadWord(Adr+Regs.XR); +} + + + static void OPC_6502_7D (void) /* Opcode $7D: ADC abs,x */ { @@ -1188,6 +1456,14 @@ static void OPC_6502_7E (void) +static void OPC_65SC02_80 (void) +/* Opcode $80: BRA */ +{ + BRANCH (1); +} + + + static void OPC_6502_81 (void) /* Opcode $81: STA (zp,x) */ { @@ -1250,6 +1526,20 @@ static void OPC_6502_88 (void) +static void OPC_65SC02_89 (void) +/* Opcode $89: BIT #imm */ +{ + unsigned char Val; + Cycles = 2; + Val = MemReadByte (Regs.PC+1); + SET_SF (Val & 0x80); + SET_OF (Val & 0x40); + SET_ZF ((Val & Regs.AC) == 0); + Regs.PC += 2; +} + + + static void OPC_6502_8A (void) /* Opcode $8A: TXA */ { @@ -1320,6 +1610,20 @@ static void OPC_6502_91 (void) +static void OPC_65SC02_92 (void) +/* Opcode $92: sta (zp) */ +{ + unsigned char ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadZPWord (ZPAddr); + MemWriteByte (Addr, Regs.AC); + Regs.PC += 2; +} + + + static void OPC_6502_94 (void) /* Opcode $94: STY zp,x */ { @@ -1390,6 +1694,18 @@ static void OPC_6502_9A (void) +static void OPC_65SC02_9C (void) +/* Opcode $9C: STZ abs */ +{ + unsigned Addr; + Cycles = 4; + Addr = MemReadWord (Regs.PC+1); + MemWriteByte (Addr, 0); + Regs.PC += 3; +} + + + static void OPC_6502_9D (void) /* Opcode $9D: STA abs,x */ { @@ -1402,6 +1718,18 @@ static void OPC_6502_9D (void) +static void OPC_65SC02_9E (void) +/* Opcode $9E: STZ abs,x */ +{ + unsigned Addr; + Cycles = 5; + Addr = MemReadWord (Regs.PC+1) + Regs.XR; + MemWriteByte (Addr, 0); + Regs.PC += 3; +} + + + static void OPC_6502_A0 (void) /* Opcode $A0: LDY #imm */ { @@ -1589,6 +1917,22 @@ static void OPC_6502_B1 (void) +static void OPC_65SC02_B2 (void) +/* Opcode $B2: LDA (zp) */ +{ + unsigned char ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadZPWord (ZPAddr); + Regs.AC = MemReadByte (Addr); + TEST_ZF (Regs.AC); + TEST_SF (Regs.AC); + Regs.PC += 2; +} + + + static void OPC_6502_B4 (void) /* Opcode $B4: LDY zp,x */ { @@ -1884,6 +2228,20 @@ static void OPC_6502_D1 (void) +static void OPC_65SC02_D2 (void) +/* Opcode $D2: CMP (zp) */ +{ + unsigned ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadWord (ZPAddr); + CMP (Regs.AC, MemReadByte (Addr)); + Regs.PC += 2; +} + + + static void OPC_6502_D5 (void) /* Opcode $D5: CMP zp,x */ { @@ -1937,6 +2295,16 @@ static void OPC_6502_D9 (void) +static void OPC_65SC02_DA (void) +/* Opcode $DA: PHX */ +{ + Cycles = 3; + PUSH (Regs.XR); + Regs.PC += 1; +} + + + static void OPC_6502_DD (void) /* Opcode $DD: CMP abs,x */ { @@ -2064,6 +2432,42 @@ static void OPC_6502_EA (void) +static void OPC_65C02_NOP11(void) +/* Opcode 'Illegal' 1 cycle NOP */ +{ + Cycles = 1; + Regs.PC += 1; +} + + + +static void OPC_65C02_NOP22 (void) +/* Opcode 'Illegal' 2 byte 2 cycle NOP */ +{ + Cycles = 2; + Regs.PC += 2; +} + + + +static void OPC_65C02_NOP24 (void) +/* Opcode 'Illegal' 2 byte 4 cycle NOP */ +{ + Cycles = 4; + Regs.PC += 2; +} + + + +static void OPC_65C02_NOP34 (void) +/* Opcode 'Illegal' 3 byte 4 cycle NOP */ +{ + Cycles = 4; + Regs.PC += 3; +} + + + static void OPC_6502_EC (void) /* Opcode $EC: CPX abs */ { @@ -2129,6 +2533,20 @@ static void OPC_6502_F1 (void) +static void OPC_65SC02_F2 (void) +/* Opcode $F2: SBC (zp) */ +{ + unsigned char ZPAddr; + unsigned Addr; + Cycles = 5; + ZPAddr = MemReadByte (Regs.PC+1); + Addr = MemReadZPWord (ZPAddr); + SBC (MemReadByte (Addr)); + Regs.PC += 2; +} + + + static void OPC_6502_F5 (void) /* Opcode $F5: SBC zp,x */ { @@ -2180,6 +2598,18 @@ static void OPC_6502_F9 (void) +static void OPC_65SC02_FA (void) +/* Opcode $7A: PLX */ +{ + Cycles = 4; + Regs.XR = POP (); + TEST_ZF (Regs.XR); + TEST_SF (Regs.XR); + Regs.PC += 1; +} + + + static void OPC_6502_FD (void) /* Opcode $FD: SBC abs,x */ { @@ -2483,260 +2913,260 @@ static const OPFunc OP6502Table[256] = { static const OPFunc OP65C02Table[256] = { OPC_6502_00, OPC_6502_01, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $02 + OPC_65C02_NOP11, // $03 + OPC_65SC02_04, OPC_6502_05, OPC_6502_06, - OPC_Illegal, + OPC_Illegal, // $07: RMB0 currently unsupported OPC_6502_08, OPC_6502_09, OPC_6502_0A, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP11, // $0B + OPC_65SC02_0C, OPC_6502_0D, OPC_6502_0E, - OPC_Illegal, + OPC_Illegal, // $0F: BBR0 currently unsupported OPC_6502_10, OPC_6502_11, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_12, + OPC_65C02_NOP11, // $13 + OPC_65SC02_14, OPC_6502_15, OPC_6502_16, - OPC_Illegal, + OPC_Illegal, // $17: RMB1 currently unsupported OPC_6502_18, OPC_6502_19, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_1A, + OPC_65C02_NOP11, // $1B + OPC_65SC02_1C, OPC_6502_1D, OPC_6502_1E, - OPC_Illegal, + OPC_Illegal, // $1F: BBR1 currently unsupported OPC_6502_20, OPC_6502_21, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $22 + OPC_65C02_NOP11, // $23 OPC_6502_24, OPC_6502_25, OPC_6502_26, - OPC_Illegal, + OPC_Illegal, // $27: RMB2 currently unsupported OPC_6502_28, OPC_6502_29, OPC_6502_2A, - OPC_Illegal, + OPC_65C02_NOP11, // $2B OPC_6502_2C, OPC_6502_2D, OPC_6502_2E, - OPC_Illegal, + OPC_Illegal, // $2F: BBR2 currently unsupported OPC_6502_30, OPC_6502_31, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_32, + OPC_65C02_NOP11, // $33 + OPC_65SC02_34, OPC_6502_35, OPC_6502_36, - OPC_Illegal, + OPC_Illegal, // $37: RMB3 currently unsupported OPC_6502_38, OPC_6502_39, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_3A, + OPC_65C02_NOP11, // $3B + OPC_65SC02_3C, OPC_6502_3D, OPC_6502_3E, - OPC_Illegal, + OPC_Illegal, // $3F: BBR3 currently unsupported OPC_6502_40, OPC_6502_41, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $42 + OPC_65C02_NOP11, // $43 + OPC_65C02_44, // $44 OPC_6502_45, OPC_6502_46, - OPC_Illegal, + OPC_Illegal, // $47: RMB4 currently unsupported OPC_6502_48, OPC_6502_49, OPC_6502_4A, - OPC_Illegal, + OPC_65C02_NOP11, // $4B OPC_6502_4C, OPC_6502_4D, OPC_6502_4E, - OPC_Illegal, + OPC_Illegal, // $4F: BBR4 currently unsupported OPC_6502_50, OPC_6502_51, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_52, + OPC_65C02_NOP11, // $53 + OPC_65C02_NOP24, // $54 OPC_6502_55, OPC_6502_56, - OPC_Illegal, + OPC_Illegal, // $57: RMB5 currently unsupported OPC_6502_58, OPC_6502_59, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_5A, + OPC_65C02_NOP11, // $5B + OPC_65C02_5C, OPC_6502_5D, OPC_6502_5E, - OPC_Illegal, + OPC_Illegal, // $5F: BBR5 currently unsupported OPC_6502_60, OPC_6502_61, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $62 + OPC_65C02_NOP11, // $63 + OPC_65SC02_64, OPC_6502_65, OPC_6502_66, - OPC_Illegal, + OPC_Illegal, // $67: RMB6 currently unsupported OPC_6502_68, OPC_6502_69, OPC_6502_6A, - OPC_Illegal, + OPC_65C02_NOP11, // $6B OPC_65C02_6C, OPC_6502_6D, OPC_6502_6E, - OPC_Illegal, + OPC_Illegal, // $6F: BBR6 currently unsupported OPC_6502_70, OPC_6502_71, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_72, + OPC_65C02_NOP11, // $73 + OPC_65SC02_74, OPC_6502_75, OPC_6502_76, - OPC_Illegal, + OPC_Illegal, // $77: RMB7 currently unsupported OPC_6502_78, OPC_6502_79, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_7A, + OPC_65C02_NOP11, // $7B + OPC_65SC02_7C, OPC_6502_7D, OPC_6502_7E, - OPC_Illegal, - OPC_Illegal, + OPC_Illegal, // $7F: BBR7 currently unsupported + OPC_65SC02_80, OPC_6502_81, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $82 + OPC_65C02_NOP11, // $83 OPC_6502_84, OPC_6502_85, OPC_6502_86, - OPC_Illegal, + OPC_Illegal, // $87: SMB0 currently unsupported OPC_6502_88, - OPC_Illegal, + OPC_65SC02_89, OPC_6502_8A, - OPC_Illegal, + OPC_65C02_NOP11, // $8B OPC_6502_8C, OPC_6502_8D, OPC_6502_8E, - OPC_Illegal, + OPC_Illegal, // $8F: BBS0 currently unsupported OPC_6502_90, OPC_6502_91, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_92, + OPC_65C02_NOP11, // $93 OPC_6502_94, OPC_6502_95, OPC_6502_96, - OPC_Illegal, + OPC_Illegal, // $97: SMB1 currently unsupported OPC_6502_98, OPC_6502_99, OPC_6502_9A, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP11, // $9B + OPC_65SC02_9C, OPC_6502_9D, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_9E, + OPC_Illegal, // $9F: BBS1 currently unsupported OPC_6502_A0, OPC_6502_A1, OPC_6502_A2, - OPC_Illegal, + OPC_65C02_NOP11, // $A3 OPC_6502_A4, OPC_6502_A5, OPC_6502_A6, - OPC_Illegal, + OPC_Illegal, // $A7: SMB2 currently unsupported OPC_6502_A8, OPC_6502_A9, OPC_6502_AA, - OPC_Illegal, + OPC_65C02_NOP11, // $AB OPC_6502_AC, OPC_6502_AD, OPC_6502_AE, - OPC_Illegal, + OPC_Illegal, // $AF: BBS2 currently unsupported OPC_6502_B0, OPC_6502_B1, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_B2, + OPC_65C02_NOP11, // $B3 OPC_6502_B4, OPC_6502_B5, OPC_6502_B6, - OPC_Illegal, + OPC_Illegal, // $B7: SMB3 currently unsupported OPC_6502_B8, OPC_6502_B9, OPC_6502_BA, - OPC_Illegal, + OPC_65C02_NOP11, // $BB OPC_6502_BC, OPC_6502_BD, OPC_6502_BE, - OPC_Illegal, + OPC_Illegal, // $BF: BBS3 currently unsupported OPC_6502_C0, OPC_6502_C1, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $C2 + OPC_65C02_NOP11, // $C3 OPC_6502_C4, OPC_6502_C5, OPC_6502_C6, - OPC_Illegal, + OPC_Illegal, // $C7: SMB4 currently unsupported OPC_6502_C8, OPC_6502_C9, OPC_6502_CA, - OPC_Illegal, + OPC_Illegal, // $CB: WAI currently unsupported OPC_6502_CC, OPC_6502_CD, OPC_6502_CE, - OPC_Illegal, + OPC_Illegal, // $CF: BBS4 currently unsupported OPC_6502_D0, OPC_6502_D1, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_D2, + OPC_65C02_NOP11, // $D3 + OPC_65C02_NOP24, // $D4 OPC_6502_D5, OPC_6502_D6, - OPC_Illegal, + OPC_Illegal, // $D7: SMB5 currently unsupported OPC_6502_D8, OPC_6502_D9, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_DA, + OPC_Illegal, // $DB: STP currently unsupported + OPC_65C02_NOP34, // $DC OPC_6502_DD, OPC_6502_DE, - OPC_Illegal, + OPC_Illegal, // $DF: BBS5 currently unsupported OPC_6502_E0, OPC_6502_E1, - OPC_Illegal, - OPC_Illegal, + OPC_65C02_NOP22, // $E2 + OPC_65C02_NOP11, // $E3 OPC_6502_E4, OPC_6502_E5, OPC_6502_E6, - OPC_Illegal, + OPC_Illegal, // $E7: SMB6 currently unsupported OPC_6502_E8, OPC_6502_E9, OPC_6502_EA, - OPC_Illegal, + OPC_65C02_NOP11, // $EB OPC_6502_EC, OPC_6502_ED, OPC_6502_EE, - OPC_Illegal, + OPC_Illegal, // $EF: BBS6 currently unsupported OPC_6502_F0, OPC_6502_F1, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_F2, + OPC_65C02_NOP11, // $F3 + OPC_65C02_NOP24, // $F4 OPC_6502_F5, OPC_6502_F6, - OPC_Illegal, + OPC_Illegal, // $F7: SMB7 currently unsupported OPC_6502_F8, OPC_6502_F9, - OPC_Illegal, - OPC_Illegal, - OPC_Illegal, + OPC_65SC02_FA, + OPC_65C02_NOP11, // $FB + OPC_65C02_NOP34, // $FC OPC_6502_FD, OPC_6502_FE, - OPC_Illegal, + OPC_Illegal, // $FF: BBS7 currently unsupported }; From 4ba34f2a69b14b04a6fef142ab4174b8b1b2fe65 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 16:54:00 +0100 Subject: [PATCH 265/407] fixed scrambled semicolon --- src/sim65/6502.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index b6559ee46..bd5abcac7 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -865,10 +865,10 @@ static void OPC_65SC02_3C (void) unsigned Addr; unsigned char Val; Cycles = 4; - Addr = MemReadByte (Regs.PC+1) + Addr = MemReadByte (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.XR)) ++Cycles; - Val = MemReadByte (Addr + Regs.XR;); + Val = MemReadByte (Addr + Regs.XR); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); From c50e4d25e20ddae2384a8d8a6a6d55e75c4836ec Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 16:56:36 +0100 Subject: [PATCH 266/407] additional fix for scrambled code (sorry) --- src/sim65/6502.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index bd5abcac7..af82f00f7 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -865,7 +865,7 @@ static void OPC_65SC02_3C (void) unsigned Addr; unsigned char Val; Cycles = 4; - Addr = MemReadByte (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.XR)) ++Cycles; Val = MemReadByte (Addr + Regs.XR); From 0985655ac748656b7f7d80fa3695bd21a4fdf6f9 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 17:02:22 +0100 Subject: [PATCH 267/407] Fixed bug in original sim65 implementation (reason for C&P error in last commit) --- src/sim65/6502.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index af82f00f7..996334295 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -1447,7 +1447,7 @@ static void OPC_6502_7E (void) unsigned Addr; unsigned Val; Cycles = 7; - Addr = MemReadByte (Regs.PC+1) + Regs.XR; + Addr = MemReadWord (Regs.PC+1) + Regs.XR; Val = MemReadByte (Addr); ROR (Val); MemWriteByte (Addr, Val); From ad003e59919028a6563d88cd8ef16c66474b2aa3 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 20:27:41 +0100 Subject: [PATCH 268/407] style changes --- src/sim65/6502.c | 122 +++++++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 58 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 996334295..eeaeeca22 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -215,7 +215,9 @@ int PrintCycles; ZPAddr = MemReadByte (Regs.PC+1); \ Addr = MemReadZPWord (ZPAddr); \ if (PAGE_CROSS (Addr, Regs.YR)) \ + { \ ++Cycles; \ + } \ Addr += Regs.YR; \ Regs.AC = Regs.AC op MemReadByte (Addr); \ TEST_ZF (Regs.AC); \ @@ -257,8 +259,10 @@ int PrintCycles; } \ TEST_CF (Regs.AC); \ SET_OF ((res < -128) || (res > 127)); \ - if (CPU!=CPU_6502) \ + if (CPU != CPU_6502) \ + { \ ++Cycles; \ + } \ } else { \ Regs.AC += rhs + GET_CF (); \ TEST_ZF (Regs.AC); \ @@ -338,8 +342,10 @@ int PrintCycles; TEST_SF (res); \ SET_CF (res <= 0xFF); \ SET_OF (((old^rhs) & (old^res) & 0x80)); \ - if (CPU!=CPU_6502) \ + if (CPU != CPU_6502) \ + { \ ++Cycles; \ + } \ } else { \ Regs.AC -= rhs + (!GET_CF ()); \ TEST_ZF (Regs.AC); \ @@ -396,7 +402,7 @@ static void OPC_65SC02_04 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC)); Regs.PC += 2; @@ -419,7 +425,7 @@ static void OPC_6502_06 (void) unsigned Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr) << 1; + Val = MemReadByte (ZPAddr) << 1; MemWriteByte (ZPAddr, (unsigned char) Val); TEST_ZF (Val & 0xFF); TEST_SF (Val); @@ -468,7 +474,7 @@ static void OPC_65SC02_0C (void) unsigned char Val; Cycles = 6; Addr = MemReadByte (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); Regs.PC += 3; @@ -491,7 +497,7 @@ static void OPC_6502_0E (void) unsigned Val; Cycles = 6; Addr = MemReadWord (Regs.PC+1); - Val = MemReadByte (Addr) << 1; + Val = MemReadByte (Addr) << 1; MemWriteByte (Addr, (unsigned char) Val); TEST_ZF (Val & 0xFF); TEST_SF (Val); @@ -532,7 +538,7 @@ static void OPC_65SC02_14 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC)); Regs.PC += 2; @@ -555,7 +561,7 @@ static void OPC_6502_16 (void) unsigned Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr) << 1; + Val = MemReadByte (ZPAddr) << 1; MemWriteByte (ZPAddr, (unsigned char) Val); TEST_ZF (Val & 0xFF); TEST_SF (Val); @@ -602,7 +608,7 @@ static void OPC_65SC02_1C (void) unsigned char Val; Cycles = 6; Addr = MemReadByte (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); Regs.PC += 3; @@ -625,7 +631,7 @@ static void OPC_6502_1E (void) unsigned Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr) << 1; + Val = MemReadByte (Addr) << 1; MemWriteByte (Addr, (unsigned char) Val); TEST_ZF (Val & 0xFF); TEST_SF (Val); @@ -640,7 +646,7 @@ static void OPC_6502_20 (void) { unsigned Addr; Cycles = 6; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Regs.PC += 2; PUSH (PCH); PUSH (PCL); @@ -666,7 +672,7 @@ static void OPC_6502_24 (void) unsigned char Val; Cycles = 3; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); @@ -690,7 +696,7 @@ static void OPC_6502_26 (void) unsigned Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); ROL (Val); MemWriteByte (ZPAddr, Val); Regs.PC += 2; @@ -734,7 +740,7 @@ static void OPC_6502_2C (void) unsigned char Val; Cycles = 4; Addr = MemReadByte (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); @@ -758,7 +764,7 @@ static void OPC_6502_2E (void) unsigned Val; Cycles = 6; Addr = MemReadWord (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); ROL (Val); MemWriteByte (Addr, Val); Regs.PC += 3; @@ -797,7 +803,7 @@ static void OPC_65SC02_34 (void) unsigned char Val; Cycles = 4; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); @@ -821,7 +827,7 @@ static void OPC_6502_36 (void) unsigned Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); ROL (Val); MemWriteByte (ZPAddr, Val); Regs.PC += 2; @@ -892,7 +898,7 @@ static void OPC_6502_3E (void) unsigned Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); ROL (Val); MemWriteByte (Addr, Val); Regs.PC += 2; @@ -943,7 +949,7 @@ static void OPC_6502_46 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_CF (Val & 0x01); Val >>= 1; MemWriteByte (ZPAddr, Val); @@ -1011,7 +1017,7 @@ static void OPC_6502_4E (void) unsigned char Val; Cycles = 6; Addr = MemReadWord (Regs.PC+1); - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_CF (Val & 0x01); Val >>= 1; MemWriteByte (Addr, Val); @@ -1061,7 +1067,7 @@ static void OPC_6502_56 (void) unsigned char Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); SET_CF (Val & 0x01); Val >>= 1; MemWriteByte (ZPAddr, Val); @@ -1124,7 +1130,7 @@ static void OPC_6502_5E (void) unsigned char Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); SET_CF (Val & 0x01); Val >>= 1; MemWriteByte (Addr, Val); @@ -1153,7 +1159,7 @@ static void OPC_6502_61 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); ADC (MemReadByte (Addr)); Regs.PC += 2; } @@ -1191,7 +1197,7 @@ static void OPC_6502_66 (void) unsigned Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); ROR (Val); MemWriteByte (ZPAddr, Val); Regs.PC += 2; @@ -1238,7 +1244,7 @@ static void OPC_6502_6C (void) PC = Regs.PC; Lo = MemReadWord (PC+1); - if (CPU==CPU_6502) + if (CPU == CPU_6502) { /* Emulate the 6502 bug */ Cycles = 5; @@ -1369,7 +1375,7 @@ static void OPC_6502_76 (void) unsigned Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr); + Val = MemReadByte (ZPAddr); ROR (Val); MemWriteByte (ZPAddr, Val); Regs.PC += 2; @@ -1392,7 +1398,7 @@ static void OPC_6502_79 (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -1431,7 +1437,7 @@ static void OPC_6502_7D (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.XR)) { ++Cycles; } @@ -1448,7 +1454,7 @@ static void OPC_6502_7E (void) unsigned Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr); + Val = MemReadByte (Addr); ROR (Val); MemWriteByte (Addr, Val); Regs.PC += 3; @@ -1471,7 +1477,7 @@ static void OPC_6502_81 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); MemWriteByte (Addr, Regs.AC); Regs.PC += 2; } @@ -1531,7 +1537,7 @@ static void OPC_65SC02_89 (void) { unsigned char Val; Cycles = 2; - Val = MemReadByte (Regs.PC+1); + Val = MemReadByte (Regs.PC+1); SET_SF (Val & 0x80); SET_OF (Val & 0x40); SET_ZF ((Val & Regs.AC) == 0); @@ -1603,7 +1609,7 @@ static void OPC_6502_91 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr) + Regs.YR; + Addr = MemReadZPWord (ZPAddr) + Regs.YR; MemWriteByte (Addr, Regs.AC); Regs.PC += 2; } @@ -1617,7 +1623,7 @@ static void OPC_65SC02_92 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); MemWriteByte (Addr, Regs.AC); Regs.PC += 2; } @@ -1677,7 +1683,7 @@ static void OPC_6502_99 (void) { unsigned Addr; Cycles = 5; - Addr = MemReadWord (Regs.PC+1) + Regs.YR; + Addr = MemReadWord (Regs.PC+1) + Regs.YR; MemWriteByte (Addr, Regs.AC); Regs.PC += 3; } @@ -1711,7 +1717,7 @@ static void OPC_6502_9D (void) { unsigned Addr; Cycles = 5; - Addr = MemReadWord (Regs.PC+1) + Regs.XR; + Addr = MemReadWord (Regs.PC+1) + Regs.XR; MemWriteByte (Addr, Regs.AC); Regs.PC += 3; } @@ -1723,7 +1729,7 @@ static void OPC_65SC02_9E (void) { unsigned Addr; Cycles = 5; - Addr = MemReadWord (Regs.PC+1) + Regs.XR; + Addr = MemReadWord (Regs.PC+1) + Regs.XR; MemWriteByte (Addr, 0); Regs.PC += 3; } @@ -1853,7 +1859,7 @@ static void OPC_6502_AC (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Regs.YR = MemReadByte (Addr); TEST_ZF (Regs.YR); TEST_SF (Regs.YR); @@ -1867,7 +1873,7 @@ static void OPC_6502_AD (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Regs.AC = MemReadByte (Addr); TEST_ZF (Regs.AC); TEST_SF (Regs.AC); @@ -1881,7 +1887,7 @@ static void OPC_6502_AE (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Regs.XR = MemReadByte (Addr); TEST_ZF (Regs.XR); TEST_SF (Regs.XR); @@ -1905,7 +1911,7 @@ static void OPC_6502_B1 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -1924,7 +1930,7 @@ static void OPC_65SC02_B2 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); Regs.AC = MemReadByte (Addr); TEST_ZF (Regs.AC); TEST_SF (Regs.AC); @@ -2082,7 +2088,7 @@ static void OPC_6502_C1 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); CMP (Regs.AC, MemReadByte (Addr)); Regs.PC += 2; } @@ -2120,7 +2126,7 @@ static void OPC_6502_C6 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr) - 1; + Val = MemReadByte (ZPAddr) - 1; MemWriteByte (ZPAddr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2168,7 +2174,7 @@ static void OPC_6502_CC (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); CMP (Regs.YR, MemReadByte (Addr)); Regs.PC += 3; } @@ -2180,7 +2186,7 @@ static void OPC_6502_CD (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); CMP (Regs.AC, MemReadByte (Addr)); Regs.PC += 3; } @@ -2218,7 +2224,7 @@ static void OPC_6502_D1 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadWord (ZPAddr); + Addr = MemReadWord (ZPAddr); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -2235,7 +2241,7 @@ static void OPC_65SC02_D2 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadWord (ZPAddr); + Addr = MemReadWord (ZPAddr); CMP (Regs.AC, MemReadByte (Addr)); Regs.PC += 2; } @@ -2327,7 +2333,7 @@ static void OPC_6502_DE (void) unsigned char Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr) - 1; + Val = MemReadByte (Addr) - 1; MemWriteByte (Addr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2353,7 +2359,7 @@ static void OPC_6502_E1 (void) unsigned Addr; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); SBC (MemReadByte (Addr)); Regs.PC += 2; } @@ -2391,7 +2397,7 @@ static void OPC_6502_E6 (void) unsigned char Val; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Val = MemReadByte (ZPAddr) + 1; + Val = MemReadByte (ZPAddr) + 1; MemWriteByte (ZPAddr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2485,7 +2491,7 @@ static void OPC_6502_ED (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); SBC (MemReadByte (Addr)); Regs.PC += 3; } @@ -2499,7 +2505,7 @@ static void OPC_6502_EE (void) unsigned char Val; Cycles = 6; Addr = MemReadWord (Regs.PC+1); - Val = MemReadByte (Addr) + 1; + Val = MemReadByte (Addr) + 1; MemWriteByte (Addr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2523,7 +2529,7 @@ static void OPC_6502_F1 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -2540,7 +2546,7 @@ static void OPC_65SC02_F2 (void) unsigned Addr; Cycles = 5; ZPAddr = MemReadByte (Regs.PC+1); - Addr = MemReadZPWord (ZPAddr); + Addr = MemReadZPWord (ZPAddr); SBC (MemReadByte (Addr)); Regs.PC += 2; } @@ -2566,7 +2572,7 @@ static void OPC_6502_F6 (void) unsigned char Val; Cycles = 6; ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR; - Val = MemReadByte (ZPAddr) + 1; + Val = MemReadByte (ZPAddr) + 1; MemWriteByte (ZPAddr, Val); TEST_ZF (Val); TEST_SF (Val); @@ -2588,7 +2594,7 @@ static void OPC_6502_F9 (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.YR)) { ++Cycles; } @@ -2615,7 +2621,7 @@ static void OPC_6502_FD (void) { unsigned Addr; Cycles = 4; - Addr = MemReadWord (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); if (PAGE_CROSS (Addr, Regs.XR)) { ++Cycles; } @@ -2632,7 +2638,7 @@ static void OPC_6502_FE (void) unsigned char Val; Cycles = 7; Addr = MemReadWord (Regs.PC+1) + Regs.XR; - Val = MemReadByte (Addr) + 1; + Val = MemReadByte (Addr) + 1; MemWriteByte (Addr, Val); TEST_ZF (Val); TEST_SF (Val); From 2048d6cfb5c29b798bd459a31192f19f4d675219 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sat, 18 Mar 2017 20:57:12 +0100 Subject: [PATCH 269/407] Removed top blank line. --- libsrc/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index cb3517c7e..f4aa03101 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -1,4 +1,3 @@ - ifneq ($(shell echo),) CMD_EXE = 1 endif From e14e13abf4850c16bade80f3519faf2760b322d2 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sat, 18 Mar 2017 22:52:13 +0100 Subject: [PATCH 270/407] fixed curly brackets for single line scopes --- src/sim65/6502.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index eeaeeca22..0320dd895 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -214,8 +214,7 @@ int PrintCycles; Cycles = 5; \ ZPAddr = MemReadByte (Regs.PC+1); \ Addr = MemReadZPWord (ZPAddr); \ - if (PAGE_CROSS (Addr, Regs.YR)) \ - { \ + if (PAGE_CROSS (Addr, Regs.YR)) { \ ++Cycles; \ } \ Addr += Regs.YR; \ @@ -259,8 +258,7 @@ int PrintCycles; } \ TEST_CF (Regs.AC); \ SET_OF ((res < -128) || (res > 127)); \ - if (CPU != CPU_6502) \ - { \ + if (CPU != CPU_6502) { \ ++Cycles; \ } \ } else { \ @@ -342,8 +340,7 @@ int PrintCycles; TEST_SF (res); \ SET_CF (res <= 0xFF); \ SET_OF (((old^rhs) & (old^res) & 0x80)); \ - if (CPU != CPU_6502) \ - { \ + if (CPU != CPU_6502) { \ ++Cycles; \ } \ } else { \ From 66634ef6834438324104d6f1708a0358bd3e31ae Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Mar 2017 17:48:12 +0100 Subject: [PATCH 271/407] Cleaned up test Makefiles. --- test/Makefile | 23 ++------ test/assembler/.gitignore | 3 - test/assembler/Makefile | 91 ++++++++++++++++++------------ test/disassembler/Makefile | 76 ++++++++++++++++--------- test/err/Makefile | 21 ++++--- test/misc/Makefile | 90 ++++++++++++++++++------------ test/ref/Makefile | 110 ++++++++++++++++--------------------- test/val/Makefile | 65 +++++++++------------- 8 files changed, 253 insertions(+), 226 deletions(-) delete mode 100644 test/assembler/.gitignore diff --git a/test/Makefile b/test/Makefile index 4817e70e0..a02bd91fb 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,43 +1,30 @@ - -# top-level makefile for the regression tests +# top-level Makefile for the regression tests # You can comment this special target when you debug the regression tests. # Then, make will give you more progress reports. .SILENT: ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - EXE := .exe - MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) else - EXE := - MKDIR = mkdir $1 RMDIR = $(RM) -r $1 endif -WORKDIR := ../testwrk - -CC := gcc +WORKDIR = ../testwrk .PHONY: all dotests continue mostlyclean clean all: dotests -$(WORKDIR): - $(call MKDIR,$(WORKDIR)) - -$(WORKDIR)/bdiff$(EXE): bdiff.c | $(WORKDIR) - $(CC) -O2 -o $@ $< - .NOTPARALLEL: dotests: mostlyclean continue -continue: $(WORKDIR)/bdiff$(EXE) +continue: @$(MAKE) -C assembler all @$(MAKE) -C disassembler all @$(MAKE) -C val all @@ -46,6 +33,8 @@ continue: $(WORKDIR)/bdiff$(EXE) @$(MAKE) -C misc all mostlyclean: + @$(MAKE) -C assembler clean + @$(MAKE) -C disassembler clean @$(MAKE) -C val clean @$(MAKE) -C ref clean @$(MAKE) -C err clean diff --git a/test/assembler/.gitignore b/test/assembler/.gitignore deleted file mode 100644 index c0c74a35e..000000000 --- a/test/assembler/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.o -*.bin -*.lst diff --git a/test/assembler/Makefile b/test/assembler/Makefile index 5d38847f5..fb840446c 100644 --- a/test/assembler/Makefile +++ b/test/assembler/Makefile @@ -1,45 +1,68 @@ +# Makefile for the assembler regression tests -# makefile for the assembler regression tests +ifneq ($(shell echo),) + CMD_EXE = 1 +endif -BINDIR = ../../bin -WORKDIR := ../../testwrk +ifdef CMD_EXE + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) +else + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 + DEL = $(RM) $1 +endif -BASE_TARGETS = 6502 6502x 65sc02 65c02 -BASE_TARGETS += 4510 huc6280 +CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) -OPCODE_TARGETS = $(BASE_TARGETS) -CPUDETECT_TARGETS = $(BASE_TARGETS) +WORKDIR = ../../testwrk/asm -CPUDETECT_TARGETS += 65816 +DIFF = $(WORKDIR)/bdiff$(EXE) -# default target defined later -all: +CC = gcc +CFLAGS = -O2 -# generate opcode targets and expand target list -define opcode -OPCODE_TARGETLIST += $$(WORKDIR)/$(1)-opcodes.bin -$$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s - @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$< - @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1) - @echo ca65 --cpu $(1) opcodes ok - @rm -f $(1)-opcodes.o #workaround for #168 -endef -$(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target)))) +.PHONY: all clean -# generate cpudetect targets and expand target list -define cpudetect -CPUDETECT_TARGETLIST += $$(WORKDIR)/$(1)-cpudetect.bin -$$(WORKDIR)/$(1)-cpudetect.bin: cpudetect.s - @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-cpudetect.lst --obj-path $$(WORKDIR) -o $$@ $$< - @diff -q $(1)-cpudetect.ref $$@ || (cat $$(WORKDIR)/$(1)-cpudetect.lst ; exit 1) - @echo ca65 --cpu $(1) cpudetect ok - @rm -f cpudetect.o #workaround for #168 -endef -$(foreach target,$(CPUDETECT_TARGETS),$(eval $(call cpudetect,$(target)))) +OPCODE_REFS := $(wildcard *-opcodes.ref) +OPCODE_CPUS = $(foreach ref,$(OPCODE_REFS),$(ref:%-opcodes.ref=%)) +OPCODE_BINS = $(foreach cpu,$(OPCODE_CPUS),$(WORKDIR)/$(cpu)-opcodes.bin) -# now that all targets have been generated, get to the manual ones -all: $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST) - @# +CPUDETECT_REFS := $(wildcard *-cpudetect.ref) +CPUDETECT_CPUS = $(foreach ref,$(CPUDETECT_REFS),$(ref:%-cpudetect.ref=%)) +CPUDETECT_BINS = $(foreach cpu,$(CPUDETECT_CPUS),$(WORKDIR)/$(cpu)-cpudetect.bin) -.PHONY: all $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST) +all: $(OPCODE_BINS) $(CPUDETECT_BINS) +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + +$(DIFF): ../bdiff.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< + +define OPCODE_template + +$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF) + $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$< + $(DIFF) $$@ $1-opcodes.ref + +endef # OPCODE_template + +$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu)))) + +define CPUDETECT_template + +$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF) + $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$< + $(DIFF) $$@ $1-cpudetect.ref + +endef # CPUDETECT_template + +$(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu)))) + +clean: + @$(call RMDIR,$(WORKDIR)) + @$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o) diff --git a/test/disassembler/Makefile b/test/disassembler/Makefile index 2621b0c20..f8942ef73 100644 --- a/test/disassembler/Makefile +++ b/test/disassembler/Makefile @@ -1,42 +1,64 @@ +# Makefile for the disassembler regression tests -# makefile for the disassembler regression tests +ifneq ($(shell echo),) + CMD_EXE = 1 +endif -BINDIR = ../../bin -WORKDIR := ../../testwrk +ifdef CMD_EXE + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) +else + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 + DEL = $(RM) $1 +endif -#BASE_TARGETS = 6502 6502x 65sc02 65c02 -#BASE_TARGETS += 4510 huc6280 -BASE_TARGETS = 4510 +CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65) + +WORKDIR = ../../testwrk/dasm + +DIFF = $(WORKDIR)/bdiff$(EXE) + +CC = gcc +CFLAGS = -O2 START = --start-addr 0x8000 -DISASS_TARGETS = $(BASE_TARGETS) +.PHONY: all clean + +SOURCES := $(wildcard *.s) +CPUS = $(foreach src,$(SOURCES),$(src:%-disass.s=%)) +BINS = $(foreach cpu,$(CPUS),$(WORKDIR)/$(cpu)-reass.bin) # default target defined later -all: +all: $(BINS) -# generate opcode targets and expand target list -define disass -DISASS_TARGETLIST += $$(WORKDIR)/$(1)-reass.bin $$(WORKDIR)/$(1)-reass.s $$(WORKDIR)/$(1)-disass.bin +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) -$$(WORKDIR)/$(1)-disass.bin: $(1)-disass.s - @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$< - @rm -f $(1)-disass.o #workaround for #168 +$(DIFF): ../bdiff.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< -$$(WORKDIR)/$(1)-reass.s: $$(WORKDIR)/$(1)-disass.bin - @$$(BINDIR)/da65 --cpu $(1) $(START) -o $$@ $$< +define DISASS_template -$$(WORKDIR)/$(1)-reass.bin: $$(WORKDIR)/$(1)-reass.s - @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$< - @rm -f $(1)-reass.o #workaround for #168 - @cmp $$@ $$(WORKDIR)/$(1)-disass.bin - @echo da65 --cpu $(1) ok -endef -$(foreach target,$(DISASS_TARGETS),$(eval $(call disass,$(target)))) +$(WORKDIR)/$1-disass.bin: $1-disass.s | $(WORKDIR) + $(CL65) --cpu $1 -t none $(START) -o $$@ $$< -# now that all targets have been generated, get to the manual ones -all: $(DISASS_TARGETLIST) - @# +$(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin + $(DA65) --cpu $1 $(START) -o $$@ $$< -.PHONY: all $(DISASS_TARGETLIST) +$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF) + $(CL65) --cpu $1 -t none $(START) -o $$@ $$< + $(DIFF) $$@ $(WORKDIR)/$1-disass.bin +endef # DISASS_template + +$(foreach cpu,$(CPUS),$(eval $(call DISASS_template,$(cpu)))) + +clean: + @$(call RMDIR,$(WORKDIR)) + @$(call DEL,$(SOURCES:.s=.o)) diff --git a/test/err/Makefile b/test/err/Makefile index bc4226acb..2bcc1d264 100644 --- a/test/err/Makefile +++ b/test/err/Makefile @@ -1,24 +1,27 @@ -# makefile for the tests that MUST NOT compile +# Makefile for the tests that MUST NOT compile ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - NOT := - # Hack - DEL = -del /f $(subst /,\,$1) + NOT = - # Hack + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) else - NOT := ! - DEL = $(RM) $1 + NOT = ! + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 endif CC65 := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65) -WORKDIR := ../../testwrk +WORKDIR = ../../testwrk/err .PHONY: all clean -TESTS := $(patsubst %.c,$(WORKDIR)/%.s,$(wildcard *.c)) +SOURCES := $(wildcard *.c) +TESTS = $(patsubst %.c,$(WORKDIR)/%.s,$(SOURCES)) all: $(TESTS) @@ -26,4 +29,4 @@ $(WORKDIR)/%.s: %.c $(NOT) $(CC65) -o $@ $< clean: - @$(call DEL,$(TESTS)) + @$(call RMDIR,$(WORKDIR)) diff --git a/test/misc/Makefile b/test/misc/Makefile index 918316c6c..6512a9fd9 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -1,63 +1,85 @@ - -# makefile for the remaining tests that need special care in one way or another +# Makefile for the remaining tests that need special care in one way or another ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - S := $(subst /,\,/) - NOT := - # Hack - DEL = -del /f $(subst /,\,$1) + S = $(subst /,\,/) + NOT = - # Hack + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) else - S := / - NOT := ! + S = / + NOT = ! + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif -CC65FLAGS := -t sim6502 -SIM65FLAGS := -x 200000000 +CC65FLAGS = -t sim6502 +SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) -WORKDIR := ..$S..$Stestwrk -DIFF := $(WORKDIR)/bdiff +WORKDIR = ..$S..$Stestwrk$Smisc + +OPTIONS = g O Os Osi Osir Oi Oir Or + +DIFF = $(WORKDIR)$Sbdiff$(EXE) + +CC = gcc +CFLAGS = -O2 .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) all: $(TESTS) +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + +$(DIFF): ../bdiff.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< + +define PRG_template + # should compile, but then hangs in an endless loop -$(WORKDIR)/endless%prg: endless.c - $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ - $(NOT) $(SIM65) $(SIM65FLAGS) $@ +$(WORKDIR)/endless.$1.prg: endless.c | $(WORKDIR) + $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + $(NOT) $(SIM65) $(SIM65FLAGS) $$@ # these need reference data that can't be generated by a host-compiled program, # in a useful way -$(WORKDIR)/limits%prg: limits.c - $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/limits.out - $(DIFF) $(WORKDIR)/limits.out limits.ref +$(WORKDIR)/limits.$1.prg: limits.c $(DIFF) + $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out + $(DIFF) $(WORKDIR)/limits.$1.out limits.ref # the rest are tests that fail currently for one reason or another -$(WORKDIR)/fields%prg: fields.c - @echo "FIXME: " $@ "currently will fail." - $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ - -$(SIM65) $(SIM65FLAGS) $@ -$(WORKDIR)/sitest%prg: sitest.c - @echo "FIXME: " $@ "currently will fail." - -$(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ -# -$(SIM65) $(SIM65FLAGS) $@ -$(WORKDIR)/cc65141011%prg: cc65141011.c - @echo "FIXME: " $@ "currently can fail." - $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@ - -$(SIM65) $(SIM65FLAGS) $@ +$(WORKDIR)/fields.$1.prg: fields.c | $(WORKDIR) + @echo "FIXME: " $$@ "currently will fail." + $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + -$(SIM65) $(SIM65FLAGS) $$@ +$(WORKDIR)/sitest.$1.prg: sitest.c | $(WORKDIR) + @echo "FIXME: " $$@ "currently will fail." + -$(CL65) $(CC65FLAGS) -$1 -o $$@ $$< +# -$(SIM65) $(SIM65FLAGS) $$@ +$(WORKDIR)/cc65141011.$1.prg: cc65141011.c | $(WORKDIR) + @echo "FIXME: " $$@ "currently can fail." + $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + -$(SIM65) $(SIM65FLAGS) $$@ + +endef # PRG_template + +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) clean: - @$(call DEL,$(TESTS)) + @$(call RMDIR,$(WORKDIR)) @$(call DEL,$(SOURCES:.c=.o)) - @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out)) diff --git a/test/ref/Makefile b/test/ref/Makefile index 6f0bd1bc1..7bd10cf14 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -1,102 +1,84 @@ -# makefile for the regression tests that generate output which has to be +# Makefile for the regression tests that generate output which has to be # compared with reference output ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - S := $(subst /,\,/) - DEL = -del /f $(subst /,\,$1) + S = $(subst /,\,/) + EXE = .exe + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) else - S := / + S = / + EXE = + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif -CC65FLAGS := -t sim6502 -SIM65FLAGS := -x 200000000 +CC65FLAGS = -t sim6502 +SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) -WORKDIR := ..$S..$Stestwrk -DIFF := $(WORKDIR)/bdiff +WORKDIR = ..$S..$Stestwrk$Sref -CC := gcc -CFLAGS := -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow +OPTIONS = g O Os Osi Osir Oi Oir Or + +DIFF = $(WORKDIR)$Sbdiff$(EXE) + +CC = gcc +CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow .PHONY: all clean SOURCES := $(wildcard *.c) -REFS := $(SOURCES:%.c=$(WORKDIR)/%.ref) -TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg)) +REFS = $(SOURCES:%.c=$(WORKDIR)/%.ref) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) all: $(REFS) $(TESTS) -# "yaccdbg.c" includes "yacc.c". -# yaccdbg's built files must depend on both of them. +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) -$(WORKDIR)/yaccdbg.ref: yacc.c - -$(WORKDIR)/%.ref: %.c - $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host +$(WORKDIR)/%.ref: %.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(WORKDIR)$S$*.host > $@ +$(DIFF): ../bdiff.c | $(WORKDIR) + $(CC) $(CFLAGS) -o $@ $< + # Some files have "K & R"-style syntax. Therefore, some forward # function-declarations don't match the later function definitions. # Those programs fail when fastcall is used; but, the cdecl calling convention # tolerates those conflicts. Therefore, make their functions default to cdecl. # -$(WORKDIR)/init%prg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl +$(WORKDIR)/init.%.prg \ +$(WORKDIR)/switch.%.prg \ +$(WORKDIR)/yacc.%.prg \ +$(WORKDIR)/yaccdbg.%.prg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/yaccdbg%prg: yacc.c +# "yaccdbg.c" includes "yacc.c". +# yaccdbg's built files must depend on both of them. +# +$(WORKDIR)/yaccdbg.ref: yacc.c +$(WORKDIR)/yaccdbg.%.prg: yacc.c -$(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref - $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref +define PRG_template -$(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref - $(CL65) -O $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref +$(WORKDIR)/%.$1.prg: %.c $(WORKDIR)/%.ref $(DIFF) + $(CL65) $$(CC65FLAGS) -$1 -o $$@ $$< + $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out + $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref -$(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Os $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref +endef # PRG_template -$(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Osi $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref - -$(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Osir $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref - -$(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Oi $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref - -$(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Oir $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref - -$(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref - $(CL65) -Or $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out - $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) clean: - @$(call DEL,$(TESTS)) + @$(call RMDIR,$(WORKDIR)) @$(call DEL,$(SOURCES:.c=.o)) - @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out)) - @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.ref)) - @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.host)) diff --git a/test/val/Makefile b/test/val/Makefile index 4ad8160ef..8a07045ee 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -1,70 +1,59 @@ - -# makefile for the regression tests that return an error code on failure +# Makefile for the regression tests that return an error code on failure ifneq ($(shell echo),) - CMD_EXE := 1 + CMD_EXE = 1 endif ifdef CMD_EXE - DEL = -del /f $(subst /,\,$1) + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) + DEL = del /f $(subst /,\,$1) else + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif -CC65FLAGS := -t sim6502 -SIM65FLAGS := -x 200000000 +CC65FLAGS = -t sim6502 +SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65) -WORKDIR := ../../testwrk +WORKDIR = ../../testwrk/val + +OPTIONS = g O Os Osi Osir Oi Oir Or .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) all: $(TESTS) +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + # Some files have "K & R"-style syntax. Therefore, some forward # function-declarations don't match the later function definitions. # Those programs fail when fastcall is used; but, the cdecl calling convention # tolerates those conflicts. Therefore, make their functions default to cdecl. # -$(WORKDIR)/cq4%prg $(WORKDIR)/cq71.%rg $(WORKDIR)/cq81%prg $(WORKDIR)/cq84%prg: CC65FLAGS += -Wc --all-cdecl +$(WORKDIR)/cq4.%.prg \ +$(WORKDIR)/cq71.%.prg \ +$(WORKDIR)/cq81.%.prg \ +$(WORKDIR)/cq84.%.prg: CC65FLAGS += -Wc --all-cdecl -$(WORKDIR)/%.prg: %.c - $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ +define PRG_template -$(WORKDIR)/%.o.prg: %.c - $(CL65) -O $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ +$(WORKDIR)/%.$1.prg: %.c | $(WORKDIR) + $(CL65) $$(CC65FLAGS) -$1 -o $$@ $$< + $(SIM65) $(SIM65FLAGS) $$@ -$(WORKDIR)/%.os.prg: %.c - $(CL65) -Os $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ +endef # PRG_template -$(WORKDIR)/%.osi.prg: %.c - $(CL65) -Osi $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ - -$(WORKDIR)/%.osir.prg: %.c - $(CL65) -Osir $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ - -$(WORKDIR)/%.oi.prg: %.c - $(CL65) -Oi $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ - -$(WORKDIR)/%.oir.prg: %.c - $(CL65) -Oir $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ - -$(WORKDIR)/%.or.prg: %.c - $(CL65) -Or $(CC65FLAGS) $< -o $@ - $(SIM65) $(SIM65FLAGS) $@ +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) clean: - @$(call DEL,$(TESTS)) + @$(call RMDIR,$(WORKDIR)) @$(call DEL,$(SOURCES:.c=.o)) From ff9b77b6cc96fbdfd06e7f4d6442d4b8c4dd9f86 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Mar 2017 17:57:25 +0100 Subject: [PATCH 272/407] Shortened test subdir names. --- test/Makefile | 8 ++++---- test/{assembler => asm}/4510-cpudetect.ref | Bin test/{assembler => asm}/4510-opcodes.ref | Bin test/{assembler => asm}/4510-opcodes.s | 0 test/{assembler => asm}/6502-cpudetect.ref | Bin test/{assembler => asm}/6502-opcodes.ref | Bin test/{assembler => asm}/6502-opcodes.s | 0 test/{assembler => asm}/6502x-cpudetect.ref | Bin test/{assembler => asm}/6502x-opcodes.ref | Bin test/{assembler => asm}/6502x-opcodes.s | 0 test/{assembler => asm}/65816-cpudetect.ref | Bin test/{assembler => asm}/65c02-cpudetect.ref | Bin test/{assembler => asm}/65c02-opcodes.ref | Bin test/{assembler => asm}/65c02-opcodes.s | 0 test/{assembler => asm}/65sc02-cpudetect.ref | Bin test/{assembler => asm}/65sc02-opcodes.ref | Bin test/{assembler => asm}/65sc02-opcodes.s | 0 test/{assembler => asm}/Makefile | 0 test/{assembler => asm}/README | 0 test/{assembler => asm}/cpudetect.s | 0 test/{assembler => asm}/huc6280-cpudetect.ref | Bin test/{assembler => asm}/huc6280-opcodes.ref | Bin test/{assembler => asm}/huc6280-opcodes.s | 0 test/{assembler => asm}/m740-opcodes.s | 0 test/{disassembler => dasm}/4510-disass.s | 0 test/{disassembler => dasm}/Makefile | 0 26 files changed, 4 insertions(+), 4 deletions(-) rename test/{assembler => asm}/4510-cpudetect.ref (100%) rename test/{assembler => asm}/4510-opcodes.ref (100%) rename test/{assembler => asm}/4510-opcodes.s (100%) rename test/{assembler => asm}/6502-cpudetect.ref (100%) rename test/{assembler => asm}/6502-opcodes.ref (100%) rename test/{assembler => asm}/6502-opcodes.s (100%) rename test/{assembler => asm}/6502x-cpudetect.ref (100%) rename test/{assembler => asm}/6502x-opcodes.ref (100%) rename test/{assembler => asm}/6502x-opcodes.s (100%) rename test/{assembler => asm}/65816-cpudetect.ref (100%) rename test/{assembler => asm}/65c02-cpudetect.ref (100%) rename test/{assembler => asm}/65c02-opcodes.ref (100%) rename test/{assembler => asm}/65c02-opcodes.s (100%) rename test/{assembler => asm}/65sc02-cpudetect.ref (100%) rename test/{assembler => asm}/65sc02-opcodes.ref (100%) rename test/{assembler => asm}/65sc02-opcodes.s (100%) rename test/{assembler => asm}/Makefile (100%) rename test/{assembler => asm}/README (100%) rename test/{assembler => asm}/cpudetect.s (100%) rename test/{assembler => asm}/huc6280-cpudetect.ref (100%) rename test/{assembler => asm}/huc6280-opcodes.ref (100%) rename test/{assembler => asm}/huc6280-opcodes.s (100%) rename test/{assembler => asm}/m740-opcodes.s (100%) rename test/{disassembler => dasm}/4510-disass.s (100%) rename test/{disassembler => dasm}/Makefile (100%) diff --git a/test/Makefile b/test/Makefile index a02bd91fb..d0bee8ed8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -25,16 +25,16 @@ all: dotests dotests: mostlyclean continue continue: - @$(MAKE) -C assembler all - @$(MAKE) -C disassembler all + @$(MAKE) -C asm all + @$(MAKE) -C dasm all @$(MAKE) -C val all @$(MAKE) -C ref all @$(MAKE) -C err all @$(MAKE) -C misc all mostlyclean: - @$(MAKE) -C assembler clean - @$(MAKE) -C disassembler clean + @$(MAKE) -C asm clean + @$(MAKE) -C dasm clean @$(MAKE) -C val clean @$(MAKE) -C ref clean @$(MAKE) -C err clean diff --git a/test/assembler/4510-cpudetect.ref b/test/asm/4510-cpudetect.ref similarity index 100% rename from test/assembler/4510-cpudetect.ref rename to test/asm/4510-cpudetect.ref diff --git a/test/assembler/4510-opcodes.ref b/test/asm/4510-opcodes.ref similarity index 100% rename from test/assembler/4510-opcodes.ref rename to test/asm/4510-opcodes.ref diff --git a/test/assembler/4510-opcodes.s b/test/asm/4510-opcodes.s similarity index 100% rename from test/assembler/4510-opcodes.s rename to test/asm/4510-opcodes.s diff --git a/test/assembler/6502-cpudetect.ref b/test/asm/6502-cpudetect.ref similarity index 100% rename from test/assembler/6502-cpudetect.ref rename to test/asm/6502-cpudetect.ref diff --git a/test/assembler/6502-opcodes.ref b/test/asm/6502-opcodes.ref similarity index 100% rename from test/assembler/6502-opcodes.ref rename to test/asm/6502-opcodes.ref diff --git a/test/assembler/6502-opcodes.s b/test/asm/6502-opcodes.s similarity index 100% rename from test/assembler/6502-opcodes.s rename to test/asm/6502-opcodes.s diff --git a/test/assembler/6502x-cpudetect.ref b/test/asm/6502x-cpudetect.ref similarity index 100% rename from test/assembler/6502x-cpudetect.ref rename to test/asm/6502x-cpudetect.ref diff --git a/test/assembler/6502x-opcodes.ref b/test/asm/6502x-opcodes.ref similarity index 100% rename from test/assembler/6502x-opcodes.ref rename to test/asm/6502x-opcodes.ref diff --git a/test/assembler/6502x-opcodes.s b/test/asm/6502x-opcodes.s similarity index 100% rename from test/assembler/6502x-opcodes.s rename to test/asm/6502x-opcodes.s diff --git a/test/assembler/65816-cpudetect.ref b/test/asm/65816-cpudetect.ref similarity index 100% rename from test/assembler/65816-cpudetect.ref rename to test/asm/65816-cpudetect.ref diff --git a/test/assembler/65c02-cpudetect.ref b/test/asm/65c02-cpudetect.ref similarity index 100% rename from test/assembler/65c02-cpudetect.ref rename to test/asm/65c02-cpudetect.ref diff --git a/test/assembler/65c02-opcodes.ref b/test/asm/65c02-opcodes.ref similarity index 100% rename from test/assembler/65c02-opcodes.ref rename to test/asm/65c02-opcodes.ref diff --git a/test/assembler/65c02-opcodes.s b/test/asm/65c02-opcodes.s similarity index 100% rename from test/assembler/65c02-opcodes.s rename to test/asm/65c02-opcodes.s diff --git a/test/assembler/65sc02-cpudetect.ref b/test/asm/65sc02-cpudetect.ref similarity index 100% rename from test/assembler/65sc02-cpudetect.ref rename to test/asm/65sc02-cpudetect.ref diff --git a/test/assembler/65sc02-opcodes.ref b/test/asm/65sc02-opcodes.ref similarity index 100% rename from test/assembler/65sc02-opcodes.ref rename to test/asm/65sc02-opcodes.ref diff --git a/test/assembler/65sc02-opcodes.s b/test/asm/65sc02-opcodes.s similarity index 100% rename from test/assembler/65sc02-opcodes.s rename to test/asm/65sc02-opcodes.s diff --git a/test/assembler/Makefile b/test/asm/Makefile similarity index 100% rename from test/assembler/Makefile rename to test/asm/Makefile diff --git a/test/assembler/README b/test/asm/README similarity index 100% rename from test/assembler/README rename to test/asm/README diff --git a/test/assembler/cpudetect.s b/test/asm/cpudetect.s similarity index 100% rename from test/assembler/cpudetect.s rename to test/asm/cpudetect.s diff --git a/test/assembler/huc6280-cpudetect.ref b/test/asm/huc6280-cpudetect.ref similarity index 100% rename from test/assembler/huc6280-cpudetect.ref rename to test/asm/huc6280-cpudetect.ref diff --git a/test/assembler/huc6280-opcodes.ref b/test/asm/huc6280-opcodes.ref similarity index 100% rename from test/assembler/huc6280-opcodes.ref rename to test/asm/huc6280-opcodes.ref diff --git a/test/assembler/huc6280-opcodes.s b/test/asm/huc6280-opcodes.s similarity index 100% rename from test/assembler/huc6280-opcodes.s rename to test/asm/huc6280-opcodes.s diff --git a/test/assembler/m740-opcodes.s b/test/asm/m740-opcodes.s similarity index 100% rename from test/assembler/m740-opcodes.s rename to test/asm/m740-opcodes.s diff --git a/test/disassembler/4510-disass.s b/test/dasm/4510-disass.s similarity index 100% rename from test/disassembler/4510-disass.s rename to test/dasm/4510-disass.s diff --git a/test/disassembler/Makefile b/test/dasm/Makefile similarity index 100% rename from test/disassembler/Makefile rename to test/dasm/Makefile From 4a6bca0b560ae2c1a7cfe3b14f75ee38094b9b76 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Mar 2017 20:07:19 +0100 Subject: [PATCH 273/407] Run test for the 65C02 code generator / runtime too. Now that sim65's 65C02 support is actually functional we can run test for the 65C02 support in the compiler and the runtime. We learn the hard way this is a good idea as there are tests failing when built with optimizations for the 65C02: - val/compare7 - val/compare8 - val/compare9 - val/compare10 - val/or1 --- test/misc/Makefile | 27 ++++++++++++++------------- test/ref/Makefile | 11 ++++++----- test/val/Makefile | 18 +++++++++++++----- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/test/misc/Makefile b/test/misc/Makefile index 6512a9fd9..06ee2a84f 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -20,7 +20,6 @@ else DEL = $(RM) $1 endif -CC65FLAGS = -t sim6502 SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) @@ -38,7 +37,8 @@ CFLAGS = -O2 .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) +TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) all: $(TESTS) @@ -51,34 +51,35 @@ $(DIFF): ../bdiff.c | $(WORKDIR) define PRG_template # should compile, but then hangs in an endless loop -$(WORKDIR)/endless.$1.prg: endless.c | $(WORKDIR) - $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< +$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR) + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NOT) $(SIM65) $(SIM65FLAGS) $$@ # these need reference data that can't be generated by a host-compiled program, # in a useful way -$(WORKDIR)/limits.$1.prg: limits.c $(DIFF) - $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< +$(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF) + $(CL65) -t sim$2 -$1 -o $$@ $$< $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out $(DIFF) $(WORKDIR)/limits.$1.out limits.ref # the rest are tests that fail currently for one reason or another -$(WORKDIR)/fields.$1.prg: fields.c | $(WORKDIR) +$(WORKDIR)/fields.$1.$2.prg: fields.c | $(WORKDIR) @echo "FIXME: " $$@ "currently will fail." - $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + $(CL65) -t sim$2 -$1 -o $$@ $$< -$(SIM65) $(SIM65FLAGS) $$@ -$(WORKDIR)/sitest.$1.prg: sitest.c | $(WORKDIR) +$(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR) @echo "FIXME: " $$@ "currently will fail." - -$(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + -$(CL65) -t sim$2 -$1 -o $$@ $$< # -$(SIM65) $(SIM65FLAGS) $$@ -$(WORKDIR)/cc65141011.$1.prg: cc65141011.c | $(WORKDIR) +$(WORKDIR)/cc65141011.$1.$2.prg: cc65141011.c | $(WORKDIR) @echo "FIXME: " $$@ "currently can fail." - $(CL65) $(CC65FLAGS) -$1 -o $$@ $$< + $(CL65) -t sim$2 -$1 -o $$@ $$< -$(SIM65) $(SIM65FLAGS) $$@ endef # PRG_template -$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02))) clean: @$(call RMDIR,$(WORKDIR)) diff --git a/test/ref/Makefile b/test/ref/Makefile index 7bd10cf14..55c859af1 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -19,7 +19,6 @@ else DEL = $(RM) $1 endif -CC65FLAGS = -t sim6502 SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) @@ -38,7 +37,8 @@ CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow SOURCES := $(wildcard *.c) REFS = $(SOURCES:%.c=$(WORKDIR)/%.ref) -TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) +TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) all: $(REFS) $(TESTS) @@ -70,14 +70,15 @@ $(WORKDIR)/yaccdbg.%.prg: yacc.c define PRG_template -$(WORKDIR)/%.$1.prg: %.c $(WORKDIR)/%.ref $(DIFF) - $(CL65) $$(CC65FLAGS) -$1 -o $$@ $$< +$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF) + $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref endef # PRG_template -$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02))) clean: @$(call RMDIR,$(WORKDIR)) diff --git a/test/val/Makefile b/test/val/Makefile index 8a07045ee..425d8ace6 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -14,7 +14,6 @@ else DEL = $(RM) $1 endif -CC65FLAGS = -t sim6502 SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) @@ -27,7 +26,15 @@ OPTIONS = g O Os Osi Osir Oi Oir Or .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg)) +TESTS := $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) +TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) + +# FIXME: These tests fail when built with optimizations for the 65c02 +TESTS := $(filter-out $(WORKDIR)/compare7.O%.65c02.prg,$(TESTS)) +TESTS := $(filter-out $(WORKDIR)/compare8.O%.65c02.prg,$(TESTS)) +TESTS := $(filter-out $(WORKDIR)/compare9.O%.65c02.prg,$(TESTS)) +TESTS := $(filter-out $(WORKDIR)/compare10.O%.65c02.prg,$(TESTS)) +TESTS := $(filter-out $(WORKDIR)/or1.O%.65c02.prg,$(TESTS)) all: $(TESTS) @@ -46,13 +53,14 @@ $(WORKDIR)/cq84.%.prg: CC65FLAGS += -Wc --all-cdecl define PRG_template -$(WORKDIR)/%.$1.prg: %.c | $(WORKDIR) - $(CL65) $$(CC65FLAGS) -$1 -o $$@ $$< +$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR) + $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(SIM65) $(SIM65FLAGS) $$@ endef # PRG_template -$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option)))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502))) +$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02))) clean: @$(call RMDIR,$(WORKDIR)) From 50174d98601856b656ea07e03aaed7b9250752c8 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sun, 19 Mar 2017 20:32:23 +0100 Subject: [PATCH 274/407] Hide stdout of tests returning an exit code. Now that we doubled our tests by running them for both 6502 and 65C02 Travis CI complains (again) about a too long build output. So let's reduce it by omitting the (useless) stdout of tests. --- test/val/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/val/Makefile b/test/val/Makefile index 425d8ace6..2ae3e3b28 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -5,10 +5,14 @@ ifneq ($(shell echo),) endif ifdef CMD_EXE + S = $(subst /,\,/) + NULLDEV = nul: MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) DEL = del /f $(subst /,\,$1) else + S = / + NULLDEV = /dev/null MKDIR = mkdir -p $1 RMDIR = $(RM) -r $1 DEL = $(RM) $1 @@ -17,7 +21,7 @@ endif SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) -SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65) +SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ../../testwrk/val @@ -55,7 +59,7 @@ define PRG_template $(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR) $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< - $(SIM65) $(SIM65FLAGS) $$@ + $(SIM65) $(SIM65FLAGS) $$@ >$(NULLDEV) endef # PRG_template From 1abfa982902ba04b333e42e415ec540689d5d704 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Sun, 19 Mar 2017 20:51:54 +0100 Subject: [PATCH 275/407] minor style changes --- libsrc/runtime/along.s | 1 - libsrc/runtime/lsave.s | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libsrc/runtime/along.s b/libsrc/runtime/along.s index 25eb78c45..bd3462915 100644 --- a/libsrc/runtime/along.s +++ b/libsrc/runtime/along.s @@ -18,4 +18,3 @@ aulong: ldx #0 store: stx sreg stx sreg+1 rts - \ No newline at end of file diff --git a/libsrc/runtime/lsave.s b/libsrc/runtime/lsave.s index 82703073a..d5f4c45b3 100644 --- a/libsrc/runtime/lsave.s +++ b/libsrc/runtime/lsave.s @@ -2,7 +2,7 @@ ; Ullrich von Bassewitz, 08.08.1998 ; Christian Krueger, 11-Mar-2017, optimization ; -; CC65 runtime: save ax into temp storage/restore ax from temp storage +; CC65 runtime: save eax into temp storage/restore eax from temp storage ; .export saveeax, resteax @@ -25,4 +25,3 @@ resteax: ldx regsave+1 lda regsave rts - From 0851e3d6942d8ebd27f13cc41dd631b6b55cf429 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 20 Mar 2017 11:22:04 +0100 Subject: [PATCH 276/407] Allow to control test Makefile output via QUIET (like libsrc). --- .travis.yml | 2 +- test/Makefile | 4 ---- test/asm/Makefile | 6 ++++++ test/dasm/Makefile | 5 +++++ test/err/Makefile | 14 ++++++++++++-- test/misc/Makefile | 30 ++++++++++++++++++++---------- test/ref/Makefile | 15 ++++++++++++--- test/val/Makefile | 13 ++++++++++--- 8 files changed, 66 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10ea789cf..fd2672887 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ install: script: - make bin USER_CFLAGS=-Werror - make lib QUIET=1 - - make -C test + - make -C test QUIET=1 - make -C src clean - make bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32- - make doc zip diff --git a/test/Makefile b/test/Makefile index d0bee8ed8..c85883517 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,9 +1,5 @@ # top-level Makefile for the regression tests -# You can comment this special target when you debug the regression tests. -# Then, make will give you more progress reports. -.SILENT: - ifneq ($(shell echo),) CMD_EXE = 1 endif diff --git a/test/asm/Makefile b/test/asm/Makefile index fb840446c..93210aaee 100644 --- a/test/asm/Makefile +++ b/test/asm/Makefile @@ -16,6 +16,10 @@ else DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: +endif + CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) WORKDIR = ../../testwrk/asm @@ -46,6 +50,7 @@ $(DIFF): ../bdiff.c | $(WORKDIR) define OPCODE_template $(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF) + $(if $(QUIET),echo asm/$1-opcodes.bin) $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$< $(DIFF) $$@ $1-opcodes.ref @@ -56,6 +61,7 @@ $(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu)))) define CPUDETECT_template $(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF) + $(if $(QUIET),echo asm/$1-cpudetect.bin) $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$< $(DIFF) $$@ $1-cpudetect.ref diff --git a/test/dasm/Makefile b/test/dasm/Makefile index f8942ef73..d70711491 100644 --- a/test/dasm/Makefile +++ b/test/dasm/Makefile @@ -16,6 +16,10 @@ else DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: +endif + CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65) @@ -52,6 +56,7 @@ $(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin $(DA65) --cpu $1 $(START) -o $$@ $$< $(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF) + $(if $(QUIET),echo dasm/$1-reass.bin) $(CL65) --cpu $1 -t none $(START) -o $$@ $$< $(DIFF) $$@ $(WORKDIR)/$1-disass.bin diff --git a/test/err/Makefile b/test/err/Makefile index 2bcc1d264..4b05ca5db 100644 --- a/test/err/Makefile +++ b/test/err/Makefile @@ -5,16 +5,25 @@ ifneq ($(shell echo),) endif ifdef CMD_EXE + S = $(subst /,\,/) NOT = - # Hack + NULLDEV = nul: MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) else + S = / NOT = ! + NULLDEV = /dev/null MKDIR = mkdir -p $1 RMDIR = $(RM) -r $1 endif -CC65 := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65) +ifdef QUIET + .SILENT: + NULLERR = 2>$(NULLDEV) +endif + +CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65) WORKDIR = ../../testwrk/err @@ -26,7 +35,8 @@ TESTS = $(patsubst %.c,$(WORKDIR)/%.s,$(SOURCES)) all: $(TESTS) $(WORKDIR)/%.s: %.c - $(NOT) $(CC65) -o $@ $< + $(if $(QUIET),echo err/$*.s) + $(NOT) $(CC65) -o $@ $< $(NULLERR) clean: @$(call RMDIR,$(WORKDIR)) diff --git a/test/misc/Makefile b/test/misc/Makefile index 06ee2a84f..39a9a3868 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -8,6 +8,7 @@ ifdef CMD_EXE S = $(subst /,\,/) NOT = - # Hack EXE = .exe + NULLDEV = nul: MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) DEL = del /f $(subst /,\,$1) @@ -15,14 +16,21 @@ else S = / NOT = ! EXE = + NULLDEV = /dev/null MKDIR = mkdir -p $1 RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: + NULLOUT = >$(NULLDEV) + NULLERR = 2>$(NULLDEV) +endif + SIM65FLAGS = -x 200000000 -CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ..$S..$Stestwrk$Smisc @@ -52,29 +60,31 @@ define PRG_template # should compile, but then hangs in an endless loop $(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR) - $(CL65) -t sim$2 -$1 -o $$@ $$< - $(NOT) $(SIM65) $(SIM65FLAGS) $$@ + $(if $(QUIET),echo misc/endless.$1.$2.prg) + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) + $(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR) # these need reference data that can't be generated by a host-compiled program, # in a useful way $(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF) - $(CL65) -t sim$2 -$1 -o $$@ $$< + $(if $(QUIET),echo misc/limits.$1.$2.prg) + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out $(DIFF) $(WORKDIR)/limits.$1.out limits.ref # the rest are tests that fail currently for one reason or another $(WORKDIR)/fields.$1.$2.prg: fields.c | $(WORKDIR) @echo "FIXME: " $$@ "currently will fail." - $(CL65) -t sim$2 -$1 -o $$@ $$< - -$(SIM65) $(SIM65FLAGS) $$@ + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) + -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR) @echo "FIXME: " $$@ "currently will fail." - -$(CL65) -t sim$2 -$1 -o $$@ $$< -# -$(SIM65) $(SIM65FLAGS) $$@ + -$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) +# -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(WORKDIR)/cc65141011.$1.$2.prg: cc65141011.c | $(WORKDIR) @echo "FIXME: " $$@ "currently can fail." - $(CL65) -t sim$2 -$1 -o $$@ $$< - -$(SIM65) $(SIM65FLAGS) $$@ + $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) + -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) endef # PRG_template diff --git a/test/ref/Makefile b/test/ref/Makefile index 55c859af1..c986513b8 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -8,20 +8,27 @@ endif ifdef CMD_EXE S = $(subst /,\,/) EXE = .exe + NULLDEV = nul: MKDIR = mkdir $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1) DEL = del /f $(subst /,\,$1) else S = / EXE = + NULLDEV = /dev/null MKDIR = mkdir -p $1 RMDIR = $(RM) -r $1 DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: + NULLERR = 2>$(NULLDEV) +endif + SIM65FLAGS = -x 200000000 -CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ..$S..$Stestwrk$Sref @@ -46,7 +53,8 @@ $(WORKDIR): $(call MKDIR,$(WORKDIR)) $(WORKDIR)/%.ref: %.c | $(WORKDIR) - $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< + $(if $(QUIET),echo ref/$*.host) + $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR) $(WORKDIR)$S$*.host > $@ $(DIFF): ../bdiff.c | $(WORKDIR) @@ -71,7 +79,8 @@ $(WORKDIR)/yaccdbg.%.prg: yacc.c define PRG_template $(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF) - $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< + $(if $(QUIET),echo ref/$$*.$1.$2.prg) + $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR) $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref diff --git a/test/val/Makefile b/test/val/Makefile index 2ae3e3b28..1981b36fe 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -18,9 +18,15 @@ else DEL = $(RM) $1 endif +ifdef QUIET + .SILENT: + NULLOUT = >$(NULLDEV) + NULLERR = 2>$(NULLDEV) +endif + SIM65FLAGS = -x 200000000 -CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ../../testwrk/val @@ -58,8 +64,9 @@ $(WORKDIR)/cq84.%.prg: CC65FLAGS += -Wc --all-cdecl define PRG_template $(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR) - $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< - $(SIM65) $(SIM65FLAGS) $$@ >$(NULLDEV) + $(if $(QUIET),echo val/$$*.$1.$2.prg) + $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR) + $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) endef # PRG_template From cc82cd99923caeb3353288789208eb079c73e720 Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Mon, 20 Mar 2017 21:53:07 +0100 Subject: [PATCH 277/407] Fixed addressing error for TSB/TSR and enabled tests again. --- src/sim65/6502.c | 4 ++-- test/val/Makefile | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 0320dd895..b870dd76d 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -470,7 +470,7 @@ static void OPC_65SC02_0C (void) unsigned Addr; unsigned char Val; Cycles = 6; - Addr = MemReadByte (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); @@ -604,7 +604,7 @@ static void OPC_65SC02_1C (void) unsigned Addr; unsigned char Val; Cycles = 6; - Addr = MemReadByte (Regs.PC+1); + Addr = MemReadWord (Regs.PC+1); Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); diff --git a/test/val/Makefile b/test/val/Makefile index 1981b36fe..95522a930 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -39,13 +39,6 @@ SOURCES := $(wildcard *.c) TESTS := $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) -# FIXME: These tests fail when built with optimizations for the 65c02 -TESTS := $(filter-out $(WORKDIR)/compare7.O%.65c02.prg,$(TESTS)) -TESTS := $(filter-out $(WORKDIR)/compare8.O%.65c02.prg,$(TESTS)) -TESTS := $(filter-out $(WORKDIR)/compare9.O%.65c02.prg,$(TESTS)) -TESTS := $(filter-out $(WORKDIR)/compare10.O%.65c02.prg,$(TESTS)) -TESTS := $(filter-out $(WORKDIR)/or1.O%.65c02.prg,$(TESTS)) - all: $(TESTS) $(WORKDIR): From 669113b59521c75434380d974b900550f43b0971 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 21 Mar 2017 20:45:36 +0100 Subject: [PATCH 278/407] Added missing line continuation. Fixes https://github.com/cc65/cc65/issues/408 --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index edb6f5aa8..f4f29b949 100644 --- a/src/Makefile +++ b/src/Makefile @@ -65,7 +65,7 @@ endif CFLAGS += -MMD -MP -O -I common \ -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \ -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) -DCL65_TGT=$(CL65_TGT) \ - -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) + -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) \ -DGIT_SHA=$(GIT_SHA) LDLIBS += -lm From 5b3611265bd97f9263dad6c931a2ae58ed06f42f Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 21 Mar 2017 20:54:55 +0100 Subject: [PATCH 279/407] Revert to recursively expanded var. https://github.com/cc65/cc65/commit/4a6bca0b560ae2c1a7cfe3b14f75ee38094b9b76 needed to move to a simply expanded variable but https://github.com/cc65/cc65/commit/cc82cd99923caeb3353288789208eb079c73e720 made that unnecessary again. --- test/val/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/val/Makefile b/test/val/Makefile index 95522a930..c7539c81b 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -36,7 +36,7 @@ OPTIONS = g O Os Osi Osir Oi Oir Or .PHONY: all clean SOURCES := $(wildcard *.c) -TESTS := $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) +TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg)) TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg)) all: $(TESTS) From 8e35a82c91c002f62befbfd29e637d9b1d8b0b0f Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Tue, 21 Mar 2017 22:35:25 +0100 Subject: [PATCH 280/407] Fix regression of #pragma bss-name Closes #409 --- cfg/sim6502.cfg | 2 +- cfg/sim65c02.cfg | 2 +- src/cc65/compile.c | 28 +++++++++++++++++++--------- src/cc65/symentry.c | 1 + src/cc65/symentry.h | 2 ++ test/err/bss-name-conflict.c | 20 ++++++++++++++++++++ test/val/bss-name-decl.c | 22 ++++++++++++++++++++++ test/val/bss-name.c | 21 +++++++++++++++++++++ 8 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 test/err/bss-name-conflict.c create mode 100644 test/val/bss-name-decl.c create mode 100644 test/val/bss-name.c diff --git a/cfg/sim6502.cfg b/cfg/sim6502.cfg index b4f7738f5..530787489 100644 --- a/cfg/sim6502.cfg +++ b/cfg/sim6502.cfg @@ -3,7 +3,7 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack } MEMORY { - ZP: file = "", start = $0000, size = $001A; + ZP: file = "", start = $0000, size = $001B; HEADER: file = %O, start = $0000, size = $0001; MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; } diff --git a/cfg/sim65c02.cfg b/cfg/sim65c02.cfg index b4f7738f5..530787489 100644 --- a/cfg/sim65c02.cfg +++ b/cfg/sim65c02.cfg @@ -3,7 +3,7 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack } MEMORY { - ZP: file = "", start = $0000, size = $001A; + ZP: file = "", start = $0000, size = $001B; HEADER: file = %O, start = $0000, size = $0001; MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__; } diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 48a5c29d3..4425b6aad 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -242,16 +242,24 @@ static void Parse (void) Error ("Variable `%s' has unknown size", Decl.Ident); } Entry->Flags &= ~(SC_STORAGE | SC_DEF); + } else { + /* A global (including static) uninitialized variable + ** is only a tentative definition. For example, this is valid: + ** int i; + ** int i; + ** static int j; + ** static int j = 42; + ** Code for these will be generated in FinishCompile. + ** For now, just save the BSS segment name + ** (can be set with #pragma bss-name) + */ + const char* bssName = GetSegName (SEG_BSS); + if (Entry->V.BssName && strcmp (Entry->V.BssName, bssName) != 0) { + Error ("Global variable `%s' has already been defined in `%s' segment", + Entry->Name, Entry->V.BssName); + } + Entry->V.BssName = xstrdup (bssName); } - - /* A global (including static) uninitialized variable - ** is only a tentative definition. For example, this is valid: - ** int i; - ** int i; - ** static int j; - ** static int j = 42; - ** Code for these will be generated in FinishCompile. - */ } } @@ -418,6 +426,8 @@ void FinishCompile (void) } else if ((Entry->Flags & (SC_STORAGE | SC_DEF | SC_STATIC)) == (SC_STORAGE | SC_STATIC)) { /* Tentative definition of uninitialized global variable */ g_usebss (); + SetSegName (SEG_BSS, Entry->V.BssName); + g_segname (SEG_BSS); /* TODO: skip if same as before */ g_defgloblabel (Entry->Name); g_res (SizeOf (Entry->Type)); /* Mark as defined, so that it will be exported not imported */ diff --git a/src/cc65/symentry.c b/src/cc65/symentry.c index 980ee27f2..d6e68d1bb 100644 --- a/src/cc65/symentry.c +++ b/src/cc65/symentry.c @@ -71,6 +71,7 @@ SymEntry* NewSymEntry (const char* Name, unsigned Flags) E->Type = 0; E->Attr = 0; E->AsmName = 0; + E->V.BssName = 0; memcpy (E->Name, Name, Len+1); /* Return the new entry */ diff --git a/src/cc65/symentry.h b/src/cc65/symentry.h index 4fa84255b..ff136702f 100644 --- a/src/cc65/symentry.h +++ b/src/cc65/symentry.h @@ -153,6 +153,8 @@ struct SymEntry { struct LiteralPool* LitPool; /* Literal pool for this function */ } F; + /* Segment name for tentantive global definitions */ + const char* BssName; } V; char Name[1]; /* Name, dynamically allocated */ }; diff --git a/test/err/bss-name-conflict.c b/test/err/bss-name-conflict.c new file mode 100644 index 000000000..1d6cd5066 --- /dev/null +++ b/test/err/bss-name-conflict.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! conflicting bss-name pragmas + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/409 +*/ + +char oam_off; +#pragma bss-name (push,"ZEROPAGE") +char oam_off; +#pragma bss-name (pop) + +int main(void) +{ + return 0; +} diff --git a/test/val/bss-name-decl.c b/test/val/bss-name-decl.c new file mode 100644 index 000000000..9a535844e --- /dev/null +++ b/test/val/bss-name-decl.c @@ -0,0 +1,22 @@ +/* + !!DESCRIPTION!! bss-name pragma not affecting declarations + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/409 +*/ + +#pragma bss-name (push,"ZEROPAGE") + +char n; /* only a declaration because followed by definition */ +char n = 1; /* not BSS */ + +#pragma bss-name (pop) + +int main(void) +{ + return (unsigned) &n >= 0x100 ? 0 : 1; +} diff --git a/test/val/bss-name.c b/test/val/bss-name.c new file mode 100644 index 000000000..f0ad7111e --- /dev/null +++ b/test/val/bss-name.c @@ -0,0 +1,21 @@ +/* + !!DESCRIPTION!! bss-name pragma + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Piotr Fusik +*/ + +/* + see: https://github.com/cc65/cc65/issues/409 +*/ + +#pragma bss-name (push,"ZEROPAGE") + +char zp_var; + +#pragma bss-name (pop) + +int main(void) +{ + return (unsigned) &zp_var < 0x100 ? 0 : 1; +} From 01f5baf03defacf5b4bed9536883559b7aeca8b6 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 21 Mar 2017 21:23:48 -0400 Subject: [PATCH 281/407] Fixed SGML typo. --- doc/cc65.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 6a08cc3c3..2a0fa0260 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -4,7 +4,7 @@ <title>cc65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:gregdk@users.sf.net" name="Greg King"> -<date>2017-02-27 +<date>2017-03-21 <abstract> cc65 is a C compiler for 6502 targets. It supports several 6502 based home @@ -1276,7 +1276,7 @@ that function). As a shortcut, you can put the <tt/volatile/ qualifier in your <tt/asm/ statements. It will disable optimization for the functions in which those <tt/asm volatile/ statements sit. The effect is the same as though you put -</#pragma optimize(push, off)/ above those functions, and </#pragma +<tt/#pragma optimize(push, off)/ above those functions, and <tt/#pragma optimize(pop)/ below those functions. The string literal may contain format specifiers from the following list. For From 170d96898f3d744f131aa9c3a3cff8cf0463078c Mon Sep 17 00:00:00 2001 From: IrgendwerA8 <c.krueger.b@web.de> Date: Thu, 30 Mar 2017 12:17:29 +0200 Subject: [PATCH 282/407] Fixed SED --- src/sim65/6502.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 0320dd895..87cef2db6 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -39,6 +39,8 @@ 6502) * one cycle win for fetch-modify-write instructions ignored (e.g. ROL abs,x takes only 6 cycles if no page break occurs) + * BRK, IRQ, NMI and RESET are not different from 6502 which they are in + reality (e.g. D-flag handling) */ #include "memory.h" @@ -2581,7 +2583,9 @@ static void OPC_6502_F6 (void) static void OPC_6502_F8 (void) /* Opcode $F8: SED */ { + Cycles = 2; SET_DF (1); + Regs.PC += 1; } From 02daf9f8b5c1ae2267561ee05ce67b2d0393c12d Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 3 Apr 2017 23:20:26 +0200 Subject: [PATCH 283/407] So far the built-in inlining of several known standard function was always (!) enabled and the option -Os enabled additional, potentially unsafe inlining of some of those functions. There were two aspects of this behavior that were considered undesirable: - Although the safe inlining is in general desirable it should only be enabled if asked for it - like any other optimization. - The option name -Os implies that it is a safe option, the potentially unsafe inlining should have a more explicit name. So now: - The option -Os enables the safe inlining. - The new option --eagerly-inline-funcs enables the potentially unsafe inlining (including the safe inlining). Additionally was added: - The option --inline-stdfuncs that does like -Os enable the safe inlining but doesn't enable optimizations. - The pragma inline-stdfuncs that works identical to --inline-stdfuncs. - The pragma allow-eager-inline that enables the potentially unsafe inlining but doesn't include the safe inlining. That means that by itself it only marks code as safe for potentially unsafe inlining but doesn't actually enable any inlining. --- doc/cc65.sgml | 294 +++++---- doc/cl65.sgml | 4 +- include/ctype.h | 4 +- src/cc65/compile.c | 19 +- src/cc65/global.c | 3 +- src/cc65/global.h | 3 +- src/cc65/main.c | 91 +-- src/cc65/pragma.c | 62 +- src/cc65/stdfunc.c | 1421 +++++++++++++++++++++++--------------------- 9 files changed, 1033 insertions(+), 868 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 2a0fa0260..9322a2d44 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -58,7 +58,7 @@ Short options: -O Optimize code -Oi Optimize code, inline more code -Or Enable register variables - -Os Inline some known functions + -Os Inline some standard functions -T Include source as comment -V Print the compiler version number -W warning[,...] Suppress warnings @@ -88,9 +88,11 @@ Long options: --debug-opt name Debug optimization steps --dep-target target Use this dependency target --disable-opt name Disable an optimization step + --eagerly-inline-funcs Eagerly inline some known functions --enable-opt name Enable an optimization step --help Help (this text) --include-dir dir Set an include directory search path + --inline-stdfuncs Inline some standard functions --list-opt-steps List all optimizer steps and exit --list-warnings List available warning types for -W --local-strings Emit string literals immediately @@ -219,11 +221,53 @@ Here is a description of all the command line options: symbols in a special section in the object file. + <label id="option-eagerly-inline-funcs"> + <tag><tt>--eagerly-inline-funcs</tt></tag> + + Have the compiler eagerly inline these functions from the C library: + <itemize> + <item><tt/memcpy()/ + <item><tt/memset()/ + <item><tt/strcmp()/ + <item><tt/strcpy()/ + <item><tt/strlen()/ + <item>most of the functions declared in <tt/<ctype.h>/ + </itemize> + + Note: This has two consequences: + <itemize> + <item>You may not use names of standard C functions for your own functions. + If you do that, your program is not standard-compliant anyway; but, + using <tt/--eagerly-inline-funcs/ actually will break things. + <p> + <item>The inlined string and memory functions will not handle strings or + memory areas larger than 255 bytes. Similarly, the inlined <tt/is..()/ + functions will not work with values outside the char. range (such as + <tt/EOF/). + <p> + </itemize> + + <tt/--eagerly-inline-funcs/ implies the <tt/<ref id="option-inline-stdfuncs" + name="--inline-stdfuncs"/ command line option. + + See also <tt/<ref id="pragma-allow-eager-inline" name="#pragma allow-eager-inline">/. + + <tag><tt>-h, --help</tt></tag> Print the short option summary shown above. + <label id="option-inline-stdfuncs"> + <tag><tt>--inline-stdfuncs</tt></tag> + + Allow the compiler to inline some standard functions from the C library like + strlen. This will not only remove the overhead for a function call, but will + make the code visible for the optimizer. See also the <tt/<ref id="option-O" + name="-Os"/ command line option and <tt/<ref id="pragma-inline-stdfuncs" + name="#pragma inline-stdfuncs">/. + + <label id="option-list-warnings"> <tag><tt>--list-warnings</tt></tag> @@ -392,22 +436,22 @@ Here is a description of all the command line options: using <tscreen><verb> - void f (void) - { - unsigned a = 1; - ... - } + void f (void) + { + unsigned a = 1; + ... + } </verb></tscreen> the variable <tt/a/ will always have the value <tt/1/ when entering the function and using <tt/-Cl/, while in <tscreen><verb> - void f (void) - { - static unsigned a = 1; - .... - } + void f (void) + { + static unsigned a = 1; + .... + } </verb></tscreen> the variable <tt/a/ will have the value <tt/1/ only the first time that the @@ -444,23 +488,13 @@ Here is a description of all the command line options: name="--register-vars">/ command line option, and the <ref id="register-vars" name="discussion of register variables"> below. - Using <tt/-Os/ will force the compiler to inline some known functions from - the C library like strlen. Note: This has two consequences: - <p> - <itemize> - <item>You may not use names of standard C functions in your own code. If you - do that, your program is not standard compliant anyway, but using - <tt/-Os/ will actually break things. - <p> - <item>The inlined string and memory functions will not handle strings or - memory areas larger than 255 bytes. Similarly, the inlined <tt/is..()/ - functions will not work with values outside the char. range (such as - <tt/EOF/). - <p> - </itemize> - <p> + Using <tt/-Os/ will allow the compiler to inline some standard functions + from the C library like strlen. This will not only remove the overhead + for a function call, but will make the code visible for the optimizer. + See also <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs"/. + It is possible to concatenate the modifiers for <tt/-O/. For example, to - enable register variables and inlining of known functions, you may use + enable register variables and inlining of standard functions, you may use <tt/-Ors/. @@ -518,6 +552,7 @@ Here is a description of all the command line options: </descrip><p> + <sect>Input and output<p> The compiler will accept one C file per invocation and create a file with @@ -556,21 +591,21 @@ and the one defined by the ISO standard: <itemize> -<item> The datatypes "float" and "double" are not available. - <p> -<item> C Functions may not return structs (or unions), and structs may not +<item> The datatypes "float" and "double" are not available. + <p> +<item> C Functions may not return structs (or unions), and structs may not be passed as parameters by value. However, struct assignment *is* - possible. - <p> -<item> Most of the C library is available with only the fastcall calling - convention (<ref id="extension-fastcall" name="see below">). It means - that you must not mix pointers to those functions with pointers to - user-written, cdecl functions (the calling conventions are incompatible). - <p> -<item> The <tt/volatile/ keyword has almost no effect. That is not as bad + possible. + <p> +<item> Most of the C library is available with only the fastcall calling + convention (<ref id="extension-fastcall" name="see below">). It means + that you must not mix pointers to those functions with pointers to + user-written, cdecl functions (the calling conventions are incompatible). + <p> +<item> The <tt/volatile/ keyword has almost no effect. That is not as bad as it sounds, since the 6502 has so few registers that it isn't possible to keep values in registers anyway. - <p> + <p> </itemize> There may be some more minor differences I'm currently not aware of. The @@ -585,49 +620,48 @@ This cc65 version has some extensions to the ISO C standard. <itemize> -<item> The compiler allows to insert assembler statements into the output - file. The syntax is +<item> The compiler allows to insert assembler statements into the output + file. The syntax is - <tscreen><verb> - asm [optional volatile] (<string literal>[, optional parameters]) ; - </verb></tscreen> - or - <tscreen><verb> + <tscreen><verb> + asm [optional volatile] (<string literal>[, optional parameters]) ; + </verb></tscreen> + or + <tscreen><verb> __asm__ [optional volatile] (<string literal>[, optional parameters]) ; - </verb></tscreen> + </verb></tscreen> - The first form is in the user namespace; and, is disabled if the <tt/-A/ - switch is given. + The first form is in the user namespace; and, is disabled if the <tt/-A/ + switch is given. - There is a whole section covering inline assembler statements, - <ref id="inline-asm" name="see there">. - <p> + There is a whole section covering inline assembler statements, + <ref id="inline-asm" name="see there">. + <p> <label id="extension-fastcall"> -<item> The normal calling convention -- for non-variadic functions -- is - named "fastcall". The syntax for a function declaration that - <em/explicitly/ uses fastcall is +<item> The normal calling convention -- for non-variadic functions -- is + named "fastcall". The syntax for a function declaration that + <em/explicitly/ uses fastcall is - <tscreen><verb> - <return type> fastcall <function name> (<parameter list>) - </verb></tscreen> - or - <tscreen><verb> - <return type> __fastcall__ <function name> (<parameter list>) - </verb></tscreen> - An example is - <tscreen><verb> - void __fastcall__ f (unsigned char c) - </verb></tscreen> - The first form of the fastcall keyword is in the user namespace and can - therefore be disabled with the <tt><ref id="option--standard" + <tscreen><verb> + <return type> fastcall <function name> (<parameter list>) + </verb></tscreen> + or + <tscreen><verb> + <return type> __fastcall__ <function name> (<parameter list>) + </verb></tscreen> + An example is + <tscreen><verb> + void __fastcall__ f (unsigned char c) + </verb></tscreen> + The first form of the fastcall keyword is in the user namespace and can + therefore be disabled with the <tt><ref id="option--standard" name="--standard"></tt> command line option. - For functions that are <tt/fastcall/, the rightmost parameter is not - pushed on the stack but left in the primary register when the function - is called. That significantly reduces the cost of calling those functions. - <newline><newline> - <p> + For functions that are <tt/fastcall/, the rightmost parameter is not + pushed on the stack but left in the primary register when the function + is called. That significantly reduces the cost of calling those functions. + <p> <item> There is another calling convention named "cdecl". Variadic functions (their prototypes have an ellipsis [<tt/.../]) always use that @@ -652,40 +686,40 @@ This cc65 version has some extensions to the ISO C standard. For functions that are <tt/cdecl/, the rightmost parameter is pushed onto the stack before the function is called. That increases the cost of calling those functions, especially when they are called from many - places.<newline><newline> + places. <p> -<item> There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/. - Both refer to the primary register that is used by the compiler to - evaluate expressions or return function results. <tt/__AX__/ is of - type <tt/unsigned int/ and <tt/__EAX__/ of type <tt/long unsigned int/ - respectively. The pseudo variables may be used as lvalue and rvalue as - every other variable. They are most useful together with short - sequences of assembler code. For example, the macro +<item> There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/. + Both refer to the primary register that is used by the compiler to + evaluate expressions or return function results. <tt/__AX__/ is of + type <tt/unsigned int/ and <tt/__EAX__/ of type <tt/long unsigned int/ + respectively. The pseudo variables may be used as lvalue and rvalue as + every other variable. They are most useful together with short + sequences of assembler code. For example, the macro - <tscreen><verb> - #define hi(x) \ + <tscreen><verb> + #define hi(x) \ (__AX__ = (x), \ asm ("txa"), \ asm ("ldx #$00"), \ __AX__) - </verb></tscreen> + </verb></tscreen> - will give the high byte of any unsigned value. - <p> + will give the high byte of any unsigned value. + <p> -<item> Inside a function, the identifier <tt/__func__/ gives the name of the - current function as a string. Outside of functions, <tt/__func__/ is - undefined. - Example: +<item> Inside a function, the identifier <tt/__func__/ gives the name of the + current function as a string. Outside of functions, <tt/__func__/ is + undefined. + Example: - <tscreen><verb> - #define PRINT_DEBUG(s) printf ("%s: %s\n", __func__, s); - </verb></tscreen> + <tscreen><verb> + #define PRINT_DEBUG(s) printf ("%s: %s\n", __func__, s); + </verb></tscreen> - The macro will print the name of the current function plus a given - string. - <p> + The macro will print the name of the current function plus a given + string. + <p> <item> cc65 allows the initialization of <tt/void/ variables. This may be used to create arbitrary structures that are more compatible with @@ -825,6 +859,11 @@ The compiler defines several macros at startup: This macro expands to the date of translation of the preprocessing translation unit in the form "Mmm dd yyyy". + <tag><tt>__EAGERLY_INLINE_FUNCS__</tt></tag> + + Is defined if the compiler was called with the <tt/<ref id="option-eagerly-inline-funcs" + name="--eagerly-inline-funcs"/ command line option. + <tag><tt>__FILE__</tt></tag> This macro expands to a string containing the name of the C source file. @@ -912,6 +951,7 @@ The compiler defines several macros at startup: </descrip> + <sect>#pragmas<label id="pragmas"><p> The compiler understands some pragmas that may be used to change code @@ -920,6 +960,19 @@ If the first parameter is <tt/push/, the old value is saved onto a stack before changing it. The value may later be restored by using the <tt/pop/ parameter with the <tt/#pragma/. + +<sect1><tt>#pragma allow-eager-inline ([push,] on|off)</tt><label id="pragma-allow-eager-inline"><p> + + Allow eager inlining of known functions. If the argument is "off", eager + inlining is disabled, otherwise it is enabled. Please note that (in contrast + to the <tt/<ref id="option-eagerly-inline-funcs" name="--eagerly-inline-funcs"/ + command line option) this pragma does not imply the <tt/<ref id="option-inline-stdfuncs" + name="--inline-stdfuncs"/ command line option. Rather it marks code to be safe for + eager inlining of known functions if inlining of standard functions is enabled. + + The <tt/#pragma/ understands the push and pop parameters as explained above. + + <sect1><tt>#pragma bss-name ([push,] <name>)</tt><label id="pragma-bss-name"><p> This pragma changes the name used for the BSS segment (the BSS segment @@ -938,7 +991,7 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma bss-name ("MyBSS") + #pragma bss-name ("MyBSS") </verb></tscreen> @@ -993,6 +1046,7 @@ parameter with the <tt/#pragma/. The <tt/#pragma/ understands the push and pop parameters as explained above. + <sect1><tt>#pragma code-name ([push,] <name>)</tt><label id="pragma-code-name"><p> This pragma changes the name used for the CODE segment (the CODE segment @@ -1007,7 +1061,7 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma code-name ("MyCODE") + #pragma code-name ("MyCODE") </verb></tscreen> @@ -1035,10 +1089,21 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma data-name ("MyDATA") + #pragma data-name ("MyDATA") </verb></tscreen> +<sect1><tt>#pragma inline-stdfuncs ([push,] on|off)</tt><label id="pragma-inline-stdfuncs"><p> + + Allow the compiler to inline some standard functions from the C library like + strlen. If the argument is "off", inlining is disabled, otherwise it is enabled. + + See also the the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs"/ + command line option. + + The <tt/#pragma/ understands the push and pop parameters as explained above. + + <sect1><tt>#pragma local-strings ([push,] on|off)</tt><label id="pragma-local-strings"><p> When "on", emit string literals to the data segment when they're encountered @@ -1083,7 +1148,7 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma rodata-name ("MyRODATA") + #pragma rodata-name ("MyRODATA") </verb></tscreen> @@ -1105,9 +1170,9 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - #pragma regvaraddr(on) /* Allow taking the address - * of register variables - */ + #pragma regvaraddr(on) /* Allow taking the address + * of register variables + */ </verb></tscreen> @@ -1154,7 +1219,7 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> /* Don't warn about the unused parameter in function func */ - #pragma warn (unused-param, push, off) + #pragma warn (unused-param, push, off) static int func (int unused) { return 0; @@ -1187,13 +1252,12 @@ parameter with the <tt/#pragma/. Example: <tscreen><verb> - extern int foo; - #pragma zpsym ("foo"); /* foo is in the zeropage */ + extern int foo; + #pragma zpsym ("foo"); /* foo is in the zeropage */ </verb></tscreen> - <sect>Register variables<label id="register-vars"><p> The runtime for all supported platforms has 6 bytes of zero page space @@ -1450,14 +1514,14 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: <enum> -<item> The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. -<item> Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. -<item> This notice may not be removed or altered from any source - distribution. +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. </enum> </article> diff --git a/doc/cl65.sgml b/doc/cl65.sgml index eef6a12a3..ffeba2321 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -54,9 +54,9 @@ Short options: -L path Specify a library search path -Ln name Create a VICE label file -O Optimize code - -Oi Optimize code, inline functions + -Oi Optimize code, inline more code -Or Optimize code, honour the register keyword - -Os Optimize code, inline known C funtions + -Os Optimize code, inline standard funtions -S Compile but don't assemble and link -T Include source as comment -V Print the version number diff --git a/include/ctype.h b/include/ctype.h index b440bfb70..17cbafe9f 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -89,9 +89,9 @@ unsigned char __fastcall__ toascii (unsigned char c); ** #undef'ing the macroes. ** Please note that the following macroes do NOT handle EOF correctly, as ** stated in the manual. If you need correct behaviour for EOF, don't -** use -Os, or #undefine the following macroes. +** use --eagerly-inline-funcs, or #undefine the following macroes. */ -#ifdef __OPT_s__ +#ifdef __EAGERLY_INLINE_FUNCS__ #define isalnum(c) (__AX__ = (c), \ __asm__ ("tay"), \ diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 4425b6aad..3c1042154 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -335,17 +335,22 @@ void Compile (const char* FileName) ** changes using #pragma later. */ if (IS_Get (&Optimize)) { - long CodeSize = IS_Get (&CodeSizeFactor); DefineNumericMacro ("__OPT__", 1); + } + { + long CodeSize = IS_Get (&CodeSizeFactor); if (CodeSize > 100) { DefineNumericMacro ("__OPT_i__", CodeSize); } - if (IS_Get (&EnableRegVars)) { - DefineNumericMacro ("__OPT_r__", 1); - } - if (IS_Get (&InlineStdFuncs)) { - DefineNumericMacro ("__OPT_s__", 1); - } + } + if (IS_Get (&EnableRegVars)) { + DefineNumericMacro ("__OPT_r__", 1); + } + if (IS_Get (&InlineStdFuncs)) { + DefineNumericMacro ("__OPT_s__", 1); + } + if (IS_Get (&EagerlyInlineFuncs)) { + DefineNumericMacro ("__EAGERLY_INLINE_FUNCS__", 1); } /* __TIME__ and __DATE__ macros */ diff --git a/src/cc65/global.c b/src/cc65/global.c index dbdd72f3c..a337549fe 100644 --- a/src/cc65/global.c +++ b/src/cc65/global.c @@ -53,7 +53,8 @@ unsigned RegisterSpace = 6; /* Space available for register vars */ /* Stackable options */ IntStack WritableStrings = INTSTACK(0); /* Literal strings are r/w */ IntStack LocalStrings = INTSTACK(0); /* Emit string literals immediately */ -IntStack InlineStdFuncs = INTSTACK(0); /* Inline some known functions */ +IntStack InlineStdFuncs = INTSTACK(0); /* Inline some standard functions */ +IntStack EagerlyInlineFuncs = INTSTACK(0); /* Eagerly inline some known functions */ IntStack EnableRegVars = INTSTACK(0); /* Enable register variables */ IntStack AllowRegVarAddr = INTSTACK(0); /* Allow taking addresses of register vars */ IntStack RegVarsToCallStack = INTSTACK(0); /* Save reg variables on call stack */ diff --git a/src/cc65/global.h b/src/cc65/global.h index 8b0af5a83..4ffc84a39 100644 --- a/src/cc65/global.h +++ b/src/cc65/global.h @@ -61,7 +61,8 @@ extern unsigned RegisterSpace; /* Space available for register /* Stackable options */ extern IntStack WritableStrings; /* Literal strings are r/w */ extern IntStack LocalStrings; /* Emit string literals immediately */ -extern IntStack InlineStdFuncs; /* Inline some known functions */ +extern IntStack InlineStdFuncs; /* Inline some standard functions */ +extern IntStack EagerlyInlineFuncs; /* Eagerly inline some known functions */ extern IntStack EnableRegVars; /* Enable register variables */ extern IntStack AllowRegVarAddr; /* Allow taking addresses of register vars */ extern IntStack RegVarsToCallStack; /* Save reg variables on call stack */ diff --git a/src/cc65/main.c b/src/cc65/main.c index 9ed19b90c..d3d298876 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -88,7 +88,7 @@ static void Usage (void) " -O\t\t\t\tOptimize code\n" " -Oi\t\t\t\tOptimize code, inline more code\n" " -Or\t\t\t\tEnable register variables\n" - " -Os\t\t\t\tInline some known functions\n" + " -Os\t\t\t\tInline some standard functions\n" " -T\t\t\t\tInclude source as comment\n" " -V\t\t\t\tPrint the compiler version number\n" " -W warning[,...]\t\tSuppress warnings\n" @@ -118,9 +118,11 @@ static void Usage (void) " --debug-opt name\t\tDebug optimization steps\n" " --dep-target target\t\tUse this dependency target\n" " --disable-opt name\t\tDisable an optimization step\n" + " --eagerly-inline-funcs\t\tEagerly inline some known functions\n" " --enable-opt name\t\tEnable an optimization step\n" " --help\t\t\tHelp (this text)\n" " --include-dir dir\t\tSet an include directory search path\n" + " --inline-stdfuncs\t\tInline some standard functions\n" " --list-opt-steps\t\tList all optimizer steps and exit\n" " --list-warnings\t\tList available warning types for -W\n" " --local-strings\t\tEmit string literals immediately\n" @@ -581,6 +583,16 @@ static void OptDisableOpt (const char* Opt attribute ((unused)), const char* Arg +static void OptEagerlyInlineFuncs (const char* Opt attribute((unused)), + const char* Arg attribute((unused))) +/* Eagerly inline some known functions */ +{ + IS_Set (&InlineStdFuncs, 1); + IS_Set (&EagerlyInlineFuncs, 1); +} + + + static void OptEnableOpt (const char* Opt attribute ((unused)), const char* Arg) /* Enable an optimization step */ { @@ -608,6 +620,15 @@ static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg +static void OptInlineStdFuncs (const char* Opt attribute((unused)), + const char* Arg attribute((unused))) +/* Inline some standard functions */ +{ + IS_Set (&InlineStdFuncs, 1); +} + + + static void OptListOptSteps (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* List all optimizer steps */ @@ -819,39 +840,41 @@ int main (int argc, char* argv[]) { /* Program long options */ static const LongOpt OptTab[] = { - { "--add-source", 0, OptAddSource }, - { "--all-cdecl", 0, OptAllCDecl }, - { "--bss-name", 1, OptBssName }, - { "--check-stack", 0, OptCheckStack }, - { "--code-name", 1, OptCodeName }, - { "--codesize", 1, OptCodeSize }, - { "--cpu", 1, OptCPU }, - { "--create-dep", 1, OptCreateDep }, - { "--create-full-dep", 1, OptCreateFullDep }, - { "--data-name", 1, OptDataName }, - { "--debug", 0, OptDebug }, - { "--debug-info", 0, OptDebugInfo }, - { "--debug-opt", 1, OptDebugOpt }, - { "--debug-opt-output", 0, OptDebugOptOutput }, - { "--dep-target", 1, OptDepTarget }, - { "--disable-opt", 1, OptDisableOpt }, - { "--enable-opt", 1, OptEnableOpt }, - { "--help", 0, OptHelp }, - { "--include-dir", 1, OptIncludeDir }, - { "--list-opt-steps", 0, OptListOptSteps }, - { "--list-warnings", 0, OptListWarnings }, - { "--local-strings", 0, OptLocalStrings }, - { "--memory-model", 1, OptMemoryModel }, - { "--register-space", 1, OptRegisterSpace }, - { "--register-vars", 0, OptRegisterVars }, - { "--rodata-name", 1, OptRodataName }, - { "--signed-chars", 0, OptSignedChars }, - { "--standard", 1, OptStandard }, - { "--static-locals", 0, OptStaticLocals }, - { "--target", 1, OptTarget }, - { "--verbose", 0, OptVerbose }, - { "--version", 0, OptVersion }, - { "--writable-strings", 0, OptWritableStrings }, + { "--add-source", 0, OptAddSource }, + { "--all-cdecl", 0, OptAllCDecl }, + { "--bss-name", 1, OptBssName }, + { "--check-stack", 0, OptCheckStack }, + { "--code-name", 1, OptCodeName }, + { "--codesize", 1, OptCodeSize }, + { "--cpu", 1, OptCPU }, + { "--create-dep", 1, OptCreateDep }, + { "--create-full-dep", 1, OptCreateFullDep }, + { "--data-name", 1, OptDataName }, + { "--debug", 0, OptDebug }, + { "--debug-info", 0, OptDebugInfo }, + { "--debug-opt", 1, OptDebugOpt }, + { "--debug-opt-output", 0, OptDebugOptOutput }, + { "--dep-target", 1, OptDepTarget }, + { "--disable-opt", 1, OptDisableOpt }, + { "--eagerly-inline-funcs", 0, OptEagerlyInlineFuncs }, + { "--enable-opt", 1, OptEnableOpt }, + { "--help", 0, OptHelp }, + { "--include-dir", 1, OptIncludeDir }, + { "--inline-stdfuncs", 0, OptInlineStdFuncs }, + { "--list-opt-steps", 0, OptListOptSteps }, + { "--list-warnings", 0, OptListWarnings }, + { "--local-strings", 0, OptLocalStrings }, + { "--memory-model", 1, OptMemoryModel }, + { "--register-space", 1, OptRegisterSpace }, + { "--register-vars", 0, OptRegisterVars }, + { "--rodata-name", 1, OptRodataName }, + { "--signed-chars", 0, OptSignedChars }, + { "--standard", 1, OptStandard }, + { "--static-locals", 0, OptStaticLocals }, + { "--target", 1, OptTarget }, + { "--verbose", 0, OptVerbose }, + { "--version", 0, OptVersion }, + { "--writable-strings", 0, OptWritableStrings }, }; unsigned I; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 86739ce22..707546e1d 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -64,6 +64,7 @@ typedef enum { PRAGMA_ILLEGAL = -1, PRAGMA_ALIGN, + PRAGMA_ALLOW_EAGER_INLINE, PRAGMA_BSS_NAME, PRAGMA_BSSSEG, /* obsolete */ PRAGMA_CHARMAP, @@ -74,6 +75,7 @@ typedef enum { PRAGMA_CODESIZE, PRAGMA_DATA_NAME, PRAGMA_DATASEG, /* obsolete */ + PRAGMA_INLINE_STDFUNCS, PRAGMA_LOCAL_STRINGS, PRAGMA_OPTIMIZE, PRAGMA_REGVARADDR, @@ -96,31 +98,33 @@ static const struct Pragma { const char* Key; /* Keyword */ pragma_t Tok; /* Token */ } Pragmas[PRAGMA_COUNT] = { - { "align", PRAGMA_ALIGN }, - { "bss-name", PRAGMA_BSS_NAME }, - { "bssseg", PRAGMA_BSSSEG }, /* obsolete */ - { "charmap", PRAGMA_CHARMAP }, - { "check-stack", PRAGMA_CHECK_STACK }, - { "checkstack", PRAGMA_CHECKSTACK }, /* obsolete */ - { "code-name", PRAGMA_CODE_NAME }, - { "codeseg", PRAGMA_CODESEG }, /* obsolete */ - { "codesize", PRAGMA_CODESIZE }, - { "data-name", PRAGMA_DATA_NAME }, - { "dataseg", PRAGMA_DATASEG }, /* obsolete */ - { "local-strings", PRAGMA_LOCAL_STRINGS }, - { "optimize", PRAGMA_OPTIMIZE }, - { "register-vars", PRAGMA_REGISTER_VARS }, - { "regvaraddr", PRAGMA_REGVARADDR }, - { "regvars", PRAGMA_REGVARS }, /* obsolete */ - { "rodata-name", PRAGMA_RODATA_NAME }, - { "rodataseg", PRAGMA_RODATASEG }, /* obsolete */ - { "signed-chars", PRAGMA_SIGNED_CHARS }, - { "signedchars", PRAGMA_SIGNEDCHARS }, /* obsolete */ - { "static-locals", PRAGMA_STATIC_LOCALS }, - { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ - { "warn", PRAGMA_WARN }, - { "writable-strings", PRAGMA_WRITABLE_STRINGS }, - { "zpsym", PRAGMA_ZPSYM }, + { "align", PRAGMA_ALIGN }, + { "allow-eager-inline", PRAGMA_ALLOW_EAGER_INLINE }, + { "bss-name", PRAGMA_BSS_NAME }, + { "bssseg", PRAGMA_BSSSEG }, /* obsolete */ + { "charmap", PRAGMA_CHARMAP }, + { "check-stack", PRAGMA_CHECK_STACK }, + { "checkstack", PRAGMA_CHECKSTACK }, /* obsolete */ + { "code-name", PRAGMA_CODE_NAME }, + { "codeseg", PRAGMA_CODESEG }, /* obsolete */ + { "codesize", PRAGMA_CODESIZE }, + { "data-name", PRAGMA_DATA_NAME }, + { "dataseg", PRAGMA_DATASEG }, /* obsolete */ + { "inline-stdfuncs", PRAGMA_INLINE_STDFUNCS }, + { "local-strings", PRAGMA_LOCAL_STRINGS }, + { "optimize", PRAGMA_OPTIMIZE }, + { "register-vars", PRAGMA_REGISTER_VARS }, + { "regvaraddr", PRAGMA_REGVARADDR }, + { "regvars", PRAGMA_REGVARS }, /* obsolete */ + { "rodata-name", PRAGMA_RODATA_NAME }, + { "rodataseg", PRAGMA_RODATASEG }, /* obsolete */ + { "signed-chars", PRAGMA_SIGNED_CHARS }, + { "signedchars", PRAGMA_SIGNEDCHARS }, /* obsolete */ + { "static-locals", PRAGMA_STATIC_LOCALS }, + { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ + { "warn", PRAGMA_WARN }, + { "writable-strings", PRAGMA_WRITABLE_STRINGS }, + { "zpsym", PRAGMA_ZPSYM }, }; /* Result of ParsePushPop */ @@ -703,6 +707,10 @@ static void ParsePragma (void) IntPragma (&B, &DataAlignment, 1, 4096); break; + case PRAGMA_ALLOW_EAGER_INLINE: + FlagPragma (&B, &EagerlyInlineFuncs); + break; + case PRAGMA_BSSSEG: Warning ("#pragma bssseg is obsolete, please use #pragma bss-name instead"); /* FALLTHROUGH */ @@ -739,6 +747,10 @@ static void ParsePragma (void) SegNamePragma (&B, SEG_DATA); break; + case PRAGMA_INLINE_STDFUNCS: + FlagPragma (&B, &InlineStdFuncs); + break; + case PRAGMA_LOCAL_STRINGS: FlagPragma (&B, &LocalStrings); break; diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 720e6db15..7a0450146 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -261,262 +261,277 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) goto ExitPoint; } - /* We've generated the complete code for the function now and know the - ** types of all parameters. Check for situations where better code can - ** be generated. If such a situation is detected, throw away the - ** generated, and emit better code. - */ - if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || - (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && - ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || - (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) { + if (IS_Get (&InlineStdFuncs)) { - int Reg1 = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr); - int Reg2 = ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr); - - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); - - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127) { - - AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); - g_defcodelabel (Label); - if (Reg2) { - AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); - } else { - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0)); - } - if (Reg1) { - AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); - } else { - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); - } - AddCodeLine ("dey"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - - } else { - - AddCodeLine ("ldy #$00"); - g_defcodelabel (Label); - if (Reg2) { - AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); - } else { - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0)); - } - if (Reg1) { - AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); - } else { - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); - } - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - - } - - /* memcpy returns the address, so the result is actually identical - ** to the first argument. + /* We've generated the complete code for the function now and know the + ** types of all parameters. Check for situations where better code can + ** be generated. If such a situation is detected, throw away the + ** generated, and emit better code. */ - *Expr = Arg1.Expr; + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || + (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && + ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || + (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) { - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) && - ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && - (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) { + int Reg1 = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr); + int Reg2 = ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr); - /* It is possible to just use one index register even if the stack - ** offset is not zero, by adjusting the offset to the constant - ** address accordingly. But we cannot do this if the data in - ** question is in the register space or at an absolute address less - ** than 256. Register space is zero page, which means that the - ** address calculation could overflow in the linker. - */ - int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) && - !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Calculate the real stack offset */ - Offs = ED_GetStackOffs (&Arg1.Expr, 0); + /* We need a label */ + Label = GetLocalLabel (); - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* Generate memcpy code */ + if (Arg3.Expr.IVal <= 127) { - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { - - if (Offs == 0) { - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); g_defcodelabel (Label); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); - AddCodeLine ("sta (sp),y"); + if (Reg2) { + AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); + } else { + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0)); + } + if (Reg1) { + AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + } AddCodeLine ("dey"); AddCodeLine ("bpl %s", LocalLabelName (Label)); + } else { - AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + + AddCodeLine ("ldy #$00"); g_defcodelabel (Label); - AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("sta (sp),y"); - AddCodeLine ("dey"); - AddCodeLine ("dex"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); + if (Reg2) { + AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0)); + } else { + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0)); + } + if (Reg1) { + AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + } + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } - } else { - - if (Offs == 0 || AllowOneIndex) { - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - g_defcodelabel (Label); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); - AddCodeLine ("sta (sp),y"); - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - } else { - AddCodeLine ("ldx #$00"); - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - g_defcodelabel (Label); - AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("sta (sp),y"); - AddCodeLine ("iny"); - AddCodeLine ("inx"); - AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - } + /* memcpy returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + /* Bail out, no need for further processing */ + goto ExitPoint; } - /* memcpy returns the address, so the result is actually identical - ** to the first argument. - */ - *Expr = Arg1.Expr; + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) && + ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && + (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) { - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && - (Arg2.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256 && - ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) { + /* It is possible to just use one index register even if the stack + ** offset is not zero, by adjusting the offset to the constant + ** address accordingly. But we cannot do this if the data in + ** question is in the register space or at an absolute address less + ** than 256. Register space is zero page, which means that the + ** address calculation could overflow in the linker. + */ + int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) && + !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256); - /* It is possible to just use one index register even if the stack - ** offset is not zero, by adjusting the offset to the constant - ** address accordingly. But we cannot do this if the data in - ** question is in the register space or at an absolute address less - ** than 256. Register space is zero page, which means that the - ** address calculation could overflow in the linker. - */ - int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) && - !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256); + /* Calculate the real stack offset */ + Offs = ED_GetStackOffs (&Arg1.Expr, 0); - /* Calculate the real stack offset */ - Offs = ED_GetStackOffs (&Arg2.Expr, 0); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* We need a label */ + Label = GetLocalLabel (); - /* We need a label */ - Label = GetLocalLabel (); + /* Generate memcpy code */ + if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { - /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { + if (Offs == 0) { + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + g_defcodelabel (Label); + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); + AddCodeLine ("sta (sp),y"); + AddCodeLine ("dey"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + g_defcodelabel (Label); + AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("sta (sp),y"); + AddCodeLine ("dey"); + AddCodeLine ("dex"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } - if (Offs == 0) { + } else { + + if (Offs == 0 || AllowOneIndex) { + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); + g_defcodelabel (Label); + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); + AddCodeLine ("sta (sp),y"); + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldx #$00"); + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); + g_defcodelabel (Label); + AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("sta (sp),y"); + AddCodeLine ("iny"); + AddCodeLine ("inx"); + AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } + + } + + /* memcpy returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && + (Arg2.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256 && + ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) { + + /* It is possible to just use one index register even if the stack + ** offset is not zero, by adjusting the offset to the constant + ** address accordingly. But we cannot do this if the data in + ** question is in the register space or at an absolute address less + ** than 256. Register space is zero page, which means that the + ** address calculation could overflow in the linker. + */ + int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) && + !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256); + + /* Calculate the real stack offset */ + Offs = ED_GetStackOffs (&Arg2.Expr, 0); + + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); + + /* We need a label */ + Label = GetLocalLabel (); + + /* Generate memcpy code */ + if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { + + if (Offs == 0) { + AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); + g_defcodelabel (Label); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("dey"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + g_defcodelabel (Label); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("dey"); + AddCodeLine ("dex"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } + + } else { + + if (Offs == 0 || AllowOneIndex) { + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); + g_defcodelabel (Label); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldx #$00"); + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); + g_defcodelabel (Label); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("iny"); + AddCodeLine ("inx"); + AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } + + } + + /* memcpy returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && + (Offs = ED_GetStackOffs (&Arg2.Expr, 0)) == 0) { + + /* Drop the generated code but leave the load of the first argument*/ + RemoveCode (&Arg1.Push); + + /* We need a label */ + Label = GetLocalLabel (); + + /* Generate memcpy code */ + AddCodeLine ("sta ptr1"); + AddCodeLine ("stx ptr1+1"); + if (Arg3.Expr.IVal <= 127) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); g_defcodelabel (Label); AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("sta (ptr1),y"); AddCodeLine ("dey"); AddCodeLine ("bpl %s", LocalLabelName (Label)); } else { - AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + AddCodeLine ("ldy #$00"); g_defcodelabel (Label); AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); - AddCodeLine ("dey"); - AddCodeLine ("dex"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - } - - } else { - - if (Offs == 0 || AllowOneIndex) { - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); + AddCodeLine ("sta (ptr1),y"); AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - } else { - AddCodeLine ("ldx #$00"); - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); - AddCodeLine ("iny"); - AddCodeLine ("inx"); - AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); } + /* Reload result - X hasn't changed by the code above */ + AddCodeLine ("lda ptr1"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + + /* Bail out, no need for further processing */ + goto ExitPoint; } - - /* memcpy returns the address, so the result is actually identical - ** to the first argument. - */ - *Expr = Arg1.Expr; - - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && - (Offs = ED_GetStackOffs (&Arg2.Expr, 0)) == 0) { - - /* Drop the generated code but leave the load of the first argument*/ - RemoveCode (&Arg1.Push); - - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate memcpy code */ - AddCodeLine ("sta ptr1"); - AddCodeLine ("stx ptr1+1"); - if (Arg3.Expr.IVal <= 127) { - AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); - g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta (ptr1),y"); - AddCodeLine ("dey"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - } else { - AddCodeLine ("ldy #$00"); - g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta (ptr1),y"); - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - } - - /* Reload result - X hasn't changed by the code above */ - AddCodeLine ("lda ptr1"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); - - } else { - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); - } + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + ExitPoint: /* We expect the closing brace */ ConsumeRParen (); @@ -595,140 +610,151 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) goto ExitPoint; } - /* We've generated the complete code for the function now and know the - ** types of all parameters. Check for situations where better code can - ** be generated. If such a situation is detected, throw away the - ** generated, and emit better code. - ** Note: Lots of improvements would be possible here, but I will - ** concentrate on the most common case: memset with arguments 2 and 3 - ** being constant numerical values. Some checks have shown that this - ** covers nearly 90% of all memset calls. - */ - if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsConstAbsInt (&Arg2.Expr) && - ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || - (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) { + if (IS_Get (&InlineStdFuncs)) { - int Reg = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr); + /* We've generated the complete code for the function now and know the + ** types of all parameters. Check for situations where better code can + ** be generated. If such a situation is detected, throw away the + ** generated, and emit better code. + ** Note: Lots of improvements would be possible here, but I will + ** concentrate on the most common case: memset with arguments 2 and 3 + ** being constant numerical values. Some checks have shown that this + ** covers nearly 90% of all memset calls. + */ + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsConstAbsInt (&Arg2.Expr) && + ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || + (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) { - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + int Reg = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr); - /* We need a label */ - Label = GetLocalLabel (); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Generate memset code */ - if (Arg3.Expr.IVal <= 127) { + /* We need a label */ + Label = GetLocalLabel (); + + /* Generate memset code */ + if (Arg3.Expr.IVal <= 127) { + + AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); + g_defcodelabel (Label); + if (Reg) { + AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + } + AddCodeLine ("dey"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); - AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); - g_defcodelabel (Label); - if (Reg) { - AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); } else { - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + + AddCodeLine ("ldy #$00"); + AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); + g_defcodelabel (Label); + if (Reg) { + AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); + } + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } - AddCodeLine ("dey"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - } else { - - AddCodeLine ("ldy #$00"); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); - g_defcodelabel (Label); - if (Reg) { - AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0)); - } else { - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); - } - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); + /* memset returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + /* Bail out, no need for further processing */ + goto ExitPoint; } - /* memset returns the address, so the result is actually identical - ** to the first argument. - */ - *Expr = Arg1.Expr; + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsConstAbsInt (&Arg2.Expr) && + ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && + (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) { - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsConstAbsInt (&Arg2.Expr) && - ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && - (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) { + /* Calculate the real stack offset */ + int Offs = ED_GetStackOffs (&Arg1.Expr, 0); - /* Calculate the real stack offset */ - int Offs = ED_GetStackOffs (&Arg1.Expr, 0); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* We need a label */ + Label = GetLocalLabel (); - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate memset code */ - AddCodeLine ("ldy #$%02X", (unsigned char) Offs); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); - g_defcodelabel (Label); - AddCodeLine ("sta (sp),y"); - AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); - AddCodeLine ("bne %s", LocalLabelName (Label)); - - /* memset returns the address, so the result is actually identical - ** to the first argument. - */ - *Expr = Arg1.Expr; - - } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && - ED_IsConstAbsInt (&Arg2.Expr) && - (Arg2.Expr.IVal != 0 || IS_Get (&CodeSizeFactor) > 200)) { - - /* Remove all of the generated code but the load of the first - ** argument. - */ - RemoveCode (&Arg1.Push); - - /* We need a label */ - Label = GetLocalLabel (); - - /* Generate code */ - AddCodeLine ("sta ptr1"); - AddCodeLine ("stx ptr1+1"); - if (Arg3.Expr.IVal <= 127) { - AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + /* Generate memset code */ + AddCodeLine ("ldy #$%02X", (unsigned char) Offs); AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); g_defcodelabel (Label); - AddCodeLine ("sta (ptr1),y"); - AddCodeLine ("dey"); - AddCodeLine ("bpl %s", LocalLabelName (Label)); - } else { - AddCodeLine ("ldy #$00"); - AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); - g_defcodelabel (Label); - AddCodeLine ("sta (ptr1),y"); + AddCodeLine ("sta (sp),y"); AddCodeLine ("iny"); - AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); + + /* memset returns the address, so the result is actually identical + ** to the first argument. + */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; } - /* Load the function result pointer into a/x (x is still valid). This - ** code will get removed by the optimizer if it is not used later. - */ - AddCodeLine ("lda ptr1"); + if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 && + ED_IsConstAbsInt (&Arg2.Expr) && + (Arg2.Expr.IVal != 0 || IS_Get (&CodeSizeFactor) > 200)) { - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); + /* Remove all of the generated code but the load of the first + ** argument. + */ + RemoveCode (&Arg1.Push); - } else { + /* We need a label */ + Label = GetLocalLabel (); - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); + /* Generate code */ + AddCodeLine ("sta ptr1"); + AddCodeLine ("stx ptr1+1"); + if (Arg3.Expr.IVal <= 127) { + AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); + AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); + g_defcodelabel (Label); + AddCodeLine ("sta (ptr1),y"); + AddCodeLine ("dey"); + AddCodeLine ("bpl %s", LocalLabelName (Label)); + } else { + AddCodeLine ("ldy #$00"); + AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); + g_defcodelabel (Label); + AddCodeLine ("sta (ptr1),y"); + AddCodeLine ("iny"); + AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); + AddCodeLine ("bne %s", LocalLabelName (Label)); + } + /* Load the function result pointer into a/x (x is still valid). This + ** code will get removed by the optimizer if it is not used later. + */ + AddCodeLine ("lda ptr1"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + + /* Bail out, no need for further processing */ + goto ExitPoint; + } } + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + ExitPoint: /* We expect the closing brace */ ConsumeRParen (); @@ -790,142 +816,142 @@ static void StdFunc_strcmp (FuncDesc* F attribute ((unused)), ExprDesc* Expr) ECount1 = ECount2; } - /* If the second argument is the empty string literal, we can generate - ** more efficient code. - */ - if (ED_IsLocLiteral (&Arg2.Expr) && - IS_Get (&WritableStrings) == 0 && - GetLiteralSize (Arg2.Expr.LVal) == 1 && - GetLiteralStr (Arg2.Expr.LVal)[0] == '\0') { + if (IS_Get (&InlineStdFuncs)) { - /* Drop the generated code so we have the first argument in the - ** primary + /* If the second argument is the empty string literal, we can generate + ** more efficient code. */ - RemoveCode (&Arg1.Push); + if (ED_IsLocLiteral (&Arg2.Expr) && + IS_Get (&WritableStrings) == 0 && + GetLiteralSize (Arg2.Expr.LVal) == 1 && + GetLiteralStr (Arg2.Expr.LVal)[0] == '\0') { - /* We don't need the literal any longer */ - ReleaseLiteral (Arg2.Expr.LVal); - - /* We do now have Arg1 in the primary. Load the first character from - ** this string and cast to int. This is the function result. - */ - IsArray = IsTypeArray (Arg1.Type) && ED_IsRVal (&Arg1.Expr); - if (IsArray && ED_IsLocStack (&Arg1.Expr) && - (Offs = ED_GetStackOffs (&Arg1.Expr, 0) < 256)) { - /* Drop the generated code */ - RemoveCode (&Arg1.Load); - - /* Generate code */ - AddCodeLine ("ldy #$%02X", Offs); - AddCodeLine ("ldx #$00"); - AddCodeLine ("lda (sp),y"); - } else if (IsArray && ED_IsLocConst (&Arg1.Expr)) { - /* Drop the generated code */ - RemoveCode (&Arg1.Load); - - /* Generate code */ - AddCodeLine ("ldx #$00"); - AddCodeLine ("lda %s", ED_GetLabelName (&Arg1.Expr, 0)); - } else { - /* Drop part of the generated code so we have the first argument - ** in the primary + /* Drop the generated code so we have the first argument in the + ** primary */ RemoveCode (&Arg1.Push); - /* Fetch the first char */ - g_getind (CF_CHAR | CF_UNSIGNED, 0); + /* We don't need the literal any longer */ + ReleaseLiteral (Arg2.Expr.LVal); + + /* We do now have Arg1 in the primary. Load the first character from + ** this string and cast to int. This is the function result. + */ + IsArray = IsTypeArray (Arg1.Type) && ED_IsRVal (&Arg1.Expr); + if (IsArray && ED_IsLocStack (&Arg1.Expr) && + (Offs = ED_GetStackOffs (&Arg1.Expr, 0) < 256)) { + /* Drop the generated code */ + RemoveCode (&Arg1.Load); + + /* Generate code */ + AddCodeLine ("ldy #$%02X", Offs); + AddCodeLine ("ldx #$00"); + AddCodeLine ("lda (sp),y"); + } else if (IsArray && ED_IsLocConst (&Arg1.Expr)) { + /* Drop the generated code */ + RemoveCode (&Arg1.Load); + + /* Generate code */ + AddCodeLine ("ldx #$00"); + AddCodeLine ("lda %s", ED_GetLabelName (&Arg1.Expr, 0)); + } else { + /* Drop part of the generated code so we have the first argument + ** in the primary + */ + RemoveCode (&Arg1.Push); + + /* Fetch the first char */ + g_getind (CF_CHAR | CF_UNSIGNED, 0); + } + + } else if ((IS_Get (&CodeSizeFactor) >= 165) && + ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || + (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && + ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || + (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) && + (IS_Get (&EagerlyInlineFuncs) || (ECount1 > 0 && ECount1 < 256))) { + + unsigned Entry, Loop, Fin; /* Labels */ + const char* Load; + const char* Compare; + + if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) { + Load = "lda (%s),y"; + } else { + Load = "lda %s,y"; + } + if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { + Compare = "cmp (%s),y"; + } else { + Compare = "cmp %s,y"; + } + + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); + + /* We need labels */ + Entry = GetLocalLabel (); + Loop = GetLocalLabel (); + Fin = GetLocalLabel (); + + /* Generate strcmp code */ + AddCodeLine ("ldy #$00"); + AddCodeLine ("beq %s", LocalLabelName (Entry)); + g_defcodelabel (Loop); + AddCodeLine ("tax"); + AddCodeLine ("beq %s", LocalLabelName (Fin)); + AddCodeLine ("iny"); + g_defcodelabel (Entry); + AddCodeLine (Load, ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("beq %s", LocalLabelName (Loop)); + AddCodeLine ("ldx #$01"); + AddCodeLine ("bcs %s", LocalLabelName (Fin)); + AddCodeLine ("ldx #$FF"); + g_defcodelabel (Fin); + + } else if ((IS_Get (&CodeSizeFactor) > 190) && + ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || + (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && + (IS_Get (&EagerlyInlineFuncs) || (ECount1 > 0 && ECount1 < 256))) { + + unsigned Entry, Loop, Fin; /* Labels */ + const char* Compare; + + if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { + Compare = "cmp (%s),y"; + } else { + Compare = "cmp %s,y"; + } + + /* Drop the generated code */ + RemoveCode (&Arg1.Push); + + /* We need labels */ + Entry = GetLocalLabel (); + Loop = GetLocalLabel (); + Fin = GetLocalLabel (); + + /* Store Arg1 into ptr1 */ + AddCodeLine ("sta ptr1"); + AddCodeLine ("stx ptr1+1"); + + /* Generate strcmp code */ + AddCodeLine ("ldy #$00"); + AddCodeLine ("beq %s", LocalLabelName (Entry)); + g_defcodelabel (Loop); + AddCodeLine ("tax"); + AddCodeLine ("beq %s", LocalLabelName (Fin)); + AddCodeLine ("iny"); + g_defcodelabel (Entry); + AddCodeLine ("lda (ptr1),y"); + AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("beq %s", LocalLabelName (Loop)); + AddCodeLine ("ldx #$01"); + AddCodeLine ("bcs %s", LocalLabelName (Fin)); + AddCodeLine ("ldx #$FF"); + g_defcodelabel (Fin); } - - } else if ((IS_Get (&CodeSizeFactor) >= 165) && - ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || - (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && - ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || - (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) && - (IS_Get (&InlineStdFuncs) || (ECount1 > 0 && ECount1 < 256))) { - - - unsigned Entry, Loop, Fin; /* Labels */ - const char* Load; - const char* Compare; - - if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) { - Load = "lda (%s),y"; - } else { - Load = "lda %s,y"; - } - if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { - Compare = "cmp (%s),y"; - } else { - Compare = "cmp %s,y"; - } - - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); - - /* We need labels */ - Entry = GetLocalLabel (); - Loop = GetLocalLabel (); - Fin = GetLocalLabel (); - - /* Generate strcmp code */ - AddCodeLine ("ldy #$00"); - AddCodeLine ("beq %s", LocalLabelName (Entry)); - g_defcodelabel (Loop); - AddCodeLine ("tax"); - AddCodeLine ("beq %s", LocalLabelName (Fin)); - AddCodeLine ("iny"); - g_defcodelabel (Entry); - AddCodeLine (Load, ED_GetLabelName (&Arg1.Expr, 0)); - AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("beq %s", LocalLabelName (Loop)); - AddCodeLine ("ldx #$01"); - AddCodeLine ("bcs %s", LocalLabelName (Fin)); - AddCodeLine ("ldx #$FF"); - g_defcodelabel (Fin); - - } else if ((IS_Get (&CodeSizeFactor) > 190) && - ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || - (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && - (IS_Get (&InlineStdFuncs) || (ECount1 > 0 && ECount1 < 256))) { - - - unsigned Entry, Loop, Fin; /* Labels */ - const char* Compare; - - if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { - Compare = "cmp (%s),y"; - } else { - Compare = "cmp %s,y"; - } - - /* Drop the generated code */ - RemoveCode (&Arg1.Push); - - /* We need labels */ - Entry = GetLocalLabel (); - Loop = GetLocalLabel (); - Fin = GetLocalLabel (); - - /* Store Arg1 into ptr1 */ - AddCodeLine ("sta ptr1"); - AddCodeLine ("stx ptr1+1"); - - /* Generate strcmp code */ - AddCodeLine ("ldy #$00"); - AddCodeLine ("beq %s", LocalLabelName (Entry)); - g_defcodelabel (Loop); - AddCodeLine ("tax"); - AddCodeLine ("beq %s", LocalLabelName (Fin)); - AddCodeLine ("iny"); - g_defcodelabel (Entry); - AddCodeLine ("lda (ptr1),y"); - AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("beq %s", LocalLabelName (Loop)); - AddCodeLine ("ldx #$01"); - AddCodeLine ("bcs %s", LocalLabelName (Fin)); - AddCodeLine ("ldx #$FF"); - g_defcodelabel (Fin); - } /* The function result is an rvalue in the primary register */ @@ -983,142 +1009,154 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Get the element count of argument 1 if it is an array */ ECount = ArrayElementCount (&Arg1); - /* We've generated the complete code for the function now and know the - ** types of all parameters. Check for situations where better code can - ** be generated. If such a situation is detected, throw away the - ** generated, and emit better code. - */ - if (((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || - (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && - ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || - (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) && - (IS_Get (&InlineStdFuncs) || - (ECount != UNSPECIFIED && ECount < 256))) { + if (IS_Get (&InlineStdFuncs)) { - const char* Load; - const char* Store; - if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { - Load = "lda (%s),y"; - } else { - Load = "lda %s,y"; - } - if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) { - Store = "sta (%s),y"; - } else { - Store = "sta %s,y"; - } - - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); - - /* We need labels */ - L1 = GetLocalLabel (); - - /* Generate strcpy code */ - AddCodeLine ("ldy #$FF"); - g_defcodelabel (L1); - AddCodeLine ("iny"); - AddCodeLine (Load, ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine (Store, ED_GetLabelName (&Arg1.Expr, 0)); - AddCodeLine ("bne %s", LocalLabelName (L1)); - - /* strcpy returns argument #1 */ - *Expr = Arg1.Expr; - - } else if (ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && - StackPtr >= -255 && - ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) { - - /* It is possible to just use one index register even if the stack - ** offset is not zero, by adjusting the offset to the constant - ** address accordingly. But we cannot do this if the data in - ** question is in the register space or at an absolute address less - ** than 256. Register space is zero page, which means that the - ** address calculation could overflow in the linker. + /* We've generated the complete code for the function now and know the + ** types of all parameters. Check for situations where better code can + ** be generated. If such a situation is detected, throw away the + ** generated, and emit better code. */ - int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) && - !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256); + if (((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) || + (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) && + ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) || + (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) && + (IS_Get (&EagerlyInlineFuncs) || + (ECount != UNSPECIFIED && ECount < 256))) { - /* Calculate the real stack offset */ - int Offs = ED_GetStackOffs (&Arg2.Expr, 0); + const char* Load; + const char* Store; + if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) { + Load = "lda (%s),y"; + } else { + Load = "lda %s,y"; + } + if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) { + Store = "sta (%s),y"; + } else { + Store = "sta %s,y"; + } - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* We need labels */ - L1 = GetLocalLabel (); + /* We need labels */ + L1 = GetLocalLabel (); - /* Generate strcpy code */ - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1)); - if (Offs == 0 || AllowOneIndex) { + /* Generate strcpy code */ + AddCodeLine ("ldy #$FF"); g_defcodelabel (L1); AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); - } else { - AddCodeLine ("ldx #$FF"); - g_defcodelabel (L1); - AddCodeLine ("iny"); - AddCodeLine ("inx"); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine (Load, ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine (Store, ED_GetLabelName (&Arg1.Expr, 0)); + AddCodeLine ("bne %s", LocalLabelName (L1)); + + /* strcpy returns argument #1 */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; } - AddCodeLine ("bne %s", LocalLabelName (L1)); - /* strcpy returns argument #1 */ - *Expr = Arg1.Expr; + if (ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) && + StackPtr >= -255 && + ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) { - } else if (ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) && - ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && - StackPtr >= -255) { + /* It is possible to just use one index register even if the stack + ** offset is not zero, by adjusting the offset to the constant + ** address accordingly. But we cannot do this if the data in + ** question is in the register space or at an absolute address less + ** than 256. Register space is zero page, which means that the + ** address calculation could overflow in the linker. + */ + int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) && + !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256); - /* It is possible to just use one index register even if the stack - ** offset is not zero, by adjusting the offset to the constant - ** address accordingly. But we cannot do this if the data in - ** question is in the register space or at an absolute address less - ** than 256. Register space is zero page, which means that the - ** address calculation could overflow in the linker. - */ - int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) && - !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256); + /* Calculate the real stack offset */ + int Offs = ED_GetStackOffs (&Arg2.Expr, 0); - /* Calculate the real stack offset */ - int Offs = ED_GetStackOffs (&Arg1.Expr, 0); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); - /* Drop the generated code */ - RemoveCode (&Arg1.Expr.Start); + /* We need labels */ + L1 = GetLocalLabel (); - /* We need labels */ - L1 = GetLocalLabel (); + /* Generate strcpy code */ + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1)); + if (Offs == 0 || AllowOneIndex) { + g_defcodelabel (L1); + AddCodeLine ("iny"); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); + } else { + AddCodeLine ("ldx #$FF"); + g_defcodelabel (L1); + AddCodeLine ("iny"); + AddCodeLine ("inx"); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); + } + AddCodeLine ("bne %s", LocalLabelName (L1)); - /* Generate strcpy code */ - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1)); - if (Offs == 0 || AllowOneIndex) { - g_defcodelabel (L1); - AddCodeLine ("iny"); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); - AddCodeLine ("sta (sp),y"); - } else { - AddCodeLine ("ldx #$FF"); - g_defcodelabel (L1); - AddCodeLine ("iny"); - AddCodeLine ("inx"); - AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("sta (sp),y"); + /* strcpy returns argument #1 */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; } - AddCodeLine ("bne %s", LocalLabelName (L1)); - /* strcpy returns argument #1 */ - *Expr = Arg1.Expr; + if (ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) && + ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) && + StackPtr >= -255) { - } else { + /* It is possible to just use one index register even if the stack + ** offset is not zero, by adjusting the offset to the constant + ** address accordingly. But we cannot do this if the data in + ** question is in the register space or at an absolute address less + ** than 256. Register space is zero page, which means that the + ** address calculation could overflow in the linker. + */ + int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) && + !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256); - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = GetFuncReturn (Expr->Type); + /* Calculate the real stack offset */ + int Offs = ED_GetStackOffs (&Arg1.Expr, 0); + /* Drop the generated code */ + RemoveCode (&Arg1.Expr.Start); + + /* We need labels */ + L1 = GetLocalLabel (); + + /* Generate strcpy code */ + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1)); + if (Offs == 0 || AllowOneIndex) { + g_defcodelabel (L1); + AddCodeLine ("iny"); + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); + AddCodeLine ("sta (sp),y"); + } else { + AddCodeLine ("ldx #$FF"); + g_defcodelabel (L1); + AddCodeLine ("iny"); + AddCodeLine ("inx"); + AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); + AddCodeLine ("sta (sp),y"); + } + AddCodeLine ("bne %s", LocalLabelName (L1)); + + /* strcpy returns argument #1 */ + *Expr = Arg1.Expr; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } } + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = GetFuncReturn (Expr->Type); + +ExitPoint: /* We expect the closing brace */ ConsumeRParen (); } @@ -1142,8 +1180,6 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr) long ECount; unsigned L; - - /* Setup the argument type string */ ArgType[1].C = GetDefaultChar () | T_QUAL_CONST; @@ -1175,125 +1211,148 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Do type conversion */ TypeConversion (&Arg, ArgType); - /* If the expression is a literal, and if string literals are read - ** only, we can calculate the length of the string and remove it - ** from the literal pool. Otherwise we have to calculate the length - ** at runtime. - */ - if (ED_IsLocLiteral (&Arg) && IS_Get (&WritableStrings) == 0) { + if (IS_Get (&Optimize)) { - /* Constant string literal */ - ED_MakeConstAbs (Expr, GetLiteralSize (Arg.LVal) - 1, type_size_t); + /* If the expression is a literal, and if string literals are read + ** only, we can calculate the length of the string and remove it + ** from the literal pool. Otherwise we have to calculate the length + ** at runtime. + */ + if (ED_IsLocLiteral (&Arg) && IS_Get (&WritableStrings) == 0) { - /* We don't need the literal any longer */ - ReleaseLiteral (Arg.LVal); + /* Constant string literal */ + ED_MakeConstAbs (Expr, GetLiteralSize (Arg.LVal) - 1, type_size_t); - /* We will inline strlen for arrays with constant addresses, if either the - ** inlining was forced on the command line, or the array is smaller than - ** 256, so the inlining is considered safe. - */ - } else if (ED_IsLocConst (&Arg) && IsArray && - (IS_Get (&InlineStdFuncs) || IsByteIndex)) { - - /* Generate the strlen code */ - L = GetLocalLabel (); - AddCodeLine ("ldy #$FF"); - g_defcodelabel (L); - AddCodeLine ("iny"); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg, 0)); - AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("tax"); - AddCodeLine ("tya"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; - - /* We will inline strlen for arrays on the stack, if the array is - ** completely within the reach of a byte sized index register. - */ - } else if (ED_IsLocStack (&Arg) && IsArray && IsByteIndex && - (Arg.IVal - StackPtr) + ECount < 256) { - - /* Calculate the true stack offset */ - int Offs = ED_GetStackOffs (&Arg, 0); - - /* Generate the strlen code */ - L = GetLocalLabel (); - AddCodeLine ("ldx #$FF"); - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs-1)); - g_defcodelabel (L); - AddCodeLine ("inx"); - AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); - AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("txa"); - AddCodeLine ("ldx #$00"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; - - /* strlen for a string that is pointed to by a register variable will only - ** get inlined if requested on the command line, since we cannot know how - ** big the buffer actually is, so inlining is not always safe. - */ - } else if (ED_IsLocRegister (&Arg) && ED_IsLVal (&Arg) && IsPtr && - IS_Get (&InlineStdFuncs)) { - - /* Generate the strlen code */ - L = GetLocalLabel (); - AddCodeLine ("ldy #$FF"); - g_defcodelabel (L); - AddCodeLine ("iny"); - AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg, 0)); - AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("tax"); - AddCodeLine ("tya"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; - - /* Last check: We will inline a generic strlen routine if inlining was - ** requested on the command line, and the code size factor is more than - ** 400 (code is 13 bytes vs. 3 for a jsr call). - */ - } else if (IS_Get (&CodeSizeFactor) > 400 && IS_Get (&InlineStdFuncs)) { - - /* Load the expression into the primary */ - LoadExpr (CF_NONE, &Arg); - - /* Inline the function */ - L = GetLocalLabel (); - AddCodeLine ("sta ptr1"); - AddCodeLine ("stx ptr1+1"); - AddCodeLine ("ldy #$FF"); - g_defcodelabel (L); - AddCodeLine ("iny"); - AddCodeLine ("lda (ptr1),y"); - AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("tax"); - AddCodeLine ("tya"); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; - - } else { - - /* Load the expression into the primary */ - LoadExpr (CF_NONE, &Arg); - - /* Call the strlen function */ - AddCodeLine ("jsr _%s", Func_strlen); - - /* The function result is an rvalue in the primary register */ - ED_MakeRValExpr (Expr); - Expr->Type = type_size_t; + /* We don't need the literal any longer */ + ReleaseLiteral (Arg.LVal); + /* Bail out, no need for further improvements */ + goto ExitPoint; + } } + if (IS_Get (&InlineStdFuncs)) { + + /* We will inline strlen for arrays with constant addresses, if either + ** requested on the command line, or the array is smaller than 256, + ** so the inlining is considered safe. + */ + if (ED_IsLocConst (&Arg) && IsArray && + (IS_Get (&EagerlyInlineFuncs) || IsByteIndex)) { + + /* Generate the strlen code */ + L = GetLocalLabel (); + AddCodeLine ("ldy #$FF"); + g_defcodelabel (L); + AddCodeLine ("iny"); + AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg, 0)); + AddCodeLine ("bne %s", LocalLabelName (L)); + AddCodeLine ("tax"); + AddCodeLine ("tya"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + /* We will inline strlen for arrays on the stack, if the array is + ** completely within the reach of a byte sized index register. + */ + if (ED_IsLocStack (&Arg) && IsArray && IsByteIndex && + (Arg.IVal - StackPtr) + ECount < 256) { + + /* Calculate the true stack offset */ + int Offs = ED_GetStackOffs (&Arg, 0); + + /* Generate the strlen code */ + L = GetLocalLabel (); + AddCodeLine ("ldx #$FF"); + AddCodeLine ("ldy #$%02X", (unsigned char) (Offs-1)); + g_defcodelabel (L); + AddCodeLine ("inx"); + AddCodeLine ("iny"); + AddCodeLine ("lda (sp),y"); + AddCodeLine ("bne %s", LocalLabelName (L)); + AddCodeLine ("txa"); + AddCodeLine ("ldx #$00"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + /* strlen for a string that is pointed to by a register variable will only + ** get inlined if requested on the command line, since we cannot know how + ** big the buffer actually is, so inlining is not always safe. + */ + if (ED_IsLocRegister (&Arg) && ED_IsLVal (&Arg) && IsPtr && + IS_Get (&EagerlyInlineFuncs)) { + + /* Generate the strlen code */ + L = GetLocalLabel (); + AddCodeLine ("ldy #$FF"); + g_defcodelabel (L); + AddCodeLine ("iny"); + AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg, 0)); + AddCodeLine ("bne %s", LocalLabelName (L)); + AddCodeLine ("tax"); + AddCodeLine ("tya"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + + /* Last check: We will inline a generic strlen routine if inlining was + ** requested on the command line, and the code size factor is more than + ** 400 (code is 13 bytes vs. 3 for a jsr call). + */ + if (IS_Get (&CodeSizeFactor) > 400 && IS_Get (&EagerlyInlineFuncs)) { + + /* Load the expression into the primary */ + LoadExpr (CF_NONE, &Arg); + + /* Inline the function */ + L = GetLocalLabel (); + AddCodeLine ("sta ptr1"); + AddCodeLine ("stx ptr1+1"); + AddCodeLine ("ldy #$FF"); + g_defcodelabel (L); + AddCodeLine ("iny"); + AddCodeLine ("lda (ptr1),y"); + AddCodeLine ("bne %s", LocalLabelName (L)); + AddCodeLine ("tax"); + AddCodeLine ("tya"); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + + /* Bail out, no need for further processing */ + goto ExitPoint; + } + } + + /* Load the expression into the primary */ + LoadExpr (CF_NONE, &Arg); + + /* Call the strlen function */ + AddCodeLine ("jsr _%s", Func_strlen); + + /* The function result is an rvalue in the primary register */ + ED_MakeRValExpr (Expr); + Expr->Type = type_size_t; + +ExitPoint: /* We expect the closing brace */ ConsumeRParen (); } From 9b345099569af702175cf89f3ef29838c4eeac46 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 00:41:40 +0200 Subject: [PATCH 284/407] Use the more explicit tag style for recently added internal links. --- doc/cc65.sgml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 9322a2d44..827b63c80 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -247,10 +247,10 @@ Here is a description of all the command line options: <p> </itemize> - <tt/--eagerly-inline-funcs/ implies the <tt/<ref id="option-inline-stdfuncs" - name="--inline-stdfuncs"/ command line option. + <tt/--eagerly-inline-funcs/ implies the <tt><ref id="option-inline-stdfuncs" + name="--inline-stdfuncs"></tt> command line option. - See also <tt/<ref id="pragma-allow-eager-inline" name="#pragma allow-eager-inline">/. + See also <tt><ref id="pragma-allow-eager-inline" name="#pragma allow-eager-inline"></tt>. <tag><tt>-h, --help</tt></tag> @@ -263,9 +263,9 @@ Here is a description of all the command line options: Allow the compiler to inline some standard functions from the C library like strlen. This will not only remove the overhead for a function call, but will - make the code visible for the optimizer. See also the <tt/<ref id="option-O" - name="-Os"/ command line option and <tt/<ref id="pragma-inline-stdfuncs" - name="#pragma inline-stdfuncs">/. + make the code visible for the optimizer. See also the <tt><ref id="option-O" + name="-Os"></tt> command line option and <tt><ref id="pragma-inline-stdfuncs" + name="#pragma inline-stdfuncs"></tt>. <label id="option-list-warnings"> @@ -861,8 +861,8 @@ The compiler defines several macros at startup: <tag><tt>__EAGERLY_INLINE_FUNCS__</tt></tag> - Is defined if the compiler was called with the <tt/<ref id="option-eagerly-inline-funcs" - name="--eagerly-inline-funcs"/ command line option. + Is defined if the compiler was called with the <tt><ref id="option-eagerly-inline-funcs" + name="--eagerly-inline-funcs"></tt> command line option. <tag><tt>__FILE__</tt></tag> @@ -965,9 +965,9 @@ parameter with the <tt/#pragma/. Allow eager inlining of known functions. If the argument is "off", eager inlining is disabled, otherwise it is enabled. Please note that (in contrast - to the <tt/<ref id="option-eagerly-inline-funcs" name="--eagerly-inline-funcs"/ - command line option) this pragma does not imply the <tt/<ref id="option-inline-stdfuncs" - name="--inline-stdfuncs"/ command line option. Rather it marks code to be safe for + to the <tt><ref id="option-eagerly-inline-funcs" name="--eagerly-inline-funcs"></tt> + command line option) this pragma does not imply the <tt><ref id="option-inline-stdfuncs" + name="--inline-stdfuncs"></tt> command line option. Rather it marks code to be safe for eager inlining of known functions if inlining of standard functions is enabled. The <tt/#pragma/ understands the push and pop parameters as explained above. From 3b17c3a411a6e1b2099124a76f581fe5d1d79870 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 4 Apr 2017 07:23:05 -0400 Subject: [PATCH 285/407] Fixed 2 typoes. Warning messages from nsgmls usually mean a typing mistake a few lines above the first line that's named by nsgmls. --- doc/cc65.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 827b63c80..653a917db 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -491,7 +491,7 @@ Here is a description of all the command line options: Using <tt/-Os/ will allow the compiler to inline some standard functions from the C library like strlen. This will not only remove the overhead for a function call, but will make the code visible for the optimizer. - See also <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs"/. + See also <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/. It is possible to concatenate the modifiers for <tt/-O/. For example, to enable register variables and inlining of standard functions, you may use @@ -1098,7 +1098,7 @@ parameter with the <tt/#pragma/. Allow the compiler to inline some standard functions from the C library like strlen. If the argument is "off", inlining is disabled, otherwise it is enabled. - See also the the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs"/ + See also the the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/ command line option. The <tt/#pragma/ understands the push and pop parameters as explained above. From 4e856546c17603b772b4b239d8cc5caec8d88833 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 13:42:57 +0200 Subject: [PATCH 286/407] Minor language update. --- doc/cc65.sgml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 653a917db..24b37133e 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -491,7 +491,8 @@ Here is a description of all the command line options: Using <tt/-Os/ will allow the compiler to inline some standard functions from the C library like strlen. This will not only remove the overhead for a function call, but will make the code visible for the optimizer. - See also <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/. + See also the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/ + command line option. It is possible to concatenate the modifiers for <tt/-O/. For example, to enable register variables and inlining of standard functions, you may use @@ -1098,7 +1099,7 @@ parameter with the <tt/#pragma/. Allow the compiler to inline some standard functions from the C library like strlen. If the argument is "off", inlining is disabled, otherwise it is enabled. - See also the the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/ + See also the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/ command line option. The <tt/#pragma/ understands the push and pop parameters as explained above. From 275b27647ed4eeb9da98bd3227002046a52291df Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:43:56 +0200 Subject: [PATCH 287/407] Removed superfluous final linefeed. --- libsrc/runtime/axlong.s | 1 - 1 file changed, 1 deletion(-) diff --git a/libsrc/runtime/axlong.s b/libsrc/runtime/axlong.s index 02d0a825c..1fbd53ef0 100644 --- a/libsrc/runtime/axlong.s +++ b/libsrc/runtime/axlong.s @@ -19,4 +19,3 @@ axulong: store: sty sreg sty sreg+1 rts - From 14268510f59211d4b491d3eec937ea703a83bf0d Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:45:24 +0200 Subject: [PATCH 288/407] Removed workaround. --- test/val/lib_common_memmove.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/val/lib_common_memmove.c b/test/val/lib_common_memmove.c index 6c04e1951..6b2273e78 100644 --- a/test/val/lib_common_memmove.c +++ b/test/val/lib_common_memmove.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" @@ -10,7 +6,6 @@ static char Buffer[BufferSize+3]; // +1 to move up (and down) - TEST { unsigned i, v; @@ -61,5 +56,3 @@ TEST } } ENDTEST - - From 3789174162b5a5e81703fdb3f2a8e584d428f885 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:51:00 +0200 Subject: [PATCH 289/407] Removed workaround. --- test/val/lib_common_strcat.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/val/lib_common_strcat.c b/test/val/lib_common_strcat.c index 6389d5651..1872053a4 100644 --- a/test/val/lib_common_strcat.c +++ b/test/val/lib_common_strcat.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" From cd27fef6a8b2b58db36eaef767cda1a09ee2ac8c Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:52:01 +0200 Subject: [PATCH 290/407] Removed workaround. --- test/val/lib_common_strcspn.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/val/lib_common_strcspn.c b/test/val/lib_common_strcspn.c index 06838c435..f289ddb95 100644 --- a/test/val/lib_common_strcspn.c +++ b/test/val/lib_common_strcspn.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" @@ -11,6 +7,7 @@ static char EstimatedString[EstimatedStringSize+1]; // +1 room for terminati static char* EmptyTestChars=""; // strlen equivalent... static char* TestChars="1234567890"; // we like to find numbers + TEST { unsigned i; @@ -26,5 +23,3 @@ TEST ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!"); } ENDTEST - - From 93193727be4bcebfa1d728b2b948a0ebba116e43 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:52:37 +0200 Subject: [PATCH 291/407] Removed workaround. --- test/val/lib_common_strncat.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/val/lib_common_strncat.c b/test/val/lib_common_strncat.c index 84d904fa0..a6f92ac05 100644 --- a/test/val/lib_common_strncat.c +++ b/test/val/lib_common_strncat.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" @@ -54,5 +50,3 @@ TEST } } ENDTEST - - From e8065155416c060da83b03007ad17e9a837df2aa Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 4 Apr 2017 15:53:14 +0200 Subject: [PATCH 292/407] Removed workaround. --- test/val/lib_common_strspn.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/val/lib_common_strspn.c b/test/val/lib_common_strspn.c index 693a1136a..96a006469 100644 --- a/test/val/lib_common_strspn.c +++ b/test/val/lib_common_strspn.c @@ -1,7 +1,3 @@ -// temporarily disable optimizations altogether until a fine grain control -// is implemented on Makefile level only disabling the compiler option -Os -#pragma optimize (off) - #include <string.h> #include "unittest.h" From dce5783dc96bbf9165e8815c9df1314818241cb7 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 4 Apr 2017 13:23:44 -0400 Subject: [PATCH 293/407] Fixed the simulations of the stack pointer and the "break" and decimal-mode flags. * The pointer wraps around the stack page. * The break flag exists on only the stack, and only after an interrupt. * 65C02 interrupts clear the decimal-mode flag. --- src/sim65/6502.c | 57 +++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 81caff4da..1febef657 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -34,14 +34,12 @@ /* Known bugs and limitations of the 65C02 simulation: * support currently only on the level of 65SC02: - BBRx, BBSx, RMBx, SMBx, WAI and STP are unsupported + BBRx, BBSx, RMBx, SMBx, WAI, and STP are unsupported * BCD flag handling equals 6502 (unchecked if bug is simulated or wrong for 6502) * one cycle win for fetch-modify-write instructions ignored - (e.g. ROL abs,x takes only 6 cycles if no page break occurs) - * BRK, IRQ, NMI and RESET are not different from 6502 which they are in - reality (e.g. D-flag handling) - */ + (e.g., ROL abs,x takes only 6 cycles if no page break occurs) +*/ #include "memory.h" #include "error.h" @@ -87,12 +85,11 @@ int PrintCycles; -/* Return the flags as a boolean value (0/1) */ +/* Return the flags as boolean values (0/1) */ #define GET_CF() ((Regs.SR & CF) != 0) #define GET_ZF() ((Regs.SR & ZF) != 0) #define GET_IF() ((Regs.SR & IF) != 0) #define GET_DF() ((Regs.SR & DF) != 0) -#define GET_BF() ((Regs.SR & BF) != 0) #define GET_OF() ((Regs.SR & OF) != 0) #define GET_SF() ((Regs.SR & SF) != 0) @@ -103,7 +100,6 @@ int PrintCycles; #define SET_ZF(f) do { if (f) { Regs.SR |= ZF; } else { Regs.SR &= ~ZF; } } while (0) #define SET_IF(f) do { if (f) { Regs.SR |= IF; } else { Regs.SR &= ~IF; } } while (0) #define SET_DF(f) do { if (f) { Regs.SR |= DF; } else { Regs.SR &= ~DF; } } while (0) -#define SET_BF(f) do { if (f) { Regs.SR |= BF; } else { Regs.SR &= ~BF; } } while (0) #define SET_OF(f) do { if (f) { Regs.SR |= OF; } else { Regs.SR &= ~OF; } } while (0) #define SET_SF(f) do { if (f) { Regs.SR |= SF; } else { Regs.SR &= ~SF; } } while (0) @@ -119,8 +115,8 @@ int PrintCycles; #define PCH ((Regs.PC >> 8) & 0xFF) /* Stack operations */ -#define PUSH(Val) MemWriteByte (0x0100 + Regs.SP--, Val) -#define POP() MemReadByte (0x0100 + ++Regs.SP) +#define PUSH(Val) MemWriteByte (0x0100 | (Regs.SP-- & 0xFF), Val) +#define POP() MemReadByte (0x0100 | (++Regs.SP & 0xFF)) /* Test for page cross */ #define PAGE_CROSS(addr,offs) ((((addr) & 0xFF) + offs) >= 0x100) @@ -376,11 +372,14 @@ static void OPC_6502_00 (void) { Cycles = 7; Regs.PC += 2; - SET_BF (1); PUSH (PCH); PUSH (PCL); PUSH (Regs.SR); SET_IF (1); + if (CPU != CPU_6502) + { + SET_DF (0); + } Regs.PC = MemReadWord (0xFFFE); } @@ -403,7 +402,7 @@ static void OPC_65SC02_04 (void) ZPAddr = MemReadByte (Regs.PC+1); Val = MemReadByte (ZPAddr); SET_ZF ((Val & Regs.AC) == 0); - MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC)); + MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC)); Regs.PC += 2; } @@ -438,7 +437,7 @@ static void OPC_6502_08 (void) /* Opcode $08: PHP */ { Cycles = 3; - PUSH (Regs.SR & ~BF); + PUSH (Regs.SR); Regs.PC += 1; } @@ -475,7 +474,7 @@ static void OPC_65SC02_0C (void) Addr = MemReadWord (Regs.PC+1); Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); - MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); + MemWriteByte (Addr, (unsigned char) (Val | Regs.AC)); Regs.PC += 3; } @@ -539,7 +538,7 @@ static void OPC_65SC02_14 (void) ZPAddr = MemReadByte (Regs.PC+1); Val = MemReadByte (ZPAddr); SET_ZF ((Val & Regs.AC) == 0); - MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC)); + MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC)); Regs.PC += 2; } @@ -609,7 +608,7 @@ static void OPC_65SC02_1C (void) Addr = MemReadWord (Regs.PC+1); Val = MemReadByte (Addr); SET_ZF ((Val & Regs.AC) == 0); - MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); + MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC)); Regs.PC += 3; } @@ -707,7 +706,9 @@ static void OPC_6502_28 (void) /* Opcode $28: PLP */ { Cycles = 4; - Regs.SR = (POP () & ~BF); + + /* Bits 5 and 4 aren't used, and always are 1! */ + Regs.SR = (POP () | 0x30); Regs.PC += 1; } @@ -909,7 +910,9 @@ static void OPC_6502_40 (void) /* Opcode $40: RTI */ { Cycles = 6; - Regs.SR = POP (); + + /* Bits 5 and 4 aren't used, and always are 1! */ + Regs.SR = POP () | 0x30; Regs.PC = POP (); /* PCL */ Regs.PC |= (POP () << 8); /* PCH */ } @@ -2011,7 +2014,7 @@ static void OPC_6502_BA (void) /* Opcode $BA: TSX */ { Cycles = 2; - Regs.XR = Regs.SP; + Regs.XR = Regs.SP & 0xFF; TEST_ZF (Regs.XR); TEST_SF (Regs.XR); Regs.PC += 1; @@ -3213,7 +3216,9 @@ void Reset (void) /* Reset the CPU */ HaveIRQRequest = 0; HaveNMIRequest = 0; - Regs.SR = 0; + + /* Bits 5 and 4 aren't used, and always are 1! */ + Regs.SR = 0x30; Regs.PC = MemReadWord (0xFFFC); } @@ -3228,8 +3233,12 @@ unsigned ExecuteInsn (void) HaveNMIRequest = 0; PUSH (PCH); PUSH (PCL); - PUSH (Regs.SR); + PUSH (Regs.SR & ~BF); SET_IF (1); + if (CPU != CPU_6502) + { + SET_DF (0); + } Regs.PC = MemReadWord (0xFFFA); Cycles = 7; @@ -3238,8 +3247,12 @@ unsigned ExecuteInsn (void) HaveIRQRequest = 0; PUSH (PCH); PUSH (PCL); - PUSH (Regs.SR); + PUSH (Regs.SR & ~BF); SET_IF (1); + if (CPU != CPU_6502) + { + SET_DF (0); + } Regs.PC = MemReadWord (0xFFFE); Cycles = 7; From be772c0198f2d978171e0f35b5e1f71d27c414f6 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 6 Apr 2017 12:22:39 +0200 Subject: [PATCH 294/407] Bumped version. As suggested the incompatibility resulting from https://github.com/cc65/cc65/commit/02daf9f8b5c1ae2267561ee05ce67b2d0393c12d makes a new version appropriate. --- src/common/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/version.c b/src/common/version.c index 4e61a5f83..bf0a6bf71 100644 --- a/src/common/version.c +++ b/src/common/version.c @@ -47,7 +47,7 @@ #define VER_MAJOR 2U -#define VER_MINOR 15U +#define VER_MINOR 16U From e43dbe1c24a14416b8a2802af17ecd237deef25d Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 6 Apr 2017 17:53:57 +0200 Subject: [PATCH 295/407] Just some white space fixes of recently contributed code. --- libsrc/common/strcat.s | 4 ++-- libsrc/common/strchr.s | 4 ++-- libsrc/common/strcspn.s | 5 ++--- libsrc/common/strncat.s | 2 -- libsrc/common/strspn.s | 5 ++--- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index 7dce2f78a..f9cd94633 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -21,7 +21,7 @@ _strcat: .else lda #0 sta ptr2 ; access from page start, y contains low byte -.endif +.endif stx ptr2+1 findEndOfDest: @@ -33,7 +33,7 @@ findEndOfDest: bne findEndOfDest endOfDestFound: - sty ptr2 ; advance pointer to last y position + sty ptr2 ; advance pointer to last y position ldy #0 ; reset new y-offset copyByte: diff --git a/libsrc/common/strchr.s b/libsrc/common/strchr.s index 15c743776..206b5160e 100644 --- a/libsrc/common/strchr.s +++ b/libsrc/common/strchr.s @@ -20,7 +20,7 @@ _strchr: .else lda #0 sta ptr1 ; access from page start, y contains low byte -.endif +.endif Loop: lda (ptr1),y ; Get next char beq EOS ; Jump on end of string @@ -29,7 +29,7 @@ Loop: lda (ptr1),y ; Get next char iny bne Loop inc ptr1+1 - bne Loop ; Branch always + bne Loop ; Branch always ; End of string. Check if we're searching for the terminating zero diff --git a/libsrc/common/strcspn.s b/libsrc/common/strcspn.s index 3f7b42ed1..c9122dc90 100644 --- a/libsrc/common/strcspn.s +++ b/libsrc/common/strcspn.s @@ -40,7 +40,7 @@ checkNext: check: cpy tmp1 ; compare with length of test character string beq endOfTestChars cmp (ptr1),y ; found matching char? - bne checkNext + bne checkNext leave: txa ; restore position of finding ldx tmp2 ; and return @@ -50,5 +50,4 @@ endOfTestChars: inx bne loadChar inc tmp2 - bne loadChar ; like bra... - + bne loadChar ; like bra... diff --git a/libsrc/common/strncat.s b/libsrc/common/strncat.s index e0fa39cc0..457e39e25 100644 --- a/libsrc/common/strncat.s +++ b/libsrc/common/strncat.s @@ -71,5 +71,3 @@ L6: lda #0 L7: lda ptr3 ldx ptr3+1 rts - - diff --git a/libsrc/common/strspn.s b/libsrc/common/strspn.s index 3316f0dab..079b935ee 100644 --- a/libsrc/common/strspn.s +++ b/libsrc/common/strspn.s @@ -40,15 +40,14 @@ checkNext: check: cpy tmp1 ; compare with length of test character string beq leave cmp (ptr1),y ; found matching char? - bne checkNext + bne checkNext foundTestChar: inx bne loadChar inc tmp2 - bne loadChar ; like bra... + bne loadChar ; like bra... leave: txa ; restore position of finding ldx tmp2 ; and return rts - \ No newline at end of file From 1aab28718915964b33ae87a70617966719364663 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Fri, 7 Apr 2017 09:26:58 -0400 Subject: [PATCH 296/407] Fixed the handling of "while (0) {}". It's a corner case; but, conditional macroes might create it -- better safe than sorry. --- src/cc65/stmt.c | 6 +-- test/val/while.c | 116 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 88 insertions(+), 34 deletions(-) diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index 84b516dc3..c6167fa78 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -273,9 +273,6 @@ static void WhileStatement (void) /* Remember the current position */ GetCodePos (&CondCodeStart); - /* Emit the code position label */ - g_defcodelabel (CondLabel); - /* Test the loop condition */ TestInParens (LoopLabel, 1); @@ -288,6 +285,9 @@ static void WhileStatement (void) /* Loop body */ Statement (&PendingToken); + /* Emit the while condition label */ + g_defcodelabel (CondLabel); + /* Move the test code here */ GetCodePos (&Here); MoveCode (&CondCodeStart, &CondCodeEnd, &Here); diff --git a/test/val/while.c b/test/val/while.c index cf2147052..b86b1fba5 100644 --- a/test/val/while.c +++ b/test/val/while.c @@ -1,53 +1,107 @@ /* - !!DESCRIPTION!! + !!DESCRIPTION!! while-condition tests !!ORIGIN!! SDCC regression tests !!LICENCE!! GPL, read COPYING.GPL */ #include <stdio.h> -#include <limits.h> -unsigned char success = 0; -unsigned char failures = 0; -unsigned char dummy = 0; +static unsigned char failures = 0x00; +static unsigned char achar0 = 0; -#ifdef SUPPORT_BIT_TYPES -bit bit0 = 0; -#endif -unsigned int aint0 = 0; -unsigned int aint1 = 0; -unsigned char achar0 = 0; -unsigned char achar1 = 0; - -void -done () -{ - dummy++; -} - -void +static void while1 (void) { unsigned char i = 10; - do - { - achar0++; - } - while (--i); + do { + ++achar0; + } while (--i); - if (achar0 != 10) - failures++; + if (achar0 != 10) { + failures |= 0x01; + } +} + +static void +while2 (void) +{ + unsigned char i = 10; + + achar0 = 0; + while (--i) { + ++achar0; + } + + if (achar0 != 10 - 1) { + failures |= 0x02; + } +} + +static void +while3 (void) +{ + achar0 = 0; + do { + if (++achar0 == (unsigned char)0) { + return; + } + } while (1); + + failures |= 0x04; +} + +static void +while4 (void) +{ + achar0 = 0; + while (1) { + if (++achar0 == (unsigned char)0) { + return; + } + } + + failures |= 0x08; +} + +static void +while5 (void) +{ + achar0 = 0; + do { + ++achar0; + } while (0); + + if (achar0 != 1) { + failures |= 0x10; + } +} + +static void +while6 (void) +{ + achar0 = 0; + while (0) { + ++achar0; + } + + if (achar0 != 1 - 1) { + failures |= 0x20; + } } int main (void) { while1 (); + while2 (); + while3 (); + while4 (); + while5 (); + while6 (); - success = failures; - done (); - printf("failures: %d\n",failures); - + if (failures) { + printf("failures: 0x%02X\n", failures); + } return failures; } From 18b0aaf9f20229812ad09b87684fe5bc7e06c319 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Sat, 15 Apr 2017 23:12:19 +0200 Subject: [PATCH 297/407] Removed help for non-existent option. --- src/ca65/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index 3c3daf7f7..fbca2beac 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -123,7 +123,6 @@ static void Usage (void) " --large-alignment\t\tDon't warn about large alignments\n" " --listing name\t\tCreate a listing file if assembly was ok\n" " --list-bytes n\t\tMaximum number of bytes per listing line\n" - " --macpack-dir dir\t\tSet a macro package directory\n" " --memory-model model\t\tSet the memory model\n" " --pagelength n\t\tSet the page length for the listing\n" " --relax-checks\t\tRelax some checks (see docs)\n" From 82e62209d696dcb082bd67e227dd5fe30256c776 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 1 May 2017 19:50:01 +0300 Subject: [PATCH 298/407] Document pragma trampoline --- doc/cc65.sgml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 24b37133e..99ddfc82d 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1209,6 +1209,31 @@ parameter with the <tt/#pragma/. The <tt/#pragma/ understands the push and pop parameters as explained above. +<sect1><tt>#pragma trampoline (<push&rt;, <name>, <value>)</tt><label id="pragma-trampoline"><p> + + This pragma sets a trampoline for functions. The name is either + a function returning void and taking no parameters, or the address + of an array in memory (for a RAM trampoline). The value is an + 8-bit number that's set to tmp4. + + The address of the function is passed in ptr4. + + This is useful for example with banked memory, to automatically + switch banks to where this function resides, and then restore + the bank when it returns. + + The <tt/#pragma/ requires the push and pop parameters as explained above. + + Example: + <tscreen><verb> + void mytrampoline(void); + + #pragma trampoline (push, mytrampoline, 0) + void somefunc(void); + #pragma trampoline (pop) + </verb></tscreen> + + <sect1><tt>#pragma warn (name, [push,] on|off)</tt><label id="pragma-warn"><p> Switch compiler warnings on or off. "name" is the name of a warning (see the From a84463a3dfb74b200fc208ab30f89de54631a846 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 1 May 2017 20:12:18 +0300 Subject: [PATCH 299/407] callptr4 --- libsrc/runtime/callptr4.s | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 libsrc/runtime/callptr4.s diff --git a/libsrc/runtime/callptr4.s b/libsrc/runtime/callptr4.s new file mode 100644 index 000000000..9a15609aa --- /dev/null +++ b/libsrc/runtime/callptr4.s @@ -0,0 +1,10 @@ +; +; CC65 runtime: call function via pointer in ptr4 +; + + .export callptr4 + .importzp ptr4 + +callptr4: + jmp (ptr4) ; jump there + From 679bfb0ae9353646e78a981941d525ea86b44e88 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 1 May 2017 20:46:06 +0300 Subject: [PATCH 300/407] Add IntPtrStack --- src/common/intptrstack.c | 90 +++++++++++++++++++++++++++++ src/common/intptrstack.h | 121 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+) create mode 100644 src/common/intptrstack.c create mode 100644 src/common/intptrstack.h diff --git a/src/common/intptrstack.c b/src/common/intptrstack.c new file mode 100644 index 000000000..de02c09e7 --- /dev/null +++ b/src/common/intptrstack.c @@ -0,0 +1,90 @@ +/*****************************************************************************/ +/* */ +/* intptrstack.c */ +/* */ +/* Integer+ptr stack used for program settings */ +/* */ +/* */ +/* */ +/* (C) 2017, Mega Cat Studios */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +/* common */ +#include "check.h" +#include "intptrstack.h" + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +void IPS_Get (const IntPtrStack* S, long *Val, void **Ptr) +/* Get the value on top of an int stack */ +{ + PRECONDITION (S->Count > 0); + if (Val) *Val = S->Stack[S->Count-1].val; + if (Ptr) *Ptr = S->Stack[S->Count-1].ptr; +} + + + +void IPS_Set (IntPtrStack* S, long Val, void *Ptr) +/* Set the value on top of an int stack */ +{ + PRECONDITION (S->Count > 0); + S->Stack[S->Count-1].val = Val; + S->Stack[S->Count-1].ptr = Ptr; +} + + + +void IPS_Drop (IntPtrStack* S) +/* Drop a value from an int stack */ +{ + PRECONDITION (S->Count > 0); + --S->Count; +} + + + +void IPS_Push (IntPtrStack* S, long Val, void *Ptr) +/* Push a value onto an int stack */ +{ + PRECONDITION (S->Count < sizeof (S->Stack) / sizeof (S->Stack[0])); + S->Stack[S->Count].val = Val; + S->Stack[S->Count++].ptr = Ptr; +} + + + +void IPS_Pop (IntPtrStack* S, long *Val, void **Ptr) +/* Pop a value from an int stack */ +{ + PRECONDITION (S->Count > 0); + if (Val) *Val = S->Stack[--S->Count].val; + if (Ptr) *Ptr = S->Stack[S->Count].ptr; +} diff --git a/src/common/intptrstack.h b/src/common/intptrstack.h new file mode 100644 index 000000000..a7b1c6683 --- /dev/null +++ b/src/common/intptrstack.h @@ -0,0 +1,121 @@ +/*****************************************************************************/ +/* */ +/* intptrstack.h */ +/* */ +/* Integer+ptr stack used for program settings */ +/* */ +/* */ +/* */ +/* (C) 2017, Mega Cat Studios */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef INTPTRSTACK_H +#define INTPTRSTACK_H + + + +#include "inline.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +typedef struct IntPtrStack IntPtrStack; +struct IntPtrInner { + long val; + void *ptr; +}; +struct IntPtrStack { + unsigned Count; + struct IntPtrInner Stack[8]; +}; + +/* An initializer for an empty int stack */ +#define STATIC_INTPTRSTACK_INITIALIZER { 0, { 0, 0 }, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} } } + +/* Declare an int stack with the given value as first element */ +#define INTPTRSTACK(Val, Ptr) { 1, { {Val, Ptr}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} } } + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +#if defined(HAVE_INLINE) +INLINE int IPS_IsFull (const IntPtrStack* S) +/* Return true if there is no space left on the given int stack */ +{ + return (S->Count >= sizeof (S->Stack) / sizeof (S->Stack[0])); +} +#else +# define IPS_IsFull(S) ((S)->Count >= sizeof ((S)->Stack) / sizeof ((S)->Stack[0])) +#endif + +#if defined(HAVE_INLINE) +INLINE int IPS_IsEmpty (const IntPtrStack* S) +/* Return true if there are no values on the given int stack */ +{ + return (S->Count == 0); +} +#else +# define IPS_IsEmpty(S) ((S)->Count == 0) +#endif + +#if defined(HAVE_INLINE) +INLINE unsigned IPS_GetCount (const IntPtrStack* S) +/* Return the number of elements on the given int stack */ +{ + return S->Count; +} +#else +# define IPS_GetCount(S) (S)->Count +#endif + +void IPS_Get (const IntPtrStack* S, long *Val, void **Ptr); +/* Get the value on top of an int stack */ + +void IPS_Set (IntPtrStack* S, long Val, void *Ptr); +/* Set the value on top of an int stack */ + +void IPS_Drop (IntPtrStack* S); +/* Drop a value from an int stack */ + +void IPS_Push (IntPtrStack* S, long Val, void *Ptr); +/* Push a value onto an int stack */ + +void IPS_Pop (IntPtrStack* S, long *Val, void **Ptr); +/* Pop a value from an int stack */ + + + +/* End of IntPtrStack.h */ + +#endif From d091a57e918244f0d6a7b651b908f7f08a2cee95 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 1 May 2017 21:00:28 +0300 Subject: [PATCH 301/407] Trampoline stack --- src/cc65/trampoline.c | 102 ++++++++++++++++++++++++++++++++++++++++++ src/cc65/trampoline.h | 65 +++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 src/cc65/trampoline.c create mode 100644 src/cc65/trampoline.h diff --git a/src/cc65/trampoline.c b/src/cc65/trampoline.c new file mode 100644 index 000000000..1f35a0f3c --- /dev/null +++ b/src/cc65/trampoline.c @@ -0,0 +1,102 @@ +/*****************************************************************************/ +/* */ +/* trampoline.c */ +/* */ +/* Trampoline management */ +/* */ +/* */ +/* */ +/* (C) 2017, Mega Cat Studios */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#include <stdarg.h> +#include <string.h> + +/* common */ +#include "chartype.h" +#include "check.h" +#include "coll.h" +#include "scanner.h" +#include "intptrstack.h" +#include "xmalloc.h" + +/* cc65 */ +#include "codeent.h" +#include "error.h" +#include "trampoline.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + +/* Trampolines */ +static IntPtrStack Trampolines; + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +void PushTrampoline (void *Ptr, unsigned char Val) +/* Push the current trampoline */ +{ + if (IPS_IsFull (&Trampolines)) { + Error ("Trampoline stack overflow"); + } else { + IPS_Push (&Trampolines, Val, Ptr); + } +} + + + +void PopTrampoline (void) +/* Remove the current trampoline */ +{ + if (IPS_GetCount (&Trampolines) < 1) { + Error ("Trampoline stack is empty"); + } else { + IPS_Drop (&Trampolines); + } +} + + + +void GetTrampoline (void **Ptr, unsigned char *Val) +/* Get the current trampoline */ +{ + if (IPS_GetCount (&Trampolines) < 1) { + *Ptr = NULL; + *Val = 0; + } else { + long Temp; + IPS_Get (&Trampolines, &Temp, Ptr); + *Val = Temp; + } +} diff --git a/src/cc65/trampoline.h b/src/cc65/trampoline.h new file mode 100644 index 000000000..f110bd42e --- /dev/null +++ b/src/cc65/trampoline.h @@ -0,0 +1,65 @@ +/*****************************************************************************/ +/* */ +/* trampoline.h */ +/* */ +/* Trampoline management */ +/* */ +/* */ +/* */ +/* (C) 2017, Mega Cat Studios */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef TRAMPOLINE_H +#define TRAMPOLINE_H + + + +#include <stdio.h> + +/* common */ +#include "attrib.h" + +/* cc65 */ +#include "opcodes.h" + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +void PushTrampoline (void *Ptr, unsigned char Val); +/* Push the current trampoline */ + +void PopTrampoline (void); +/* Pop the current trampoline */ + +void GetTrampoline (void **Ptr, unsigned char *Val); +/* Get the current trampoline, if any */ + + +/* End of trampoline.h */ + +#endif From 9c86c03a96e9885ac7aedd62b099ba43526aef4f Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 2 May 2017 18:48:31 +0300 Subject: [PATCH 302/407] Add test case --- test/val/trampoline.c | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/val/trampoline.c diff --git a/test/val/trampoline.c b/test/val/trampoline.c new file mode 100644 index 000000000..b5df1a22b --- /dev/null +++ b/test/val/trampoline.c @@ -0,0 +1,53 @@ +/* + !!DESCRIPTION!! trampoline pragma + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Lauri Kasanen +*/ + +static unsigned char flag; + +static void trampoline_set() { + asm("ldy tmp4"); + asm("sty %v", flag); + asm("jsr callptr4"); +} + +void trampoline_inc() { + asm("inc %v", flag); + asm("jsr callptr4"); +} + +void func3() { + +} + +unsigned char array[30]; +#pragma trampoline(push, array, 0) +#pragma trampoline(pop) + +#pragma trampoline(push, trampoline_inc, 0) + +void func2() { + func3(); +} + +#pragma trampoline(push, trampoline_set, 4) + +void func1(void); + +#pragma trampoline(pop) +#pragma trampoline(pop) + +void func1() { + func2(); +} + +int main(void) +{ + flag = 0; + + func1(); + + return flag == 5 ? 0 : 1; +} From 2890b3a810219ad512f9fdd2432811f94c0b121e Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 2 May 2017 19:06:19 +0300 Subject: [PATCH 303/407] Pragma trampoline --- src/cc65/declare.c | 21 +++++++++++ src/cc65/expr.c | 46 +++++++++++++++++++++++- src/cc65/funcdesc.c | 2 ++ src/cc65/funcdesc.h | 2 ++ src/cc65/pragma.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+), 1 deletion(-) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 7b543aa55..2ebc09b14 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -58,6 +58,7 @@ #include "scanner.h" #include "standard.h" #include "symtab.h" +#include "trampoline.h" #include "typeconv.h" @@ -1315,6 +1316,8 @@ static FuncDesc* ParseFuncDecl (void) { unsigned Offs; SymEntry* Sym; + SymEntry* Trampoline; + unsigned char TrampolineData; /* Create a new function descriptor */ FuncDesc* F = NewFuncDesc (); @@ -1380,6 +1383,13 @@ static FuncDesc* ParseFuncDecl (void) /* Leave the lexical level remembering the symbol tables */ RememberFunctionLevel (F); + /* Did we have a trampoline for this function? */ + GetTrampoline((void **) &Trampoline, &TrampolineData); + if (Trampoline) { + F->Trampoline = Trampoline; + F->TrampolineData = TrampolineData; + } + /* Return the function descriptor */ return F; } @@ -1447,6 +1457,7 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode) /* Function declaration */ FuncDesc* F; + SymEntry* PrevEntry; /* Skip the opening paren */ NextToken (); @@ -1460,6 +1471,16 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode) Qualifiers &= ~T_QUAL_FASTCALL; } + /* Was there a previous entry? If so, copy trampoline info from it */ + PrevEntry = FindGlobalSym (D->Ident); + if (PrevEntry && PrevEntry->Flags & SC_FUNC) { + FuncDesc* D = PrevEntry->V.F.Func; + if (D->Trampoline && !F->Trampoline) { + F->Trampoline = D->Trampoline; + F->TrampolineData = D->TrampolineData; + } + } + /* Add the function type. Be sure to bounds check the type buffer */ NeedTypeSpace (D, 1); D->Type[D->Index].C = T_FUNC | Qualifiers; diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 34cf550a2..fb1232fc1 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -536,6 +536,10 @@ static void FunctionCall (ExprDesc* Expr) /* Special handling for function pointers */ if (IsFuncPtr) { + if (Func->Trampoline) { + Warning("Calling a trampolined function via a pointer, trampoline will not be used"); + } + /* If the function is not a fastcall function, load the pointer to ** the function into the primary. */ @@ -584,7 +588,47 @@ static void FunctionCall (ExprDesc* Expr) } else { /* Normal function */ - g_call (TypeOf (Expr->Type), (const char*) Expr->Name, ParamSize); + if (Func->Trampoline) { + char tmp[64]; + StrBuf S = AUTO_STRBUF_INITIALIZER; + + /* Store the trampoline data in tmp4 */ + sprintf(tmp, "ldy #%u", Func->TrampolineData); + SB_AppendStr (&S, tmp); + g_asmcode (&S); + SB_Clear(&S); + + SB_AppendStr (&S, "sty tmp4"); + g_asmcode (&S); + SB_Clear(&S); + + /* Store the original function address in ptr4 */ + SB_AppendStr (&S, "ldy #<(_"); + SB_AppendStr (&S, (const char*) Expr->Name); + SB_AppendChar (&S, ')'); + g_asmcode (&S); + SB_Clear(&S); + + SB_AppendStr (&S, "sty ptr4"); + g_asmcode (&S); + SB_Clear(&S); + + SB_AppendStr (&S, "ldy #>(_"); + SB_AppendStr (&S, (const char*) Expr->Name); + SB_AppendChar (&S, ')'); + g_asmcode (&S); + SB_Clear(&S); + + SB_AppendStr (&S, "sty ptr4+1"); + g_asmcode (&S); + SB_Clear(&S); + + SB_Done (&S); + + g_call (TypeOf (Expr->Type), Func->Trampoline->Name, ParamSize); + } else { + g_call (TypeOf (Expr->Type), (const char*) Expr->Name, ParamSize); + } } diff --git a/src/cc65/funcdesc.c b/src/cc65/funcdesc.c index b9561a97c..607094acd 100644 --- a/src/cc65/funcdesc.c +++ b/src/cc65/funcdesc.c @@ -60,6 +60,8 @@ FuncDesc* NewFuncDesc (void) F->ParamCount = 0; F->ParamSize = 0; F->LastParam = 0; + F->Trampoline = 0; + F->TrampolineData = 0; /* Return the new struct */ return F; diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index b79c6a055..b83cfa362 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -67,6 +67,8 @@ struct FuncDesc { unsigned ParamCount; /* Number of parameters */ unsigned ParamSize; /* Size of the parameters */ struct SymEntry* LastParam; /* Pointer to last parameter */ + struct SymEntry* Trampoline; /* Pointer to the trampoline */ + unsigned char TrampolineData; /* The trampoline's user data */ }; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 707546e1d..c36811f35 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -51,6 +51,7 @@ #include "scanstrbuf.h" #include "symtab.h" #include "pragma.h" +#include "trampoline.h" @@ -87,6 +88,7 @@ typedef enum { PRAGMA_SIGNEDCHARS, /* obsolete */ PRAGMA_STATIC_LOCALS, PRAGMA_STATICLOCALS, /* obsolete */ + PRAGMA_TRAMPOLINE, PRAGMA_WARN, PRAGMA_WRITABLE_STRINGS, PRAGMA_ZPSYM, @@ -122,6 +124,7 @@ static const struct Pragma { { "signedchars", PRAGMA_SIGNEDCHARS }, /* obsolete */ { "static-locals", PRAGMA_STATIC_LOCALS }, { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ + { "trampoline", PRAGMA_TRAMPOLINE }, { "warn", PRAGMA_WARN }, { "writable-strings", PRAGMA_WRITABLE_STRINGS }, { "zpsym", PRAGMA_ZPSYM }, @@ -446,6 +449,84 @@ ExitPoint: } +static void TrampolinePragma (StrBuf* B) +/* Handle the trampoline pragma */ +{ + StrBuf S = AUTO_STRBUF_INITIALIZER; + const char *Name; + long Val; + SymEntry *Entry; + + /* Check for the "push" or "pop" keywords */ + switch (ParsePushPop (B)) { + + case PP_NONE: + Error ("Push or pop required"); + break; + + case PP_PUSH: + break; + + case PP_POP: + PopTrampoline(); + + /* Done */ + goto ExitPoint; + + case PP_ERROR: + /* Bail out */ + goto ExitPoint; + + default: + Internal ("Invalid result from ParsePushPop"); + + } + + /* A symbol argument must follow */ + if (!SB_GetSym (B, &S, NULL)) { + goto ExitPoint; + } + + /* Skip the following comma */ + if (!GetComma (B)) { + /* Error already flagged by GetComma */ + Error ("Value required for trampoline data"); + goto ExitPoint; + } + + if (!GetNumber (B, &Val)) { + Error ("Value required for trampoline data"); + goto ExitPoint; + } + + if (Val < 0 || Val > 255) { + Error ("Value must be between 0-255"); + goto ExitPoint; + } + + /* Get the string */ + Name = SB_GetConstBuf (&S); + Entry = FindSym(Name); + + /* Check if the name is valid */ + if (Entry && Entry->Flags & (SC_FUNC | SC_STORAGE)) { + + PushTrampoline(Entry, Val); + Entry->Flags |= SC_REF; + + } else { + + /* Segment name is invalid */ + Error ("Trampoline does not exist or is not a function or array"); + + } + +ExitPoint: + /* Call the string buf destructor */ + SB_Done (&S); +} + + static void CharMapPragma (StrBuf* B) /* Change the character map */ @@ -791,6 +872,10 @@ static void ParsePragma (void) FlagPragma (&B, &StaticLocals); break; + case PRAGMA_TRAMPOLINE: + TrampolinePragma(&B); + break; + case PRAGMA_WARN: WarnPragma (&B); break; From 767f093ff86604314a9ee42c25842c79905f3248 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sat, 6 May 2017 13:20:55 +0300 Subject: [PATCH 304/407] Add fast path for char postinc --- src/cc65/expr.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 34cf550a2..502fd7a8e 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1534,26 +1534,35 @@ static void PostInc (ExprDesc* Expr) /* Get the data type */ Flags = TypeOf (Expr->Type); - /* Push the address if needed */ - PushAddr (Expr); + /* Fast path: char */ + if ((Flags & CF_CHAR) == CF_CHAR && ED_GetLoc(Expr) & (E_LOC_GLOBAL | E_LOC_STATIC)) { - /* Fetch the value and save it (since it's the result of the expression) */ - LoadExpr (CF_NONE, Expr); - g_save (Flags | CF_FORCECHAR); + LoadExpr (CF_NONE, Expr); + AddCodeLine ("inc %s", ED_GetLabelName(Expr, 0)); - /* If we have a pointer expression, increment by the size of the type */ - if (IsTypePtr (Expr->Type)) { - g_inc (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1)); } else { - g_inc (Flags | CF_CONST | CF_FORCECHAR, 1); + + /* Push the address if needed */ + PushAddr (Expr); + + /* Fetch the value and save it (since it's the result of the expression) */ + LoadExpr (CF_NONE, Expr); + g_save (Flags | CF_FORCECHAR); + + /* If we have a pointer expression, increment by the size of the type */ + if (IsTypePtr (Expr->Type)) { + g_inc (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1)); + } else { + g_inc (Flags | CF_CONST | CF_FORCECHAR, 1); + } + + /* Store the result back */ + Store (Expr, 0); + + /* Restore the original value in the primary register */ + g_restore (Flags | CF_FORCECHAR); } - /* Store the result back */ - Store (Expr, 0); - - /* Restore the original value in the primary register */ - g_restore (Flags | CF_FORCECHAR); - /* The result is always an expression, no reference */ ED_MakeRValExpr (Expr); } From ead0338c0def811cb251090cc0851899a0cbdf8e Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sat, 6 May 2017 13:23:50 +0300 Subject: [PATCH 305/407] Add fast path for char postdec --- src/cc65/expr.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 502fd7a8e..e5c1a17b9 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1590,26 +1590,35 @@ static void PostDec (ExprDesc* Expr) /* Get the data type */ Flags = TypeOf (Expr->Type); - /* Push the address if needed */ - PushAddr (Expr); + /* Fast path: char */ + if ((Flags & CF_CHAR) == CF_CHAR && ED_GetLoc(Expr) & (E_LOC_GLOBAL | E_LOC_STATIC)) { - /* Fetch the value and save it (since it's the result of the expression) */ - LoadExpr (CF_NONE, Expr); - g_save (Flags | CF_FORCECHAR); + LoadExpr (CF_NONE, Expr); + AddCodeLine ("dec %s", ED_GetLabelName(Expr, 0)); - /* If we have a pointer expression, increment by the size of the type */ - if (IsTypePtr (Expr->Type)) { - g_dec (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1)); } else { - g_dec (Flags | CF_CONST | CF_FORCECHAR, 1); + + /* Push the address if needed */ + PushAddr (Expr); + + /* Fetch the value and save it (since it's the result of the expression) */ + LoadExpr (CF_NONE, Expr); + g_save (Flags | CF_FORCECHAR); + + /* If we have a pointer expression, increment by the size of the type */ + if (IsTypePtr (Expr->Type)) { + g_dec (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1)); + } else { + g_dec (Flags | CF_CONST | CF_FORCECHAR, 1); + } + + /* Store the result back */ + Store (Expr, 0); + + /* Restore the original value in the primary register */ + g_restore (Flags | CF_FORCECHAR); } - /* Store the result back */ - Store (Expr, 0); - - /* Restore the original value in the primary register */ - g_restore (Flags | CF_FORCECHAR); - /* The result is always an expression, no reference */ ED_MakeRValExpr (Expr); } From a2f61c667ab49cd99632cbd958ef79057d80ac77 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sun, 7 May 2017 20:31:41 +0300 Subject: [PATCH 306/407] Update comments and location checks according to Greg --- src/cc65/expr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index e5c1a17b9..e87b02ffc 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1534,8 +1534,8 @@ static void PostInc (ExprDesc* Expr) /* Get the data type */ Flags = TypeOf (Expr->Type); - /* Fast path: char */ - if ((Flags & CF_CHAR) == CF_CHAR && ED_GetLoc(Expr) & (E_LOC_GLOBAL | E_LOC_STATIC)) { + /* Emit smaller code if a char variable is at a constant location */ + if ((Flags & CF_CHAR) == CF_CHAR && ED_IsLocConst(Expr)) { LoadExpr (CF_NONE, Expr); AddCodeLine ("inc %s", ED_GetLabelName(Expr, 0)); @@ -1590,8 +1590,8 @@ static void PostDec (ExprDesc* Expr) /* Get the data type */ Flags = TypeOf (Expr->Type); - /* Fast path: char */ - if ((Flags & CF_CHAR) == CF_CHAR && ED_GetLoc(Expr) & (E_LOC_GLOBAL | E_LOC_STATIC)) { + /* Emit smaller code if a char variable is at a constant location */ + if ((Flags & CF_CHAR) == CF_CHAR && ED_IsLocConst(Expr)) { LoadExpr (CF_NONE, Expr); AddCodeLine ("dec %s", ED_GetLabelName(Expr, 0)); From 7adcde1707eb7ab81bc1f15099ad91276f0f11eb Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sun, 7 May 2017 20:35:49 +0300 Subject: [PATCH 307/407] Add explicit postinc/dec testcase --- test/val/postincdec.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/val/postincdec.c diff --git a/test/val/postincdec.c b/test/val/postincdec.c new file mode 100644 index 000000000..19a6eb2a7 --- /dev/null +++ b/test/val/postincdec.c @@ -0,0 +1,23 @@ +/* + !!DESCRIPTION!! char-sized post-increment and -decrement + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Lauri Kasanen +*/ + + +static unsigned char val, array[2]; + +int main() { + + val = 0; + array[0] = array[1] = 10; + + array[val++] = 2; + array[val++] = 2; + --val; + array[val--] = 0; + array[val--] = 0; + + return (array[0] == array[1] && array[0] == 0) ? 0 : 1; +} From 077b14ccfa5f8b4defc2f98b01cf17e0f2a70922 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Mon, 8 May 2017 10:19:26 +0300 Subject: [PATCH 308/407] test/val/postincdec: Test for the final val value --- test/val/postincdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/val/postincdec.c b/test/val/postincdec.c index 19a6eb2a7..6d3e9593c 100644 --- a/test/val/postincdec.c +++ b/test/val/postincdec.c @@ -19,5 +19,5 @@ int main() { array[val--] = 0; array[val--] = 0; - return (array[0] == array[1] && array[0] == 0) ? 0 : 1; + return (array[0] == array[1] && array[0] == 0 && val == 0xff) ? 0 : 1; } From 4cbfb4e199bf019c0f4c917c6c189fe93867a05a Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Fri, 12 May 2017 12:19:40 +0200 Subject: [PATCH 309/407] added -E switch to cl65 for >>stop after the preprocessing stage<<. added compilation and assemblation disable after -Wc -E also with -E beeing part of a comma separated list of arguments --- src/cl65/main.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 7bdbe7a8a..58a1fe0c2 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -706,6 +706,7 @@ static void Usage (void) " -C name\t\t\tUse linker config file\n" " -Cl\t\t\t\tMake local variables static\n" " -D sym[=defn]\t\t\tDefine a preprocessor symbol\n" + " -E Stop after the preprocessing stage\n" " -I dir\t\t\tSet a compiler include directory path\n" " -L path\t\t\tSpecify a library search path\n" " -Ln name\t\t\tCreate a VICE label file\n" @@ -1411,14 +1412,41 @@ int main (int argc, char* argv []) /* Print version number */ OptVersion (Arg, 0); break; - + + case 'E': + /*Forward -E to compiler*/ + CmdAddArg (&CC65, Arg); + DoAssemble = 0; + DoLink = 0; + break; case 'W': if (Arg[2] == 'a' && Arg[3] == '\0') { /* -Wa: Pass options to assembler */ OptAsmArgs (Arg, GetArg (&I, 3)); - } else if (Arg[2] == 'c' && Arg[3] == '\0') { + } + else if (Arg[2] == 'c' && Arg[3] == '\0') { /* -Wc: Pass options to compiler */ - OptCCArgs (Arg, GetArg (&I, 3)); + + /* Get argument succeeding -Wc switch */ + const char* WcSubArgs = GetArg (&I, 3); + + /* Remember -Wc sub arguments in cc65 arg struct */ + OptCCArgs (Arg, WcSubArgs); + /* Check for isolated -E switch given after -Wc*/ + if (!strcmp("-E", WcSubArgs)){ + /*If both -Wc and -E given, then prevent assembling + and linking */ + DoAssemble = 0; + DoLink = 0; + }else{ + /* Check for -E beeing part of comma separated arg + list given after -Wc*/ + if ( (NULL!=strstr(WcSubArgs, "-E,")) || + (NULL!=strstr(WcSubArgs, ",-E"))){ + DoAssemble = 0; + DoLink = 0; + } + } } else if (Arg[2] == 'l' && Arg[3] == '\0') { /* -Wl: Pass options to linker */ OptLdArgs (Arg, GetArg (&I, 3)); From 691df09a1f4a6b0f95b0d6eb7fd7320eb28df2b6 Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Tue, 16 May 2017 13:13:09 +0200 Subject: [PATCH 310/407] According to recent comments on my recent pull request, -Wc checking for -E flag has been removed again. Intead, -E flag has been added to cl65 without need of -Wc. Two functions have been introduced to disable compile, link or both. These function remove assigment repetions to DoAssemble and DoLink for litte overhead, having the maintainability in mind. --- src/cl65/main.c | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 58a1fe0c2..2172700ae 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -156,7 +156,21 @@ static char* TargetLib = 0; # endif #endif +/*****************************************************************************/ +/* Credential functions */ +/*****************************************************************************/ +void DisableAssembling(void){ + DoAssemble = 0; +} +void DisableLinking(void){ + DoLink = 0; +} + +void DisableAssemblingAndLinking(void){ + DisableAssembling(); + DisableLinking(); +} /*****************************************************************************/ /* Command structure handling */ @@ -1399,8 +1413,7 @@ int main (int argc, char* argv []) case 'S': /* Dont assemble and link the created files */ - DoAssemble = 0; - DoLink = 0; + DisableAssemblingAndLinking(); break; case 'T': @@ -1416,37 +1429,16 @@ int main (int argc, char* argv []) case 'E': /*Forward -E to compiler*/ CmdAddArg (&CC65, Arg); - DoAssemble = 0; - DoLink = 0; + DisableAssemblingAndLinking(); break; case 'W': if (Arg[2] == 'a' && Arg[3] == '\0') { /* -Wa: Pass options to assembler */ OptAsmArgs (Arg, GetArg (&I, 3)); - } - else if (Arg[2] == 'c' && Arg[3] == '\0') { + } else if (Arg[2] == 'c' && Arg[3] == '\0') { /* -Wc: Pass options to compiler */ - - /* Get argument succeeding -Wc switch */ - const char* WcSubArgs = GetArg (&I, 3); - /* Remember -Wc sub arguments in cc65 arg struct */ - OptCCArgs (Arg, WcSubArgs); - /* Check for isolated -E switch given after -Wc*/ - if (!strcmp("-E", WcSubArgs)){ - /*If both -Wc and -E given, then prevent assembling - and linking */ - DoAssemble = 0; - DoLink = 0; - }else{ - /* Check for -E beeing part of comma separated arg - list given after -Wc*/ - if ( (NULL!=strstr(WcSubArgs, "-E,")) || - (NULL!=strstr(WcSubArgs, ",-E"))){ - DoAssemble = 0; - DoLink = 0; - } - } + OptCCArgs (Arg, GetArg (&I, 3)); } else if (Arg[2] == 'l' && Arg[3] == '\0') { /* -Wl: Pass options to linker */ OptLdArgs (Arg, GetArg (&I, 3)); @@ -1458,7 +1450,7 @@ int main (int argc, char* argv []) case 'c': /* Don't link the resulting files */ - DoLink = 0; + DisableLinking(); break; case 'd': From d70a9507a7c731e9b95dd615328df975a3cff58c Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Tue, 16 May 2017 13:31:10 +0200 Subject: [PATCH 311/407] replaced tabs with spaces which accidently were introduced. --- src/cl65/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 2172700ae..e428c96ac 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -157,19 +157,19 @@ static char* TargetLib = 0; #endif /*****************************************************************************/ -/* Credential functions */ +/* Credential functions */ /*****************************************************************************/ void DisableAssembling(void){ - DoAssemble = 0; + DoAssemble = 0; } void DisableLinking(void){ - DoLink = 0; + DoLink = 0; } void DisableAssemblingAndLinking(void){ - DisableAssembling(); - DisableLinking(); + DisableAssembling(); + DisableLinking(); } /*****************************************************************************/ From ca41af41c2d555355ea45dd0c83a5fa3508ddd1a Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 16 May 2017 20:10:24 +0300 Subject: [PATCH 312/407] Rename pragma trampoline to wrapped-call, value to identifier --- doc/cc65.sgml | 50 +++++++++++++++++++++---------------------- src/cc65/pragma.c | 20 ++++++++--------- test/val/trampoline.c | 12 +++++------ 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 99ddfc82d..a9b88c2b4 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1209,31 +1209,6 @@ parameter with the <tt/#pragma/. The <tt/#pragma/ understands the push and pop parameters as explained above. -<sect1><tt>#pragma trampoline (<push&rt;, <name>, <value>)</tt><label id="pragma-trampoline"><p> - - This pragma sets a trampoline for functions. The name is either - a function returning void and taking no parameters, or the address - of an array in memory (for a RAM trampoline). The value is an - 8-bit number that's set to tmp4. - - The address of the function is passed in ptr4. - - This is useful for example with banked memory, to automatically - switch banks to where this function resides, and then restore - the bank when it returns. - - The <tt/#pragma/ requires the push and pop parameters as explained above. - - Example: - <tscreen><verb> - void mytrampoline(void); - - #pragma trampoline (push, mytrampoline, 0) - void somefunc(void); - #pragma trampoline (pop) - </verb></tscreen> - - <sect1><tt>#pragma warn (name, [push,] on|off)</tt><label id="pragma-warn"><p> Switch compiler warnings on or off. "name" is the name of a warning (see the @@ -1254,6 +1229,31 @@ parameter with the <tt/#pragma/. </verb></tscreen> +<sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-trampoline"><p> + + This pragma sets a wrapper for functions, often used for trampolines. + The name is either a function returning void and taking no parameters, + or the address of an array in memory (for a RAM trampoline). The identifier + is an 8-bit number that's set to tmp4. + + The address of the function is passed in ptr4. + + This is useful for example with banked memory, to automatically + switch banks to where this function resides, and then restore + the bank when it returns. + + The <tt/#pragma/ requires the push and pop parameters as explained above. + + Example: + <tscreen><verb> + void mytrampoline(void); + + #pragma wrapped-call (push, mytrampoline, 0) + void somefunc(void); + #pragma wrapped-call (pop) + </verb></tscreen> + + <sect1><tt>#pragma writable-strings ([push,] on|off)</tt><label id="pragma-writable-strings"><p> Changes the storage location of string literals. For historical reasons, diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index c36811f35..6ec2df3a3 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -88,8 +88,8 @@ typedef enum { PRAGMA_SIGNEDCHARS, /* obsolete */ PRAGMA_STATIC_LOCALS, PRAGMA_STATICLOCALS, /* obsolete */ - PRAGMA_TRAMPOLINE, PRAGMA_WARN, + PRAGMA_WRAPPED_CALL, PRAGMA_WRITABLE_STRINGS, PRAGMA_ZPSYM, PRAGMA_COUNT @@ -124,8 +124,8 @@ static const struct Pragma { { "signedchars", PRAGMA_SIGNEDCHARS }, /* obsolete */ { "static-locals", PRAGMA_STATIC_LOCALS }, { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ - { "trampoline", PRAGMA_TRAMPOLINE }, { "warn", PRAGMA_WARN }, + { "wrapped-call", PRAGMA_WRAPPED_CALL }, { "writable-strings", PRAGMA_WRITABLE_STRINGS }, { "zpsym", PRAGMA_ZPSYM }, }; @@ -449,8 +449,8 @@ ExitPoint: } -static void TrampolinePragma (StrBuf* B) -/* Handle the trampoline pragma */ +static void WrappedCallPragma (StrBuf* B) +/* Handle the wrapped-call pragma */ { StrBuf S = AUTO_STRBUF_INITIALIZER; const char *Name; @@ -490,17 +490,17 @@ static void TrampolinePragma (StrBuf* B) /* Skip the following comma */ if (!GetComma (B)) { /* Error already flagged by GetComma */ - Error ("Value required for trampoline data"); + Error ("Value required for wrapped-call identifier"); goto ExitPoint; } if (!GetNumber (B, &Val)) { - Error ("Value required for trampoline data"); + Error ("Value required for wrapped-call identifier"); goto ExitPoint; } if (Val < 0 || Val > 255) { - Error ("Value must be between 0-255"); + Error ("Identifier must be between 0-255"); goto ExitPoint; } @@ -517,7 +517,7 @@ static void TrampolinePragma (StrBuf* B) } else { /* Segment name is invalid */ - Error ("Trampoline does not exist or is not a function or array"); + Error ("Wrapped-call target does not exist or is not a function or array"); } @@ -872,8 +872,8 @@ static void ParsePragma (void) FlagPragma (&B, &StaticLocals); break; - case PRAGMA_TRAMPOLINE: - TrampolinePragma(&B); + case PRAGMA_WRAPPED_CALL: + WrappedCallPragma(&B); break; case PRAGMA_WARN: diff --git a/test/val/trampoline.c b/test/val/trampoline.c index b5df1a22b..aad4c96ea 100644 --- a/test/val/trampoline.c +++ b/test/val/trampoline.c @@ -23,21 +23,21 @@ void func3() { } unsigned char array[30]; -#pragma trampoline(push, array, 0) -#pragma trampoline(pop) +#pragma wrapped-call(push, array, 0) +#pragma wrapped-call(pop) -#pragma trampoline(push, trampoline_inc, 0) +#pragma wrapped-call(push, trampoline_inc, 0) void func2() { func3(); } -#pragma trampoline(push, trampoline_set, 4) +#pragma wrapped-call(push, trampoline_set, 4) void func1(void); -#pragma trampoline(pop) -#pragma trampoline(pop) +#pragma wrapped-call(pop) +#pragma wrapped-call(pop) void func1() { func2(); From ac7a0e21ac0211df2594dff303da973e88a4faee Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 16 May 2017 20:14:19 +0300 Subject: [PATCH 313/407] Correct missed doc label --- doc/cc65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index a9b88c2b4..d87fa47a7 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1229,7 +1229,7 @@ parameter with the <tt/#pragma/. </verb></tscreen> -<sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-trampoline"><p> +<sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p> This pragma sets a wrapper for functions, often used for trampolines. The name is either a function returning void and taking no parameters, From 6011bdb2f63c86424fbd6e321d3eee3408b61b62 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Wed, 17 May 2017 10:00:35 +0200 Subject: [PATCH 314/407] Optimize the inlined strlen. --- src/cc65/stdfunc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 7a0450146..f658f0dcb 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -1245,9 +1245,8 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("ldy #$FF"); g_defcodelabel (L); AddCodeLine ("iny"); - AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg, 0)); + AddCodeLine ("ldx %s,y", ED_GetLabelName (&Arg, 0)); AddCodeLine ("bne %s", LocalLabelName (L)); - AddCodeLine ("tax"); AddCodeLine ("tya"); /* The function result is an rvalue in the primary register */ From 675dd3c9637e0f4a73ae549fefa4e312b8c4bbf5 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Wed, 17 May 2017 10:08:08 +0200 Subject: [PATCH 315/407] Optimize the inlined memcpy/memset for the sizes of 128/129. --- src/cc65/stdfunc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index f658f0dcb..2d4317ef8 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -284,7 +284,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 129) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); g_defcodelabel (Label); @@ -355,7 +355,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { + if (Arg3.Expr.IVal <= 129 && !AllowOneIndex) { if (Offs == 0) { AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); @@ -433,7 +433,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { + if (Arg3.Expr.IVal <= 129 && !AllowOneIndex) { if (Offs == 0) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); @@ -499,7 +499,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Generate memcpy code */ AddCodeLine ("sta ptr1"); AddCodeLine ("stx ptr1+1"); - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 129) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); g_defcodelabel (Label); AddCodeLine ("lda (sp),y"); @@ -635,7 +635,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memset code */ - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 129) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); @@ -720,7 +720,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Generate code */ AddCodeLine ("sta ptr1"); AddCodeLine ("stx ptr1+1"); - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 129) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); g_defcodelabel (Label); From 298dda0e71646112f0d0a57146acbb3a62a145fd Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 17 May 2017 18:30:12 +0200 Subject: [PATCH 316/407] Increased GCC optimization level. --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index f4f29b949..3ce4b676a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -62,7 +62,7 @@ else endif endif -CFLAGS += -MMD -MP -O -I common \ +CFLAGS += -MMD -MP -O3 -I common \ -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \ -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) -DCL65_TGT=$(CL65_TGT) \ -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) \ From f151142e6a9935f53fb36b5c54d1031572f50d0c Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 17 May 2017 19:39:02 +0200 Subject: [PATCH 317/407] Keep GCC from complaining about 'List' may be used uninitialized in this function. --- src/ca65/pseudo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index b44c28dd8..f84f21d7f 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -1388,7 +1388,7 @@ static void DoList (void) /* Enable/disable the listing */ { /* Get the setting */ - unsigned char List; + unsigned char List = 0; SetBoolOption (&List); /* Manage the counter */ From 73f1c0e11d0162b1dbad8e1ef21a9f90f4c4f032 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Wed, 17 May 2017 20:56:21 +0200 Subject: [PATCH 318/407] Migrate 'encrypted variables' variables to 'repository settings'. The GitHub token used for GitHub Pages deployment was revoked (see https://blog.travis-ci.com/2017-05-08-security-advisory) so I took the opportunity to make use of the "new" repository settings feature instead of fiddling with variable encryption again. --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd2672887..c84eb0cc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,3 @@ script: - make doc zip after_success: - make -f Makefile.travis -env: - global: - - secure: "h+hoQdEHGPLNwaqGKmSaM8NBRDLc2X+W05VsnNG2Feq/wPv/AiBjONNlzN7jRf6D6f3aoPXaQ2Lc3bYWdxGvFRCmwiofdxkJI9n5L8HPHLZ2lf37MQsXmGJzoTFOvjPLj73H6HlbI9Ux0El3zO6hvalxiXj6TfoZ41dbhNyvpYk=" - - secure: "A4hMEe5RRfUtYjFGbT7QAvT1Tyo434N+/TiuQeQ4q0L46c79LnXuGQzbFLOFZshZiplLkJr7lFg466CoI1bf2L0cQOew/LesMhE75v0HQ7tZnExWhdpAk0ri6nWixbjn/dmQ0+HxjzJ48A44DMMBYcvSIsO4vflvuJ8etfSg42k=" From c6cab0bb2747d26e710a0c048b74a3475d070df5 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Thu, 18 May 2017 12:59:03 +0200 Subject: [PATCH 319/407] VIC's kernal does not support CTRL+[ --- doc/vic20.sgml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/vic20.sgml b/doc/vic20.sgml index b1a08ac83..889cc266e 100644 --- a/doc/vic20.sgml +++ b/doc/vic20.sgml @@ -2,11 +2,11 @@ <article> -<title>Commodore VIC20 (aka VC20) specific information for cc65 +<title>Commodore VIC20 (aka VC20 aka VIC1001) specific information for cc65 <author> <url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal"> -<date>2014-04-12 +<date>2017-05-18 <abstract> An overview over the VIC20 runtime system as it is implemented for the cc65 C @@ -188,7 +188,7 @@ No VIC1011 drivers are currently available for the VIC20. <sect1>Escape code<p> -For an Esc, press CTRL and the <tt/[/ key. +For an Esc, pressing CTRL and the <tt/[/ key is not supported. <sect1>Passing arguments to the program<p> @@ -219,8 +219,7 @@ The program return code (low byte) is passed back to BASIC by use of the <sect1>Using extended memory<p> -The extended memory at $A000 may be added to the heap by using the following -code: +BLK5 memory may be added to the heap by using the following code: <tscreen><verb> /* Check for the existence of RAM */ From a590b99f5be4af391811d0e79520ea07852b763f Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 14:21:43 +0300 Subject: [PATCH 320/407] Align with spaces instead of tabs here --- src/cc65/pragma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 6ec2df3a3..27015285e 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -125,7 +125,7 @@ static const struct Pragma { { "static-locals", PRAGMA_STATIC_LOCALS }, { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ { "warn", PRAGMA_WARN }, - { "wrapped-call", PRAGMA_WRAPPED_CALL }, + { "wrapped-call", PRAGMA_WRAPPED_CALL }, { "writable-strings", PRAGMA_WRITABLE_STRINGS }, { "zpsym", PRAGMA_ZPSYM }, }; From 7feced88627dc3f07fe1580e80670c234bd0a984 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 15:54:47 +0300 Subject: [PATCH 321/407] More tabs to spaces --- src/cc65/pragma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 27015285e..fe7101d97 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -125,7 +125,7 @@ static const struct Pragma { { "static-locals", PRAGMA_STATIC_LOCALS }, { "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */ { "warn", PRAGMA_WARN }, - { "wrapped-call", PRAGMA_WRAPPED_CALL }, + { "wrapped-call", PRAGMA_WRAPPED_CALL }, { "writable-strings", PRAGMA_WRITABLE_STRINGS }, { "zpsym", PRAGMA_ZPSYM }, }; From f6fa74a6367f6aa8f803c867c61be9f6071bb614 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 16:00:04 +0300 Subject: [PATCH 322/407] Rename trampoline to wrappedcall everywhere --- src/cc65/declare.c | 24 +++++++-------- src/cc65/expr.c | 12 ++++---- src/cc65/funcdesc.c | 4 +-- src/cc65/funcdesc.h | 4 +-- src/cc65/pragma.c | 6 ++-- src/cc65/{trampoline.c => wrappedcall.c} | 38 ++++++++++++------------ src/cc65/{trampoline.h => wrappedcall.h} | 22 +++++++------- 7 files changed, 55 insertions(+), 55 deletions(-) rename src/cc65/{trampoline.c => wrappedcall.c} (79%) rename src/cc65/{trampoline.h => wrappedcall.h} (85%) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 2ebc09b14..a6b232905 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -58,7 +58,7 @@ #include "scanner.h" #include "standard.h" #include "symtab.h" -#include "trampoline.h" +#include "wrappedcall.h" #include "typeconv.h" @@ -1316,8 +1316,8 @@ static FuncDesc* ParseFuncDecl (void) { unsigned Offs; SymEntry* Sym; - SymEntry* Trampoline; - unsigned char TrampolineData; + SymEntry* WrappedCall; + unsigned char WrappedCallData; /* Create a new function descriptor */ FuncDesc* F = NewFuncDesc (); @@ -1383,11 +1383,11 @@ static FuncDesc* ParseFuncDecl (void) /* Leave the lexical level remembering the symbol tables */ RememberFunctionLevel (F); - /* Did we have a trampoline for this function? */ - GetTrampoline((void **) &Trampoline, &TrampolineData); - if (Trampoline) { - F->Trampoline = Trampoline; - F->TrampolineData = TrampolineData; + /* Did we have a WrappedCall for this function? */ + GetWrappedCall((void **) &WrappedCall, &WrappedCallData); + if (WrappedCall) { + F->WrappedCall = WrappedCall; + F->WrappedCallData = WrappedCallData; } /* Return the function descriptor */ @@ -1471,13 +1471,13 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode) Qualifiers &= ~T_QUAL_FASTCALL; } - /* Was there a previous entry? If so, copy trampoline info from it */ + /* Was there a previous entry? If so, copy WrappedCall info from it */ PrevEntry = FindGlobalSym (D->Ident); if (PrevEntry && PrevEntry->Flags & SC_FUNC) { FuncDesc* D = PrevEntry->V.F.Func; - if (D->Trampoline && !F->Trampoline) { - F->Trampoline = D->Trampoline; - F->TrampolineData = D->TrampolineData; + if (D->WrappedCall && !F->WrappedCall) { + F->WrappedCall = D->WrappedCall; + F->WrappedCallData = D->WrappedCallData; } } diff --git a/src/cc65/expr.c b/src/cc65/expr.c index fb1232fc1..467c30da2 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -536,8 +536,8 @@ static void FunctionCall (ExprDesc* Expr) /* Special handling for function pointers */ if (IsFuncPtr) { - if (Func->Trampoline) { - Warning("Calling a trampolined function via a pointer, trampoline will not be used"); + if (Func->WrappedCall) { + Warning("Calling a wrapped function via a pointer, wrapped-call will not be used"); } /* If the function is not a fastcall function, load the pointer to @@ -588,12 +588,12 @@ static void FunctionCall (ExprDesc* Expr) } else { /* Normal function */ - if (Func->Trampoline) { + if (Func->WrappedCall) { char tmp[64]; StrBuf S = AUTO_STRBUF_INITIALIZER; - /* Store the trampoline data in tmp4 */ - sprintf(tmp, "ldy #%u", Func->TrampolineData); + /* Store the WrappedCall data in tmp4 */ + sprintf(tmp, "ldy #%u", Func->WrappedCallData); SB_AppendStr (&S, tmp); g_asmcode (&S); SB_Clear(&S); @@ -625,7 +625,7 @@ static void FunctionCall (ExprDesc* Expr) SB_Done (&S); - g_call (TypeOf (Expr->Type), Func->Trampoline->Name, ParamSize); + g_call (TypeOf (Expr->Type), Func->WrappedCall->Name, ParamSize); } else { g_call (TypeOf (Expr->Type), (const char*) Expr->Name, ParamSize); } diff --git a/src/cc65/funcdesc.c b/src/cc65/funcdesc.c index 607094acd..273263dec 100644 --- a/src/cc65/funcdesc.c +++ b/src/cc65/funcdesc.c @@ -60,8 +60,8 @@ FuncDesc* NewFuncDesc (void) F->ParamCount = 0; F->ParamSize = 0; F->LastParam = 0; - F->Trampoline = 0; - F->TrampolineData = 0; + F->WrappedCall = 0; + F->WrappedCallData = 0; /* Return the new struct */ return F; diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index b83cfa362..966aff573 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -67,8 +67,8 @@ struct FuncDesc { unsigned ParamCount; /* Number of parameters */ unsigned ParamSize; /* Size of the parameters */ struct SymEntry* LastParam; /* Pointer to last parameter */ - struct SymEntry* Trampoline; /* Pointer to the trampoline */ - unsigned char TrampolineData; /* The trampoline's user data */ + struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ + unsigned char WrappedCallData; /* The WrappedCall's user data */ }; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index fe7101d97..98f1a20d0 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -51,7 +51,7 @@ #include "scanstrbuf.h" #include "symtab.h" #include "pragma.h" -#include "trampoline.h" +#include "wrappedcall.h" @@ -468,7 +468,7 @@ static void WrappedCallPragma (StrBuf* B) break; case PP_POP: - PopTrampoline(); + PopWrappedCall(); /* Done */ goto ExitPoint; @@ -511,7 +511,7 @@ static void WrappedCallPragma (StrBuf* B) /* Check if the name is valid */ if (Entry && Entry->Flags & (SC_FUNC | SC_STORAGE)) { - PushTrampoline(Entry, Val); + PushWrappedCall(Entry, Val); Entry->Flags |= SC_REF; } else { diff --git a/src/cc65/trampoline.c b/src/cc65/wrappedcall.c similarity index 79% rename from src/cc65/trampoline.c rename to src/cc65/wrappedcall.c index 1f35a0f3c..2d11245fd 100644 --- a/src/cc65/trampoline.c +++ b/src/cc65/wrappedcall.c @@ -1,8 +1,8 @@ /*****************************************************************************/ /* */ -/* trampoline.c */ +/* wrappedcall.c */ /* */ -/* Trampoline management */ +/* WrappedCall management */ /* */ /* */ /* */ @@ -44,7 +44,7 @@ /* cc65 */ #include "codeent.h" #include "error.h" -#include "trampoline.h" +#include "wrappedcall.h" @@ -53,8 +53,8 @@ /*****************************************************************************/ -/* Trampolines */ -static IntPtrStack Trampolines; +/* WrappedCalls */ +static IntPtrStack WrappedCalls; @@ -64,39 +64,39 @@ static IntPtrStack Trampolines; -void PushTrampoline (void *Ptr, unsigned char Val) -/* Push the current trampoline */ +void PushWrappedCall (void *Ptr, unsigned char Val) +/* Push the current WrappedCall */ { - if (IPS_IsFull (&Trampolines)) { - Error ("Trampoline stack overflow"); + if (IPS_IsFull (&WrappedCalls)) { + Error ("WrappedCall stack overflow"); } else { - IPS_Push (&Trampolines, Val, Ptr); + IPS_Push (&WrappedCalls, Val, Ptr); } } -void PopTrampoline (void) -/* Remove the current trampoline */ +void PopWrappedCall (void) +/* Remove the current WrappedCall */ { - if (IPS_GetCount (&Trampolines) < 1) { - Error ("Trampoline stack is empty"); + if (IPS_GetCount (&WrappedCalls) < 1) { + Error ("WrappedCall stack is empty"); } else { - IPS_Drop (&Trampolines); + IPS_Drop (&WrappedCalls); } } -void GetTrampoline (void **Ptr, unsigned char *Val) -/* Get the current trampoline */ +void GetWrappedCall (void **Ptr, unsigned char *Val) +/* Get the current WrappedCall */ { - if (IPS_GetCount (&Trampolines) < 1) { + if (IPS_GetCount (&WrappedCalls) < 1) { *Ptr = NULL; *Val = 0; } else { long Temp; - IPS_Get (&Trampolines, &Temp, Ptr); + IPS_Get (&WrappedCalls, &Temp, Ptr); *Val = Temp; } } diff --git a/src/cc65/trampoline.h b/src/cc65/wrappedcall.h similarity index 85% rename from src/cc65/trampoline.h rename to src/cc65/wrappedcall.h index f110bd42e..3517c2465 100644 --- a/src/cc65/trampoline.h +++ b/src/cc65/wrappedcall.h @@ -1,8 +1,8 @@ /*****************************************************************************/ /* */ -/* trampoline.h */ +/* wrappedcall.h */ /* */ -/* Trampoline management */ +/* Wrapped-call management */ /* */ /* */ /* */ @@ -30,8 +30,8 @@ -#ifndef TRAMPOLINE_H -#define TRAMPOLINE_H +#ifndef WRAPPEDCALL_H +#define WRAPPEDCALL_H @@ -50,16 +50,16 @@ -void PushTrampoline (void *Ptr, unsigned char Val); -/* Push the current trampoline */ +void PushWrappedCall (void *Ptr, unsigned char Val); +/* Push the current WrappedCall */ -void PopTrampoline (void); -/* Pop the current trampoline */ +void PopWrappedCall (void); +/* Pop the current WrappedCall */ -void GetTrampoline (void **Ptr, unsigned char *Val); -/* Get the current trampoline, if any */ +void GetWrappedCall (void **Ptr, unsigned char *Val); +/* Get the current WrappedCall, if any */ -/* End of trampoline.h */ +/* End of wrappedcall.h */ #endif From 4c05c46cd15ade6c282bb4bf51686a07bf0b4ca3 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 16:11:39 +0300 Subject: [PATCH 323/407] Remove RAM-trampoline array support --- doc/cc65.sgml | 5 ++--- src/cc65/pragma.c | 2 +- test/val/trampoline.c | 4 ---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index d87fa47a7..2e480e4c3 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1232,9 +1232,8 @@ parameter with the <tt/#pragma/. <sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p> This pragma sets a wrapper for functions, often used for trampolines. - The name is either a function returning void and taking no parameters, - or the address of an array in memory (for a RAM trampoline). The identifier - is an 8-bit number that's set to tmp4. + The name is a function returning void and taking no parameters. + The identifier is an 8-bit number that's set to tmp4. The address of the function is passed in ptr4. diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 98f1a20d0..2cd510ff8 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -509,7 +509,7 @@ static void WrappedCallPragma (StrBuf* B) Entry = FindSym(Name); /* Check if the name is valid */ - if (Entry && Entry->Flags & (SC_FUNC | SC_STORAGE)) { + if (Entry && Entry->Flags & SC_FUNC) { PushWrappedCall(Entry, Val); Entry->Flags |= SC_REF; diff --git a/test/val/trampoline.c b/test/val/trampoline.c index aad4c96ea..6723df9b3 100644 --- a/test/val/trampoline.c +++ b/test/val/trampoline.c @@ -22,10 +22,6 @@ void func3() { } -unsigned char array[30]; -#pragma wrapped-call(push, array, 0) -#pragma wrapped-call(pop) - #pragma wrapped-call(push, trampoline_inc, 0) void func2() { From 219b239a347fd07742e09628599f5d7e4f987253 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Thu, 18 May 2017 17:14:26 +0300 Subject: [PATCH 324/407] Adjustments in response to latest comments --- src/cc65/funcdesc.h | 4 ++-- src/cc65/pragma.c | 2 +- test/val/trampoline.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index 966aff573..040f6e97c 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -67,8 +67,8 @@ struct FuncDesc { unsigned ParamCount; /* Number of parameters */ unsigned ParamSize; /* Size of the parameters */ struct SymEntry* LastParam; /* Pointer to last parameter */ - struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ - unsigned char WrappedCallData; /* The WrappedCall's user data */ + struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ + unsigned char WrappedCallData;/* The WrappedCall's user data */ }; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 2cd510ff8..8d5dfd8b1 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -517,7 +517,7 @@ static void WrappedCallPragma (StrBuf* B) } else { /* Segment name is invalid */ - Error ("Wrapped-call target does not exist or is not a function or array"); + Error ("Wrapped-call target does not exist or is not a function"); } diff --git a/test/val/trampoline.c b/test/val/trampoline.c index 6723df9b3..63741b590 100644 --- a/test/val/trampoline.c +++ b/test/val/trampoline.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! trampoline pragma + !!DESCRIPTION!! wrapped-call pragma used for trampolines !!ORIGIN!! cc65 regression tests !!LICENCE!! Public Domain !!AUTHOR!! Lauri Kasanen From 70b541b81ea01561f8e8d19a8f195ef55e76bc6d Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Thu, 18 May 2017 21:21:02 +0200 Subject: [PATCH 325/407] Changed section --- doc/vic20.sgml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/vic20.sgml b/doc/vic20.sgml index 889cc266e..26a4aa558 100644 --- a/doc/vic20.sgml +++ b/doc/vic20.sgml @@ -182,13 +182,14 @@ No VIC1011 drivers are currently available for the VIC20. <sect>Limitations<p> - -<sect>Other hints<p> - - <sect1>Escape code<p> -For an Esc, pressing CTRL and the <tt/[/ key is not supported. +The CTRL key cannot be used to type most control characters, +entering an Esc is not possible. + + + +<sect>Other hints<p> <sect1>Passing arguments to the program<p> From 16a2beaaca0b05b47417a396048003121e51c9ea Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Thu, 18 May 2017 22:40:18 +0200 Subject: [PATCH 326/407] Adjusted VS project files to commit https://github.com/cc65/cc65/commit/11b01b908d321c39d86de1dd12102eaa6f4053e9 --- src/cc65.vcxproj | 2 ++ src/common.vcxproj | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/cc65.vcxproj b/src/cc65.vcxproj index 1c1f993fe..70f43dc73 100644 --- a/src/cc65.vcxproj +++ b/src/cc65.vcxproj @@ -145,6 +145,7 @@ <ClInclude Include="cc65\typecmp.h" /> <ClInclude Include="cc65\typeconv.h" /> <ClInclude Include="cc65\util.h" /> + <ClInclude Include="cc65\wrappedcall.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="cc65\anonname.c" /> @@ -218,6 +219,7 @@ <ClCompile Include="cc65\typecmp.c" /> <ClCompile Include="cc65\typeconv.c" /> <ClCompile Include="cc65\util.c" /> + <ClCompile Include="cc65\wrappedcall.c" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/src/common.vcxproj b/src/common.vcxproj index 053d23981..39fea35e5 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -38,6 +38,7 @@ <ClInclude Include="common\hashtab.h" /> <ClInclude Include="common\hlldbgsym.h" /> <ClInclude Include="common\inline.h" /> + <ClInclude Include="common\intptrstack.h" /> <ClInclude Include="common\intstack.h" /> <ClInclude Include="common\inttypes.h" /> <ClInclude Include="common\libdefs.h" /> @@ -87,6 +88,7 @@ <ClCompile Include="common\gentype.c" /> <ClCompile Include="common\hashfunc.c" /> <ClCompile Include="common\hashtab.c" /> + <ClCompile Include="common\intptrstack.c" /> <ClCompile Include="common\intstack.c" /> <ClCompile Include="common\matchpat.c" /> <ClCompile Include="common\mmodel.c" /> From 75028e41087b0d0efeb1e8b75ea31cb1f3fb8521 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Thu, 18 May 2017 23:58:10 +0200 Subject: [PATCH 327/407] shorter code --- libsrc/c128/joy/c128-stdjoy.s | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libsrc/c128/joy/c128-stdjoy.s b/libsrc/c128/joy/c128-stdjoy.s index 119d3784f..a2caead1a 100644 --- a/libsrc/c128/joy/c128-stdjoy.s +++ b/libsrc/c128/joy/c128-stdjoy.s @@ -104,7 +104,7 @@ joy1: lda #$7F sei sta CIA1_PRA lda CIA1_PRB - cli +back: cli and #$1F eor #$1F rts @@ -118,9 +118,4 @@ joy2: ldx #0 sta CIA1_DDRA lda CIA1_PRA sty CIA1_DDRA - cli - and #$1F - eor #$1F - rts - - + jmp back From 80e6afd33522d4583f0753b85e4b75da0b79ebee Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 19 May 2017 14:20:04 +0300 Subject: [PATCH 328/407] Add two new trampoline test cases --- test/val/trampoline-params.c | 32 +++++++++++++++++++++++ test/val/trampoline-varargs.c | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 test/val/trampoline-params.c create mode 100644 test/val/trampoline-varargs.c diff --git a/test/val/trampoline-params.c b/test/val/trampoline-params.c new file mode 100644 index 000000000..890e43e5f --- /dev/null +++ b/test/val/trampoline-params.c @@ -0,0 +1,32 @@ +/* + !!DESCRIPTION!! wrapped-call pragma w/ many params + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Lauri Kasanen +*/ + +#include <stdarg.h> + +static unsigned char flag; + +static void trampoline_set() { + asm("ldy tmp4"); + asm("sty %v", flag); + asm("jsr callptr4"); +} + +#pragma wrapped-call(push, trampoline_set, 4) +long adder(long in); +#pragma wrapped-call(pop) + +long adder(long in) { + + return in + 7; +} + +int main() { + + flag = 0; + + return adder(70436) == 70436 + 7 && flag == 4 ? 0 : 1; +} diff --git a/test/val/trampoline-varargs.c b/test/val/trampoline-varargs.c new file mode 100644 index 000000000..5d3377c68 --- /dev/null +++ b/test/val/trampoline-varargs.c @@ -0,0 +1,48 @@ +/* + !!DESCRIPTION!! wrapped-call pragma w/ varags + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Lauri Kasanen +*/ + +#include <stdarg.h> + +static unsigned char flag; + +static void trampoline_set() { + // The Y register is used for variadics - save and restore + asm("sty tmp3"); + + asm("ldy tmp4"); + asm("sty %v", flag); + + asm("ldy tmp3"); + asm("jsr callptr4"); +} + +#pragma wrapped-call(push, trampoline_set, 4) +unsigned adder(unsigned char num, ...); +#pragma wrapped-call(pop) + +unsigned adder(unsigned char num, ...) { + + unsigned char i; + unsigned sum = 0; + va_list ap; + va_start(ap, num); + + for (i = 0; i < num; i++) { + sum += va_arg(ap, unsigned); + } + + va_end(ap); + + return sum; +} + +int main() { + + flag = 0; + + return adder(3, 0, 5, 500) == 505 && flag == 4 ? 0 : 1; +} From 901ac80026f3defad4c143d2336558384bd763ad Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 19 May 2017 15:20:36 +0300 Subject: [PATCH 329/407] Wrapper functions use all registers --- src/cc65/codeinfo.c | 4 ++++ src/cc65/funcdesc.h | 3 ++- src/cc65/pragma.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index de51781a6..06c66baf4 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -401,6 +401,10 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg) */ if ((D->Flags & FD_VARIADIC) != 0) { *Use = REG_Y; + } else if (D->Flags & FD_CALL_WRAPPER) { + /* Wrappers may go to any functions, so mark them as using all + registers */ + *Use = REG_EAXY; } else if (D->ParamCount > 0 && (AutoCDecl ? IsQualFastcall (E->Type) : diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index 040f6e97c..a04ffb14a 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -52,9 +52,10 @@ #define FD_OLDSTYLE 0x0010U /* Old style (K&R) function */ #define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */ #define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */ +#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */ /* Bits that must be ignored when comparing funcs */ -#define FD_IGNORE (FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS) +#define FD_IGNORE (FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 8d5dfd8b1..3dfc62668 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -513,6 +513,7 @@ static void WrappedCallPragma (StrBuf* B) PushWrappedCall(Entry, Val); Entry->Flags |= SC_REF; + Entry->V.F.Func->Flags |= FD_CALL_WRAPPER; } else { From e8a735492de02f1ab7dc5f28a24dc1c5022c0d82 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 19 May 2017 15:38:50 +0300 Subject: [PATCH 330/407] Correct comment style --- src/cc65/codeinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index 06c66baf4..e9d98f5b8 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -403,7 +403,8 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg) *Use = REG_Y; } else if (D->Flags & FD_CALL_WRAPPER) { /* Wrappers may go to any functions, so mark them as using all - registers */ + ** registers. + */ *Use = REG_EAXY; } else if (D->ParamCount > 0 && (AutoCDecl ? From 39e55bdb77bc6a2ba6ea7748e5c02c814685f0c0 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sat, 20 May 2017 01:41:49 -0400 Subject: [PATCH 331/407] Added more info to the documentation of "#pragma wrapped-call". --- doc/cc65.sgml | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 2e480e4c3..3689c0b35 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -4,7 +4,7 @@ <title>cc65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:gregdk@users.sf.net" name="Greg King"> -<date>2017-03-21 +<date>2017-05-20 <abstract> cc65 is a C compiler for 6502 targets. It supports several 6502 based home @@ -1229,27 +1229,36 @@ parameter with the <tt/#pragma/. </verb></tscreen> -<sect1><tt>#pragma wrapped-call (<push&rt;, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p> +<sect1><tt>#pragma wrapped-call (push, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p> This pragma sets a wrapper for functions, often used for trampolines. - The name is a function returning void and taking no parameters. - The identifier is an 8-bit number that's set to tmp4. - The address of the function is passed in ptr4. + The name is a function returning <tt/void/, and taking no parameters. + It must preserve the CPU's <tt/A/ and <tt/X/ registers if it wraps any + <tt/__fastcall__/ functions that have parameters. It must preserve + the <tt/Y/ register if it wraps any variadic functions (they have "<tt/.../" + in their prototypes). - This is useful for example with banked memory, to automatically - switch banks to where this function resides, and then restore - the bank when it returns. + The identifier is an 8-bit number that's set into <tt/tmp4/. - The <tt/#pragma/ requires the push and pop parameters as explained above. + The address of a wrapped function is passed in <tt/ptr4/. The wrapper can + call that function by using "<tt/jsr callptr4/". + + This feature is useful, for example, with banked memory, to switch banks + automatically to where a wrapped function resides, and then to restore the + previous bank when it returns. + + The <tt/#pragma/ requires the push or pop argument as explained above. Example: <tscreen><verb> - void mytrampoline(void); +/* Note that this code can be in a header. */ +void mytrampoline(void); /* Doesn't corrupt __AX__ */ - #pragma wrapped-call (push, mytrampoline, 0) - void somefunc(void); - #pragma wrapped-call (pop) +#pragma wrapped-call (push, mytrampoline, 5) +void somefunc1(void); +void somefunc2(int, char *); +#pragma wrapped-call (pop) </verb></tscreen> From 05b73276c2ff1b6ea88735c1d78a9da8e1d8cabc Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Sat, 20 May 2017 09:53:30 +0300 Subject: [PATCH 332/407] Update test description --- test/val/trampoline-varargs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/val/trampoline-varargs.c b/test/val/trampoline-varargs.c index 5d3377c68..d154a3da0 100644 --- a/test/val/trampoline-varargs.c +++ b/test/val/trampoline-varargs.c @@ -1,5 +1,5 @@ /* - !!DESCRIPTION!! wrapped-call pragma w/ varags + !!DESCRIPTION!! wrapped-call pragma w/ variadic function !!ORIGIN!! cc65 regression tests !!LICENCE!! Public Domain !!AUTHOR!! Lauri Kasanen From 3157e4be1ec7f2a5ac61ca45b232cd07c5e30483 Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Mon, 22 May 2017 23:07:31 +0200 Subject: [PATCH 333/407] added empty lines and spaces according to olivers comments. Made local functions static. --- src/cl65/main.c | 55 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index e428c96ac..6926199f9 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -156,22 +156,36 @@ static char* TargetLib = 0; # endif #endif + + /*****************************************************************************/ /* Credential functions */ /*****************************************************************************/ -void DisableAssembling(void){ + + + +static void DisableAssembling (void) +{ DoAssemble = 0; } -void DisableLinking(void){ + + +static void DisableLinking (void) +{ DoLink = 0; } -void DisableAssemblingAndLinking(void){ + + +static void DisableAssemblingAndLinking (void) +{ DisableAssembling(); DisableLinking(); } + + /*****************************************************************************/ /* Command structure handling */ /*****************************************************************************/ @@ -1427,22 +1441,33 @@ int main (int argc, char* argv []) break; case 'E': - /*Forward -E to compiler*/ + /* Forward -E to compiler */ CmdAddArg (&CC65, Arg); DisableAssemblingAndLinking(); break; + case 'W': - if (Arg[2] == 'a' && Arg[3] == '\0') { - /* -Wa: Pass options to assembler */ - OptAsmArgs (Arg, GetArg (&I, 3)); - } else if (Arg[2] == 'c' && Arg[3] == '\0') { - /* -Wc: Pass options to compiler */ - /* Remember -Wc sub arguments in cc65 arg struct */ - OptCCArgs (Arg, GetArg (&I, 3)); - } else if (Arg[2] == 'l' && Arg[3] == '\0') { - /* -Wl: Pass options to linker */ - OptLdArgs (Arg, GetArg (&I, 3)); - } else { + /* avoid && with'\0' in if clauses */ + if (Arg[3] == '\0') { + switch (Arg[2]) { + case 'a': + /* -Wa: Pass options to assembler */ + OptAsmArgs (Arg, GetArg (&I, 3)); + break; + case 'c': + /* -Wc: Pass options to compiler + ** Remember -Wc sub arguments in cc65 arg struct + */ + OptCCArgs (Arg, GetArg (&I, 3)); + break; + case 'l': + /* -Wl: Pass options to linker */ + OptLdArgs (Arg, GetArg (&I, 3)); + break; + default: + break; + } + }else { /* Anything else: Suppress warnings (compiler) */ CmdAddArg2 (&CC65, "-W", GetArg (&I, 2)); } From 21b1add98464367bef7819654f1643337c65260b Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Mon, 22 May 2017 23:21:55 +0200 Subject: [PATCH 334/407] added four escaped tabs to -E Stop after .... description --- src/cl65/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 6926199f9..8252b61ff 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -734,7 +734,7 @@ static void Usage (void) " -C name\t\t\tUse linker config file\n" " -Cl\t\t\t\tMake local variables static\n" " -D sym[=defn]\t\t\tDefine a preprocessor symbol\n" - " -E Stop after the preprocessing stage\n" + " -E\t\t\t\tStop after the preprocessing stage\n" " -I dir\t\t\tSet a compiler include directory path\n" " -L path\t\t\tSpecify a library search path\n" " -Ln name\t\t\tCreate a VICE label file\n" From d9a8c300538f7778e5823350a9f0e8eccc7b88cd Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Mon, 22 May 2017 23:53:51 +0200 Subject: [PATCH 335/407] typo --- doc/funcref.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index d4c2f3fe1..d160082bf 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -3710,7 +3710,7 @@ fastcall function, so it may only be used in presence of a prototype. <quote> <descrip> -<tag/Function/Check if a given character is a a white-space character. +<tag/Function/Check if a given character is a white-space character. <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/ <tag/Declaration/<tt/int __fastcall__ isspace (int c);/ <tag/Description/The function returns a non zero value if the given argument From 355696d17da9147d12f63de855ec5ff089f0c285 Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Mon, 22 May 2017 21:33:02 -0400 Subject: [PATCH 336/407] ca65 documentation of .define macros, making note that parentheses in ca65 macros are problematic especially when thinking of them as "C style", replacing unclear example with an example showing how accidental parentheses can cause a problem. --- doc/ca65.sgml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 6ce5ecef6..74e081985 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4282,6 +4282,12 @@ different: some things may be done with both macro types, each type has special usages. The types complement each other. +<item> Parentheses work differently from C macros. + The common practice of wrapping C macros in parentheses may cause + unintended problems here, such as accidentally implying an + indirect addressing mode. While the definition of a macro requires + parentheses around its argument list, when invoked they should not be included. + </itemize> Let's look at a few examples to make the advantages and disadvantages @@ -4314,20 +4320,18 @@ Macros with parameters may also be useful: DEBUG "Assembling include file #3" </verb></tscreen> -Note that, while formal parameters have to be placed in braces, this is -not true for the actual parameters. Beware: Since the assembler cannot -detect the end of one parameter, only the first token is used. If you -don't like that, use classic macros instead: +Note that, while formal parameters have to be placed in braces, +the actual parameters used when invoking the macro should not use braces. +The invoked parameters are separated by commas only, if parentheses are +used by accident they will become part of the replaced token: <tscreen><verb> -.macro DEBUG message - .out message -.endmacro +.define COMBINE(ta,tb,tc) ta+tb*10+tc*100 + + COMBINE 5,6,7 ; 5+6*10+7*100 = 765 correct + COMBINE(5,6,7) ; (5+6*10+7)*100 = 7200 incorrect! </verb></tscreen> -(That is an example where a problem can be solved with both macro types). - - <sect1>Characters in macros<p> When using the <ref id="option-t" name="-t"> option, characters are translated From f87a575d4d32f0f2386ebd7c24dc73953eed2bef Mon Sep 17 00:00:00 2001 From: mc78 <mc78@outlook.de> Date: Tue, 23 May 2017 22:57:27 +0200 Subject: [PATCH 337/407] added missing spaces before braces. added unknown option msg if not given -Wc|l|a when passing options to subprocess --- src/cl65/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 8252b61ff..b209cb21d 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -180,8 +180,8 @@ static void DisableLinking (void) static void DisableAssemblingAndLinking (void) { - DisableAssembling(); - DisableLinking(); + DisableAssembling (); + DisableLinking (); } @@ -1427,7 +1427,7 @@ int main (int argc, char* argv []) case 'S': /* Dont assemble and link the created files */ - DisableAssemblingAndLinking(); + DisableAssemblingAndLinking (); break; case 'T': @@ -1443,7 +1443,7 @@ int main (int argc, char* argv []) case 'E': /* Forward -E to compiler */ CmdAddArg (&CC65, Arg); - DisableAssemblingAndLinking(); + DisableAssemblingAndLinking (); break; case 'W': @@ -1465,9 +1465,10 @@ int main (int argc, char* argv []) OptLdArgs (Arg, GetArg (&I, 3)); break; default: + UnknownOption (Arg); break; } - }else { + } else { /* Anything else: Suppress warnings (compiler) */ CmdAddArg2 (&CC65, "-W", GetArg (&I, 2)); } @@ -1475,7 +1476,7 @@ int main (int argc, char* argv []) case 'c': /* Don't link the resulting files */ - DisableLinking(); + DisableLinking (); break; case 'd': From 051cf11ce69ce147ff747c44e2732bf75a982c79 Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Tue, 23 May 2017 17:07:45 -0400 Subject: [PATCH 338/407] expanding macro examples, trying to adhere to style guidelines --- doc/ca65.sgml | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 74e081985..d0a3d80e7 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4286,7 +4286,8 @@ different: The common practice of wrapping C macros in parentheses may cause unintended problems here, such as accidentally implying an indirect addressing mode. While the definition of a macro requires - parentheses around its argument list, when invoked they should not be included. + parentheses around its argument list, when invoked they should not be + included. </itemize> @@ -4320,18 +4321,44 @@ Macros with parameters may also be useful: DEBUG "Assembling include file #3" </verb></tscreen> -Note that, while formal parameters have to be placed in braces, -the actual parameters used when invoking the macro should not use braces. -The invoked parameters are separated by commas only, if parentheses are -used by accident they will become part of the replaced token: +Note that, while formal parameters have to be placed in parentheses, +the actual argument used when invoking the macro should not be. +The invoked arguments are separated by commas only, if parentheses are +used by accident they will become part of the replaced token. + +If you wish to have an expression follow the macro invocation, the +last parameter can be enclosed in curly braces {} to indicate the end of that +argument. + +Examples: <tscreen><verb> .define COMBINE(ta,tb,tc) ta+tb*10+tc*100 - COMBINE 5,6,7 ; 5+6*10+7*100 = 765 correct - COMBINE(5,6,7) ; (5+6*10+7)*100 = 7200 incorrect! +.word COMBINE 5,6,7 ; 5+6*10+7*100 = 765 +.word COMBINE(5,6,7) ; (5+6*10+7)*100 = 7200 ; incorrect use of parentheses +.word COMBINE 5,6,7+1 ; 5+6*10+7+1*100 = 172 +.word COMBINE 5,6,{7}+1 ; 5+6*10+7*100+1 = 766 ; {} encloses the argument +.word COMBINE 5,6-2,7 ; 5+6-2*10+7*100 = 691 +.word COMBINE 5,(6-2),7 ; 5+(6-2)*10+7*100 = 745 +.word COMBINE 5,6,7+COMBINE 0,1,2 ; 5+6*10+7+0+1*10+2*100*100 = 20082 +.word COMBINE 5,6,{7}+COMBINE 0,1,2 ; 5+6*10+7*100+0+1*10+2*100 = 975 </verb></tscreen> +With C macros it is common to enclose the results in parentheses to +prevent unintended interactions with the text of the arguments, but +additional care must be taken in this assembly context where parentheses +may alter the meaning of a statement. In particular, indirect addressing modes +may be accidentally implied: + +<tscreen><verb> +.define DUO(ta,tb) (ta+(tb*10)) + + lda DUO(5,4), Y ; LDA (indirect), Y + lda 0+DUO(5,4), Y ; LDA absolute indexed, Y +</verb></tscreen> + + <sect1>Characters in macros<p> When using the <ref id="option-t" name="-t"> option, characters are translated From 87a9e0ce4f88a69b2db2c047074894f05c4b8f56 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Wed, 24 May 2017 00:04:52 +0200 Subject: [PATCH 339/407] clean-up --- doc/telestrat.sgml | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index fda4dee86..243097a84 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -4,13 +4,14 @@ <title>Oric Telestrat-specific information for cc65 <author> -<url url="mailto:jede@oric.org" name="Jede">,<newline> +<url url="mailto:jede@oric.org" name="Jede"> <date>2017-01-22 <abstract> -An overview over the Telestrat (Telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C -compiler.) +An overview over the Telestrat (<url name="Telemon 3.0" +url="http://orix.oric.org">) runtime system as it is implemented for the +cc65 C compiler. </abstract> <!-- Table of contents --> @@ -32,25 +33,28 @@ information. <sect>Binary format<p> -The standard binary output format generated the linker for the Telestrat target -is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header +The standard binary output format generated the linker for the Telestrat +target is a machine language program with a 20 bytes header described <url +name="here" url="http://orix.oric.org/doku.php?id=orix:header"> -This header is used for Telemon 3.0. +This header is used for Telemon 3.0. -Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily. +Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily. -Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. +Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. -There is no tool to insert a binary in a Stratsed floppy disk. +There is no tool to insert a binary in a Stratsed floppy disk. -The only way to load a binary (for Telemon 2.4) is to : +The only way to load a binary (for Telemon 2.4) is to: <itemize> <item>remove the 20 bytes header -<item>download osdk : http://osdk.defence-force.org/index?page=download +<item>download <url name="osdk" url="http://osdk.defence-force.org/index?page=download"> <item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when Telestrat starts) </itemize> -Please note also, that the binary converted into TAP file, will not produce a right stratsed file when tap2dsk and old2mfm are used. You will be in the case that Telestrat/Stratsed crashed when you do "DIR" command. +Please note also, that the binary converted into TAP file, will not produce +a right stratsed file when tap2dsk and old2mfm are used. You will be in the +case that Telestrat/Stratsed crashed when you do "DIR" command. If you know the Stratsed disk format, please contact the author of this doc. @@ -79,7 +83,7 @@ Special locations: <sect>Platform-specific header files<p> -Programs containing Telestrat -specific code may use the <tt/telestrat.h/ header file. +Programs containing Telestrat-specific code may use the <tt/telestrat.h/ header file. <sect1>Telestrat-specific functions<p> @@ -147,8 +151,12 @@ Telestrat has a RS232 port, but it's not used <sect1>Disk I/O<p> -Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 does not have these primitives. -By the way, Telemon 3.0 uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose). +Telemon 3.0 handles fopen, fread, fclose primitives. It means that this +function will crash the Telestrat because Telemon 2.4 does not have these +primitives. By the way, Telemon 3.0 uses an extension "ch376 card" which +handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, +Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, +fclose). <itemize> <item>fclose From ca1b9deb592e25889f75cc0a9f32b198e8de011c Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 24 May 2017 16:47:12 -0400 Subject: [PATCH 340/407] Added a description of the "-E" command-line option to cl65's document. Improved other descriptions, to make them more consistent and accurate. --- doc/cl65.sgml | 91 +++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/doc/cl65.sgml b/doc/cl65.sgml index ffeba2321..8b3c02cbb 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -2,8 +2,9 @@ <article> <title>cl65 Users Guide -<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>01.08.2000, 27.11.2000, 02.10.2001 +<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> +<url url="mailto:greg.king5@verizon.net" name="Greg King"> +<date>2017-05-24 <abstract> cl65 is the compile & link utility for cc65, the 6502 C compiler. It was @@ -50,6 +51,7 @@ Short options: -C name Use linker config file -Cl Make local variables static -D sym[=defn] Define a preprocessor symbol + -E Stop after the preprocessing stage -I dir Set a compiler include directory path -L path Specify a library search path -Ln name Create a VICE label file @@ -120,56 +122,66 @@ Long options: --------------------------------------------------------------------------- </verb></tscreen> -Most of the options have the same meaning than the corresponding compiler, -assembler or linker option. See the documentation for these tools for an +Most of the options have the same meanings as the corresponding compiler, +assembler, and linker options. See the documentation for those tools for an explanation. If an option is available for more than one of the tools, it -is set for all tools, where it is available. One example for this is <tt/-v/: -The compiler, the assembler and the linker are all called with the <tt/-v/ +is set for all tools where it is available. One example for that is <tt/-v/: +The compiler, the assembler, and the linker are all called with the <tt/-v/ switch. There are a few remaining options that control the behaviour of cl65: <descrip> + <tag><tt>-E</tt></tag> + + This option is passed to the cc65 compiler; and, it forces cl65 to stop + before the assembly step. That means that C-level preprocessor directives + are obeyed; and, macroes are expanded. But, the C source isn't compiled. + If the <tt/-o/ option isn't used, then the C code results are written into + files with a ".i" suffix on their base names. Assembler files, object + files, and libraries given on the command line are ignored. + + <tag><tt>-S</tt></tag> - This option forces cl65 to stop after the assembly step. This means that - C files are translated into assembler files, but nothing more is done. - Assembler files, object files and libraries given on the command line + This option forces cl65 to stop before the assembly step. That means that + C files are translated into assembler files; but, nothing more is done. + Assembler files, object files, and libraries given on the command line are ignored. <tag><tt>-c</tt></tag> - This options forces cl65 to stop after the assembly step. This means + This option forces cl65 to stop after the assembly step. That means that C and assembler files given on the command line are translated into - object files, but there is no link step, and object files and libraries + object files; but, there is no link step. Object files and libraries given on the command line are ignored. <tag><tt>-o name</tt></tag> - The -o option is used for the target name in the final step. This causes - problems, if the linker will not be called, and there are several input - files on the command line. In this case, the name given with -o will be + The -o option is used for the target name in the final step. That causes + problems if the linker will not be called, and there are several input + files on the command line. In that case, the name given with -o will be used for all of them, which makes the option pretty useless. You - shouldn't use -o when more than one output file is created. + shouldn't use <tt/-o/ when more than one output file is created. <tag><tt>--print-target-path</tt></tag> - This option prints the absolute path of the target file directory and exits + This option prints the absolute path of the target file directory, and exits then. It is supposed to be used with shell backquotes or the GNU make shell - function. This way you can write build scripts or Makefiles accessing target + function. That way, you can write build scripts or Makefiles accessing target files without any assumption about the cc65 installation path. <tag><tt>-t sys, --target sys</tt></tag> - The default for this option is different from the compiler and linker in the - case that the option is missing: While the other tools (compiler, assembler + The default for this option is different from the compiler and linker, in the + case that the option is missing: While the other tools (compiler, assembler, and linker) will use the "none" system settings by default, cl65 will use - the C64 as a target system by default. This was chosen since most people + "c64" as a target system by default. That was chosen because most people seem to use cc65 to develop for the C64. @@ -177,10 +189,10 @@ There are a few remaining options that control the behaviour of cl65: Pass options directly to the assembler. This may be used to pass options that aren't directly supported by cl65. Several options may be separated by - commas, the commas are replaced by spaces when passing them to the - assembler. Beware: Passing arguments directly to the assembler may interfere - with some of the defaults, because cl65 doesn't parse the options passed. So - if cl65 supports an option by itself, do not pass this option to the + commas; the commas are replaced by spaces when passing them to the + assembler. Beware: Passing arguments directly to the assembler might interfere + with some of the defaults because cl65 doesn't parse the options passed. So, + if cl65 supports an option by itself, do not pass that option to the assembler by means of the <tt/-Wa/ switch. @@ -188,10 +200,10 @@ There are a few remaining options that control the behaviour of cl65: Pass options directly to the compiler. This may be used to pass options that aren't directly supported by cl65. Several options may be separated by - commas, the commas are replaced by spaces when passing them to the - compiler. Beware: Passing arguments directly to the compiler may interfere - with some of the defaults, because cl65 doesn't parse the options passed. So - if cl65 supports an option by itself, do not pass this option to the + commas; the commas are replaced by spaces when passing them to the + compiler. Beware: Passing arguments directly to the compiler might interfere + with some of the defaults because cl65 doesn't parse the options passed. So, + if cl65 supports an option by itself, do not pass that option to the compiler by means of the <tt/-Wc/ switch. @@ -199,10 +211,10 @@ There are a few remaining options that control the behaviour of cl65: Pass options directly to the linker. This may be used to pass options that aren't directly supported by cl65. Several options may be separated by - commas, the commas are replaced by spaces when passing them to the linker. - Beware: Passing arguments directly to the linker may interfere with some of - the defaults, because cl65 doesn't parse the options passed. So if cl65 - supports an option by itself, do not pass this option to the linker by means + commas; the commas are replaced by spaces when passing them to the linker. + Beware: Passing arguments directly to the linker might interfere with some of + the defaults because cl65 doesn't parse the options passed. So, if cl65 + supports an option by itself, do not pass that option to the linker by means of the <tt/-Wl/ switch. </descrip> @@ -211,7 +223,7 @@ There are a few remaining options that control the behaviour of cl65: <sect>More usage<p> -Since cl65 was created to simplify the use of the cc65 development +Because cl65 was created to simplify the use of the cc65 development package, it tries to be smart about several things. <itemize> @@ -219,15 +231,14 @@ package, it tries to be smart about several things. <item> If you don't give a target system on the command line, cl65 defaults to the C64. -<item> When linking, cl65 will supply the names of the startup file and - library for the target system to the linker, so you don't have to do - that. +<item> When linking, cl65 will supply the name of the library file for + the target system to the linker; so, you don't have to do that. <item> If the final step is the linker, and the name of the output file was not explicitly given, cl65 will use the name of the first input file - without the extension, provided that the name of this file has an - extension. So you don't need to name the executable name in most - cases, just give the name of your "main" file as first input file. + without the extension, provided that the name of that file has an + extension. So, you don't need to give the executable name in most + cases; just give the name of your "main" file as the first input file. </itemize> The command line is parsed from left to right, and the actual processing tool @@ -248,7 +259,7 @@ The type of an input file is derived from its extension: <itemize> <item>C files: <tt/.c/ <item>Assembler files: <tt/.s/, <tt/.asm/, <tt/.a65/ -<item>Object files: <tt/.o/ <tt/.obj/ +<item>Object files: <tt/.o/, <tt/.obj/ <item>Libraries: <tt/.a/, <tt/.lib/ <item>GEOS resource files: <tt/.grc/ <item>o65 files: <tt/.o65/, <tt/.emd/, <tt/.joy/, <tt/.tgi/ From e31133c804ebb50ea89198445aec93d85584a7f8 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 24 May 2017 18:49:02 -0400 Subject: [PATCH 341/407] Added "html" and "info" goals to the top-level Makefile. They are for people who don't want to build both types of documents at the same time. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 808689c82..206f853fc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all mostlyclean clean install zip avail unavail bin lib doc samples +.PHONY: all mostlyclean clean install zip avail unavail bin lib doc html info samples .SUFFIXES: @@ -14,7 +14,7 @@ avail unavail bin: lib: @$(MAKE) -C libsrc --no-print-directory $@ -doc: +doc html info: @$(MAKE) -C doc --no-print-directory $@ samples: From 1602aab6e9aa4d89098404993526938c512d282a Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Thu, 25 May 2017 03:01:25 -0400 Subject: [PATCH 342/407] forgot to update comments from earlier #323 rand.s change --- libsrc/common/rand.s | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libsrc/common/rand.s b/libsrc/common/rand.s index 8ad7bcdb4..38d525b6b 100644 --- a/libsrc/common/rand.s +++ b/libsrc/common/rand.s @@ -2,6 +2,7 @@ ; Randum number generator ; ; Written and donated by Sidney Cadot - sidney@ch.twi.tudelft.nl +; 2016-11-07, modified by Brad Smith ; ; May be distributed with the cc65 runtime using the same license. ; @@ -13,10 +14,14 @@ ; Multiplier must be 1 (mod 4) ; Added value must be 1 (mod 2) ; This guarantees max. period (2**32) -; Bits 8-22 are returned (positive 2-byte int) -; where 0 is LSB, 31 is MSB. -; This is better as lower bits exhibit easily -; detectable patterns. +; The lowest bits have poor entropy and +; exhibit easily detectabl patterns, so +; only the upper bits 16-22 and 24-31 of the +; 4-byte state are returned. +; +; The best 8 bits, 24-31 are returned in the +; low byte A to provide the best entropy in the +; most commonly used part of the return value. ; .export _rand, _srand From 950d65e8ed4c95d8ada5540601b35cda35823a77 Mon Sep 17 00:00:00 2001 From: Brad Smith <rainwarrior@gmail.com> Date: Thu, 25 May 2017 03:20:11 -0400 Subject: [PATCH 343/407] detectabl > detectable --- libsrc/common/rand.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/common/rand.s b/libsrc/common/rand.s index 38d525b6b..102dd5be2 100644 --- a/libsrc/common/rand.s +++ b/libsrc/common/rand.s @@ -15,7 +15,7 @@ ; Added value must be 1 (mod 2) ; This guarantees max. period (2**32) ; The lowest bits have poor entropy and -; exhibit easily detectabl patterns, so +; exhibit easily detectable patterns, so ; only the upper bits 16-22 and 24-31 of the ; 4-byte state are returned. ; From 3b33af88cf4c3b6fff6e8b032fe5d5f9304ab599 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Fri, 26 May 2017 01:44:33 +0200 Subject: [PATCH 344/407] Oricutron mentioned --- doc/ld65.sgml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/ld65.sgml b/doc/ld65.sgml index 5687aa8ab..8f9dd7093 100644 --- a/doc/ld65.sgml +++ b/doc/ld65.sgml @@ -247,10 +247,11 @@ Here is a description of all of the command-line options: <tag><tt>-Ln</tt></tag> This option allows you to create a file that contains all global labels and - may be loaded into the VICE emulator using the <tt/ll/ (load label) command. You + may be loaded into the VICE emulator using the <tt/ll/ (load label) command + or into the Oricutron emulator using the <tt/sl/ (symbols load) command. You may use this to debug your code with VICE. Note: Older versions had some bugs in the label code. If you have problems, please get the latest <url - url="http://vice-emu.sourceforge.net/" name="VICE"> version. + url="http://vice-emu.sourceforge.net" name="VICE"> version. <label id="option-S"> From ff339393859558323553aea89c1ecc90fcf55d01 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 00:29:53 +0200 Subject: [PATCH 345/407] Use verbosity --- src/ar65/list.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ar65/list.c b/src/ar65/list.c index 656299860..496bbcde0 100644 --- a/src/ar65/list.c +++ b/src/ar65/list.c @@ -36,6 +36,9 @@ #include <stdio.h> #include <stdlib.h> +/* common */ +#include "print.h" + /* ar65 */ #include "error.h" #include "library.h" @@ -73,6 +76,10 @@ void ListObjFiles (int argc, char* argv []) /* Get the entry */ O = CollConstAt (&ObjPool, I); + /* Print the size */ + if (Verbosity > 0) { + printf ("%5ld ", O->Size); + } /* Print the name */ printf ("%s\n", O->Name); From 9bdcb0a31bd5d164d7aa027e975e6c4b0da611af Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 00:35:38 +0200 Subject: [PATCH 346/407] More POSIX.2, staying compatible --- src/ar65/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ar65/main.c b/src/ar65/main.c index a1839bad2..9985f1f71 100644 --- a/src/ar65/main.c +++ b/src/ar65/main.c @@ -64,8 +64,8 @@ static void Usage (void) "Operations are some of:\n" "\ta\tAdd modules\n" "\td\tDelete modules\n" - "\tl\tList library contents\n" - "\tv\tIncrease verbosity (put before other operation)\n" + "\tt\tList library table\n" + "\tv\tIncrease verbosity (put after other operation)\n" "\tx\tExtract modules\n" "\tV\tPrint the archiver version\n", ProgName); @@ -94,10 +94,6 @@ int main (int argc, char* argv []) /* Get the argument */ const char* Arg = ArgVec [I]; - /* Check for an option */ - if (strlen (Arg) != 1) { - Usage (); - } switch (Arg [0]) { case 'a': @@ -108,7 +104,11 @@ int main (int argc, char* argv []) DelObjFiles (ArgCount - I - 1, &ArgVec [I+1]); break; - case 'l': + case 't': /* POSIX.2 */ + case 'l': /* staying compatible */ + if (Arg [1] == 'v') { + ++Verbosity; + } ListObjFiles (ArgCount - I - 1, &ArgVec [I+1]); break; From 843c5442b149ca12db80dcb5f55dc61da9feaa42 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 13:13:53 +0200 Subject: [PATCH 347/407] Update list.c --- src/ar65/list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ar65/list.c b/src/ar65/list.c index 496bbcde0..e307e70a8 100644 --- a/src/ar65/list.c +++ b/src/ar65/list.c @@ -78,7 +78,7 @@ void ListObjFiles (int argc, char* argv []) /* Print the size */ if (Verbosity > 0) { - printf ("%5ld ", O->Size); + Print (stdout, 1, "%5lu ", O->Size); } /* Print the name */ printf ("%s\n", O->Name); From c9c2562c14aa296c69548bd089f5ba689abf2156 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 15:13:43 +0200 Subject: [PATCH 348/407] Update list.c --- src/ar65/list.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ar65/list.c b/src/ar65/list.c index e307e70a8..d65ad51e5 100644 --- a/src/ar65/list.c +++ b/src/ar65/list.c @@ -76,10 +76,8 @@ void ListObjFiles (int argc, char* argv []) /* Get the entry */ O = CollConstAt (&ObjPool, I); - /* Print the size */ - if (Verbosity > 0) { - Print (stdout, 1, "%5lu ", O->Size); - } + /* Print the size if verbose */ + Print (stdout, 1, "%5lu ", O->Size); /* Print the name */ printf ("%s\n", O->Name); From ea9430e28edc6b47a20bf3a94d05267a4c383569 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 15:22:33 +0200 Subject: [PATCH 349/407] Update list.c --- src/ar65/list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ar65/list.c b/src/ar65/list.c index d65ad51e5..367c950dc 100644 --- a/src/ar65/list.c +++ b/src/ar65/list.c @@ -79,7 +79,7 @@ void ListObjFiles (int argc, char* argv []) /* Print the size if verbose */ Print (stdout, 1, "%5lu ", O->Size); /* Print the name */ - printf ("%s\n", O->Name); + puts (O->Name); } From 49e22f566fa04cfaf841797732c7bb9b08a96c01 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 15:29:49 +0200 Subject: [PATCH 350/407] Update main.c --- src/ar65/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ar65/main.c b/src/ar65/main.c index 9985f1f71..9fb5d6cf8 100644 --- a/src/ar65/main.c +++ b/src/ar65/main.c @@ -65,7 +65,7 @@ static void Usage (void) "\ta\tAdd modules\n" "\td\tDelete modules\n" "\tt\tList library table\n" - "\tv\tIncrease verbosity (put after other operation)\n" + "\tv\tIncrease verbosity (put before other operation)\n" "\tx\tExtract modules\n" "\tV\tPrint the archiver version\n", ProgName); From ed65eaf682f84abcf59739d8774d61f382e5ca04 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 16:12:02 +0200 Subject: [PATCH 351/407] Verbosity was missing; POSIX operations --- doc/ar65.sgml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/doc/ar65.sgml b/doc/ar65.sgml index 136defd40..fa11cddb0 100644 --- a/doc/ar65.sgml +++ b/doc/ar65.sgml @@ -32,16 +32,17 @@ for the cc65 compiler. ar65 is part of this suite. The archiver is called as follows: <tscreen><verb> - Usage: ar65 <operation> lib file|module ... - Operation is one of: - a Add modules - d Delete modules - l List library contents - x Extract modules - V Print the archiver version + Usage: ar65 <operation ...> lib file|module ... + Operations are some of: + r Add modules + d Delete modules + t List library table + v Increase verbosity (put before other operation) + x Extract modules + V Print the archiver version </verb></tscreen> -You may add modules to a library using the `a' command. If the library +You may add modules to a library using the `r' command. If the library does not exist, it is created (and a warning message is printed which you may ignore if creation of the library was your intention). You may specify any number of modules on the command line following the library. @@ -53,7 +54,7 @@ has a newer timestamp than the one to add. Here's an example: <tscreen><verb> - ar65 a mysubs.lib sub1.o sub2.o + ar65 r mysubs.lib sub1.o sub2.o </verb></tscreen> This will add two modules to the library `mysubs.lib' creating the @@ -63,10 +64,10 @@ sub2.o, they are replaced by the new ones. Modules names in the library are stored without the path, so, using <tscreen><verb> - ar65 a mysubs.lib ofiles/sub1.o ofiles/sub2.o + ar65 v v r mysubs.lib ofiles/sub1.o ofiles/sub2.o </verb></tscreen> -will add two modules named `sub1.o' and `sub2.o' to the library. +will verbose add two modules named `sub1.o' and `sub2.o' to the library. Deleting modules from a library is done with the `d' command. You may not give a path when naming the modules. @@ -81,13 +82,13 @@ This will delete the module named `sub1.o' from the library, printing an error if the library does not contain that module. -The `l' command prints a list of all modules in the library. Any module +The `t' command prints a table of all modules in the library. Any module names on the command line are ignored. Example: <tscreen><verb> - ar65 l mysubs.lib + ar65 tv mysubs.lib </verb></tscreen> From 80feb80168eccc8b8097b9150c13deb848a8eb45 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 16:17:34 +0200 Subject: [PATCH 352/407] Update main.c --- src/ar65/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ar65/main.c b/src/ar65/main.c index 9fb5d6cf8..48561027f 100644 --- a/src/ar65/main.c +++ b/src/ar65/main.c @@ -62,7 +62,7 @@ static void Usage (void) { fprintf (stderr, "Usage: %s <operation ...> lib file|module ...\n" "Operations are some of:\n" - "\ta\tAdd modules\n" + "\tr\tAdd modules\n" "\td\tDelete modules\n" "\tt\tList library table\n" "\tv\tIncrease verbosity (put before other operation)\n" @@ -96,7 +96,8 @@ int main (int argc, char* argv []) switch (Arg [0]) { - case 'a': + case 'r': /* POSIX.2 */ + case 'a': /* staying compatible */ AddObjFiles (ArgCount - I - 1, &ArgVec[I+1]); break; From 0a011c31eab6ac137025b017c44677f929941df6 Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Sun, 28 May 2017 16:22:34 +0200 Subject: [PATCH 353/407] Update ar65.sgml --- doc/ar65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ar65.sgml b/doc/ar65.sgml index fa11cddb0..0a55a08c0 100644 --- a/doc/ar65.sgml +++ b/doc/ar65.sgml @@ -4,7 +4,7 @@ <title>ar65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>19.07.2000 +<date>2017-05-28 <abstract> ar65 is an archiver for object files generated by ca65. It allows to create From 52642f6c8f8a2a8f687fff71661e403b0218bbdc Mon Sep 17 00:00:00 2001 From: Stefan <stefan.haubenthal@gmail.com> Date: Tue, 30 May 2017 02:05:35 +0200 Subject: [PATCH 354/407] Deprecated commands mentioned --- doc/ar65.sgml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/ar65.sgml b/doc/ar65.sgml index 0a55a08c0..2e01025ca 100644 --- a/doc/ar65.sgml +++ b/doc/ar65.sgml @@ -42,7 +42,7 @@ The archiver is called as follows: V Print the archiver version </verb></tscreen> -You may add modules to a library using the `r' command. If the library +You may add modules to a library using the `r' command (`a' is deprecated). If the library does not exist, it is created (and a warning message is printed which you may ignore if creation of the library was your intention). You may specify any number of modules on the command line following the library. @@ -82,8 +82,8 @@ This will delete the module named `sub1.o' from the library, printing an error if the library does not contain that module. -The `t' command prints a table of all modules in the library. Any module -names on the command line are ignored. +The `t' command prints a table of all modules in the library (`l' is deprecated). +Any module names on the command line are ignored. Example: From e75a59d7a8d9bce24a3c9731924ad3abd1ab109e Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 6 Jun 2017 18:48:25 +0300 Subject: [PATCH 355/407] Add LZ4 decompression support --- include/lz4.h | 44 +++ libsrc/common/lz4.s | 283 +++++++++++++++++++ test/val/lz4.c | 669 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 996 insertions(+) create mode 100644 include/lz4.h create mode 100644 libsrc/common/lz4.s create mode 100644 test/val/lz4.c diff --git a/include/lz4.h b/include/lz4.h new file mode 100644 index 000000000..d6bf1b17c --- /dev/null +++ b/include/lz4.h @@ -0,0 +1,44 @@ +/*****************************************************************************/ +/* */ +/* lz4.h */ +/* */ +/* Decompression routine for the 'lz4' format */ +/* */ +/* */ +/* */ +/* (C) 2017 Mega Cat Studios */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef _LZ4_H +#define _LZ4_H + +void __fastcall__ decompress_lz4 (const unsigned char* src, unsigned char* dst, + const unsigned short uncompressed_size); +/* + Decompresses the source buffer into the destination buffer. + The size of the decompressed data must be known in advance, LZ4 + does not include any terminator in-stream. +*/ + +/* end of lz4.h */ +#endif diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s new file mode 100644 index 000000000..ee215d4da --- /dev/null +++ b/libsrc/common/lz4.s @@ -0,0 +1,283 @@ +; +; Lauri Kasanen, 6 Jun 2017 +; (C) Mega Cat Studios +; An optimized LZ4 decompressor +; + + .importzp sp, sreg, regsave, regbank + .importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 + .macpack longbranch + .import memcpy_upwards,pushax,popax + .export _decompress_lz4 + +_out = regsave +_written = regsave + 2 +_tmp = tmp1 +_token = tmp2 +_offset = ptr3 +_in = sreg +_outlen = ptr4 + +; --------------------------------------------------------------- +; void decompress_lz4 (const u8 *in, u8 * const out, const u16 outlen) +; --------------------------------------------------------------- + +.segment "CODE" + +.proc _decompress_lz4: near + + sta _outlen + stx _outlen+1 + + jsr popax + sta _out + stx _out+1 + + jsr popax + sta _in + stx _in+1 + +; +; written = 0; +; + lda #$00 + sta _written +; +; while (written < outlen) { +; + jmp L0046 +; +; token = *in++; +; +L0004: ldy #0 + lda (_in),y + sta _token + + inc _in + bne L000A + inc _in+1 +L000A: +; +; offset = token >> 4; +; + ldx #$00 + lsr a + lsr a + lsr a + lsr a + sta _offset + stx _offset+1 +; +; token &= 0xf; +; token += 4; // Minmatch +; + lda _token + and #$0F + clc + adc #4 + sta _token +; +; if (offset == 15) { +; + lda _offset + cmp #$0F +L0013: bne L001A +; +; tmp = *in++; +; + ldy #0 + lda (_in),y + sta _tmp + + inc _in + bne L0017 + inc _in+1 +L0017: +; +; offset += tmp; +; + clc + adc _offset + sta _offset + lda #$00 + adc _offset+1 + sta _offset+1 +; +; if (tmp == 255) +; + lda _tmp + cmp #$FF +; +; goto moreliterals; +; + jmp L0013 +; +; if (offset) { +; +L001A: lda _offset + ora _offset+1 + beq L001C +; +; memcpy(&out[written], in, offset); +; + lda _out + clc + adc _written + sta ptr2 + lda _out+1 + adc _written+1 + tax + lda ptr2 + stx ptr2+1 + jsr pushax + lda _in + ldx _in+1 + sta ptr1 + stx ptr1+1 + ldy #0 + jsr memcpy_upwards +; +; written += offset; +; + lda _offset + clc + adc _written + sta _written + lda _offset+1 + adc _written+1 + sta _written+1 +; +; in += offset; +; + lda _offset + clc + adc _in + sta _in + lda _offset+1 + adc _in+1 + sta _in+1 +; +; if (written >= outlen) +; +L001C: lda _written + cmp _outlen + lda _written+1 + sbc _outlen+1 +; +; return; +; + bcc L0047 + rts +; +; memcpy(&offset, in, 2); +; +L0047: ldy #0 + lda (_in),y + sta _offset + iny + lda (_in),y + sta _offset+1 +; +; in += 2; +; + lda #$02 + clc + adc _in + sta _in + bcc L002F + inc _in+1 +; +; copysrc = out + written - offset; +; +L002F: lda _out + clc + adc _written + pha + lda _out+1 + adc _written+1 + tax + pla + sec + sbc _offset + sta ptr1 + txa + sbc _offset+1 + sta ptr1+1 +; +; offset = token; +; + lda #$00 + sta _offset+1 + lda _token + sta _offset +; +; if (token == 19) { +; + cmp #$13 +L0045: bne L003C +; +; tmp = *in++; +; + ldy #0 + lda (_in),y + sta _tmp + + inc _in + bne L0039 + inc _in+1 +L0039: +; +; offset += tmp; +; + clc + adc _offset + sta _offset + tya + adc _offset+1 + sta _offset+1 +; +; if (tmp == 255) +; + lda _tmp + cmp #$FF +; +; goto morematches; +; + jmp L0045 +; +; memcpy(&out[written], copysrc, offset); +; +L003C: lda _out + clc + adc _written + sta ptr2 + lda _out+1 + adc _written+1 + tax + lda ptr2 + stx ptr2+1 + jsr pushax + jsr memcpy_upwards +; +; written += offset; +; + lda _offset + clc + adc _written + sta _written + lda _offset+1 + adc _written+1 +L0046: sta _written+1 +; +; while (written < outlen) { +; + lda _written + cmp _outlen + lda _written+1 + sbc _outlen+1 + jcc L0004 + + rts + +.endproc + diff --git a/test/val/lz4.c b/test/val/lz4.c new file mode 100644 index 000000000..dceefbfcc --- /dev/null +++ b/test/val/lz4.c @@ -0,0 +1,669 @@ +/* + !!DESCRIPTION!! lz4 decompression + !!ORIGIN!! cc65 regression tests + !!LICENCE!! BSD 2-clause + !!AUTHOR!! Lauri Kasanen +*/ + +#include <zlib.h> +#include <stdio.h> +#include <lz4.h> + +/* The sample data is the original lz4.h, compressed with lz4 hc */ +static const unsigned char compressed[] = { +0xf0, 0x1a, 0x2f, 0x2a, 0x0a, 0x20, 0x20, 0x20, 0x4c, 0x5a, 0x34, 0x20, +0x2d, 0x20, 0x46, 0x61, 0x73, 0x74, 0x20, 0x4c, 0x5a, 0x20, 0x63, 0x6f, +0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x6c, +0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x27, 0x00, 0xb0, 0x48, 0x65, +0x61, 0x64, 0x65, 0x72, 0x20, 0x46, 0x69, 0x6c, 0x65, 0x0f, 0x00, 0xf0, +0x17, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, +0x43, 0x29, 0x20, 0x32, 0x30, 0x31, 0x31, 0x2d, 0x32, 0x30, 0x31, 0x35, +0x2c, 0x20, 0x59, 0x61, 0x6e, 0x6e, 0x20, 0x43, 0x6f, 0x6c, 0x6c, 0x65, +0x74, 0x2e, 0x0a, 0x2a, 0x00, 0xf2, 0x22, 0x42, 0x53, 0x44, 0x20, 0x32, +0x2d, 0x43, 0x6c, 0x61, 0x75, 0x73, 0x65, 0x20, 0x4c, 0x69, 0x63, 0x65, +0x6e, 0x73, 0x65, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, +0x77, 0x77, 0x77, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x6f, 0x75, 0x72, +0x63, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6c, 0x23, 0x00, 0x63, 0x73, +0x2f, 0x62, 0x73, 0x64, 0x2d, 0x0d, 0x00, 0x51, 0x2e, 0x70, 0x68, 0x70, +0x29, 0x4e, 0x00, 0xb1, 0x52, 0x65, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, +0x62, 0x75, 0x74, 0xa3, 0x00, 0x30, 0x6e, 0x64, 0x20, 0x58, 0x00, 0x32, +0x69, 0x6e, 0x20, 0x43, 0x00, 0x01, 0x12, 0x00, 0xf1, 0x06, 0x62, 0x69, +0x6e, 0x61, 0x72, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2c, 0x20, +0x77, 0x69, 0x74, 0x68, 0x20, 0x6f, 0x72, 0x08, 0x00, 0x30, 0x6f, 0x75, +0x74, 0x46, 0x00, 0x80, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x63, 0x61, +0x44, 0x00, 0xf0, 0x22, 0x2c, 0x20, 0x61, 0x72, 0x65, 0x20, 0x70, 0x65, +0x72, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x20, 0x70, 0x72, 0x6f, 0x76, +0x69, 0x64, 0x65, 0x64, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x74, 0x68, +0x65, 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x20, +0x63, 0x6f, 0x6e, 0x64, 0x69, 0x35, 0x00, 0x10, 0x73, 0x35, 0x00, 0x01, +0x4a, 0x00, 0x31, 0x65, 0x74, 0x3a, 0x99, 0x00, 0x00, 0x01, 0x00, 0x1b, +0x2a, 0x9f, 0x00, 0x44, 0x73, 0x20, 0x6f, 0x66, 0x98, 0x00, 0xf1, 0x01, +0x63, 0x6f, 0x64, 0x65, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x72, 0x65, +0x74, 0x61, 0x69, 0x6e, 0x5a, 0x00, 0x40, 0x61, 0x62, 0x6f, 0x76, 0x1b, +0x00, 0x03, 0x4c, 0x01, 0x00, 0x48, 0x00, 0xf0, 0x02, 0x6e, 0x6f, 0x74, +0x69, 0x63, 0x65, 0x2c, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6c, 0x69, +0x73, 0x74, 0x44, 0x00, 0x08, 0x78, 0x00, 0x2b, 0x6e, 0x64, 0x95, 0x00, +0xbf, 0x64, 0x69, 0x73, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x72, 0x2e, +0x89, 0x00, 0x07, 0x28, 0x69, 0x6e, 0x16, 0x01, 0x04, 0x89, 0x00, 0x76, +0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x8c, 0x00, 0x00, 0x41, 0x00, +0x05, 0x8f, 0x00, 0x0f, 0x8c, 0x00, 0x2a, 0x00, 0x4a, 0x00, 0x03, 0xe6, +0x00, 0x94, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0xb3, +0x01, 0xf6, 0x04, 0x2f, 0x6f, 0x72, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72, +0x20, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x73, 0x77, 0x01, +0x01, 0xaf, 0x01, 0x21, 0x74, 0x68, 0x8b, 0x00, 0x08, 0xc4, 0x00, 0x02, +0x4e, 0x02, 0xf0, 0x34, 0x54, 0x48, 0x49, 0x53, 0x20, 0x53, 0x4f, 0x46, +0x54, 0x57, 0x41, 0x52, 0x45, 0x20, 0x49, 0x53, 0x20, 0x50, 0x52, 0x4f, +0x56, 0x49, 0x44, 0x45, 0x44, 0x20, 0x42, 0x59, 0x20, 0x54, 0x48, 0x45, +0x20, 0x43, 0x4f, 0x50, 0x59, 0x52, 0x49, 0x47, 0x48, 0x54, 0x20, 0x48, +0x4f, 0x4c, 0x44, 0x45, 0x52, 0x53, 0x20, 0x41, 0x4e, 0x44, 0x20, 0x43, +0x4f, 0x4e, 0x54, 0x52, 0x49, 0x42, 0x55, 0x54, 0x4f, 0x52, 0x53, 0x47, +0x00, 0x71, 0x22, 0x41, 0x53, 0x20, 0x49, 0x53, 0x22, 0x1c, 0x00, 0xf1, +0x26, 0x41, 0x4e, 0x59, 0x20, 0x45, 0x58, 0x50, 0x52, 0x45, 0x53, 0x53, +0x20, 0x4f, 0x52, 0x20, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x45, 0x44, 0x20, +0x57, 0x41, 0x52, 0x52, 0x41, 0x4e, 0x54, 0x49, 0x45, 0x53, 0x2c, 0x20, +0x49, 0x4e, 0x43, 0x4c, 0x55, 0x44, 0x49, 0x4e, 0x47, 0x2c, 0x20, 0x42, +0x55, 0x54, 0x20, 0x4e, 0x4f, 0x54, 0x3a, 0x03, 0xa1, 0x49, 0x4d, 0x49, +0x54, 0x45, 0x44, 0x20, 0x54, 0x4f, 0x2c, 0x7b, 0x00, 0x0e, 0x3a, 0x00, +0xf1, 0x04, 0x20, 0x4f, 0x46, 0x20, 0x4d, 0x45, 0x52, 0x43, 0x48, 0x41, +0x4e, 0x54, 0x41, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x73, 0x00, 0x40, +0x46, 0x49, 0x54, 0x4e, 0x6f, 0x00, 0x30, 0x46, 0x4f, 0x52, 0x49, 0x00, +0xf0, 0x06, 0x41, 0x20, 0x50, 0x41, 0x52, 0x54, 0x49, 0x43, 0x55, 0x4c, +0x41, 0x52, 0x20, 0x50, 0x55, 0x52, 0x50, 0x4f, 0x53, 0x45, 0x20, 0xe0, +0x00, 0xfa, 0x0e, 0x44, 0x49, 0x53, 0x43, 0x4c, 0x41, 0x49, 0x4d, 0x45, +0x44, 0x2e, 0x20, 0x49, 0x4e, 0x20, 0x4e, 0x4f, 0x20, 0x45, 0x56, 0x45, +0x4e, 0x54, 0x20, 0x53, 0x48, 0x41, 0x4c, 0x4c, 0xef, 0x00, 0x00, 0x48, +0x00, 0x50, 0x4f, 0x57, 0x4e, 0x45, 0x52, 0xc4, 0x00, 0x08, 0xef, 0x00, +0xa0, 0x20, 0x42, 0x45, 0x20, 0x4c, 0x49, 0x41, 0x42, 0x4c, 0x45, 0x6f, +0x00, 0x01, 0xee, 0x00, 0x60, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0xd7, +0x00, 0x06, 0x0a, 0x00, 0x90, 0x43, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x41, +0x4c, 0x2c, 0x49, 0x00, 0xf3, 0x04, 0x53, 0x50, 0x45, 0x43, 0x49, 0x41, +0x4c, 0x2c, 0x20, 0x45, 0x58, 0x45, 0x4d, 0x50, 0x4c, 0x41, 0x52, 0x59, +0x2c, 0x57, 0x00, 0xff, 0x05, 0x53, 0x45, 0x51, 0x55, 0x45, 0x4e, 0x54, +0x49, 0x41, 0x4c, 0x20, 0x44, 0x41, 0x4d, 0x41, 0x47, 0x45, 0x53, 0x20, +0x28, 0x1e, 0x01, 0x0f, 0x80, 0x50, 0x52, 0x4f, 0x43, 0x55, 0x52, 0x45, +0x4d, 0xbc, 0x00, 0xf1, 0x03, 0x4f, 0x46, 0x20, 0x53, 0x55, 0x42, 0x53, +0x54, 0x49, 0x54, 0x55, 0x54, 0x45, 0x20, 0x47, 0x4f, 0x4f, 0x44, 0x77, +0x01, 0xd1, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x53, 0x3b, 0x20, +0x4c, 0x4f, 0x53, 0x39, 0x01, 0x31, 0x55, 0x53, 0x45, 0x8d, 0x00, 0x41, +0x44, 0x41, 0x54, 0x41, 0x7f, 0x00, 0x80, 0x50, 0x52, 0x4f, 0x46, 0x49, +0x54, 0x53, 0x3b, 0x0c, 0x00, 0x41, 0x42, 0x55, 0x53, 0x49, 0x43, 0x01, +0xf1, 0x0d, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x52, 0x55, 0x50, 0x54, 0x49, +0x4f, 0x4e, 0x29, 0x20, 0x48, 0x4f, 0x57, 0x45, 0x56, 0x45, 0x52, 0x20, +0x43, 0x41, 0x55, 0x53, 0x45, 0x44, 0x6c, 0x01, 0x20, 0x4f, 0x4e, 0xf4, +0x00, 0x02, 0x3c, 0x02, 0x40, 0x45, 0x4f, 0x52, 0x59, 0x5b, 0x00, 0x23, +0x4c, 0x49, 0x8e, 0x01, 0x90, 0x2c, 0x20, 0x57, 0x48, 0x45, 0x54, 0x48, +0x45, 0x52, 0x5f, 0x01, 0x01, 0x36, 0x01, 0x10, 0x41, 0x0f, 0x01, 0x68, +0x53, 0x54, 0x52, 0x49, 0x43, 0x54, 0x27, 0x00, 0x61, 0x4f, 0x52, 0x20, +0x54, 0x4f, 0x52, 0xd9, 0x00, 0x06, 0xf0, 0x00, 0xb0, 0x20, 0x4e, 0x45, +0x47, 0x4c, 0x49, 0x47, 0x45, 0x4e, 0x43, 0x45, 0x21, 0x00, 0x10, 0x4f, +0x49, 0x00, 0xa0, 0x57, 0x49, 0x53, 0x45, 0x29, 0x20, 0x41, 0x52, 0x49, +0x53, 0x21, 0x00, 0x11, 0x49, 0x7d, 0x00, 0x71, 0x20, 0x57, 0x41, 0x59, +0x20, 0x4f, 0x55, 0xfc, 0x00, 0x00, 0xb5, 0x01, 0x31, 0x55, 0x53, 0x45, +0xaf, 0x01, 0x1a, 0x46, 0xcf, 0x02, 0x11, 0x2c, 0xde, 0x01, 0x80, 0x20, +0x49, 0x46, 0x20, 0x41, 0x44, 0x56, 0x49, 0xc0, 0x00, 0x03, 0x30, 0x00, +0x53, 0x50, 0x4f, 0x53, 0x53, 0x49, 0x3f, 0x02, 0x01, 0x3f, 0x01, 0x23, +0x43, 0x48, 0x7e, 0x01, 0x02, 0x15, 0x03, 0x70, 0x59, 0x6f, 0x75, 0x20, +0x63, 0x61, 0x6e, 0x9b, 0x03, 0x32, 0x74, 0x61, 0x63, 0xb5, 0x04, 0xb0, +0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x20, 0x61, 0x74, 0x20, 0x3a, 0x23, +0x00, 0x11, 0x2d, 0xe8, 0x05, 0x03, 0x8c, 0x04, 0xd0, 0x72, 0x65, 0x70, +0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x3a, 0x20, 0x8a, 0x05, +0xf6, 0x0c, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, +0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x79, 0x61, 0x6e, 0x34, 0x39, 0x37, +0x33, 0x2f, 0x6c, 0x7a, 0x34, 0x3d, 0x00, 0x60, 0x70, 0x75, 0x62, 0x6c, +0x69, 0x63, 0x40, 0x04, 0x28, 0x75, 0x6d, 0x38, 0x00, 0xc1, 0x72, 0x6f, +0x75, 0x70, 0x73, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x3f, 0x00, +0x01, 0x22, 0x00, 0x32, 0x2f, 0x23, 0x21, 0x08, 0x00, 0xf0, 0x1b, 0x6c, +0x7a, 0x34, 0x63, 0x0a, 0x2a, 0x2f, 0x0a, 0x23, 0x70, 0x72, 0x61, 0x67, +0x6d, 0x61, 0x20, 0x6f, 0x6e, 0x63, 0x65, 0x0a, 0x0a, 0x23, 0x69, 0x66, +0x20, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x20, 0x28, 0x5f, 0x5f, +0x63, 0x70, 0x6c, 0x75, 0x73, 0x04, 0x00, 0xf0, 0x08, 0x29, 0x0a, 0x65, +0x78, 0x74, 0x65, 0x72, 0x6e, 0x20, 0x22, 0x43, 0x22, 0x20, 0x7b, 0x0a, +0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x0a, 0x0a, 0xab, 0x06, 0x74, 0x2a, +0x20, 0x6c, 0x7a, 0x34, 0x2e, 0x68, 0x2a, 0x04, 0x79, 0x73, 0x20, 0x62, +0x6c, 0x6f, 0x63, 0x6b, 0xb2, 0x06, 0x41, 0x66, 0x75, 0x6e, 0x63, 0x9b, +0x04, 0x11, 0x2c, 0x9c, 0x04, 0xf1, 0x02, 0x67, 0x69, 0x76, 0x65, 0x73, +0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, +0x22, 0x01, 0x60, 0x72, 0x6f, 0x6c, 0x20, 0x74, 0x6f, 0x47, 0x00, 0x42, +0x67, 0x72, 0x61, 0x6d, 0x37, 0x05, 0xb0, 0x2a, 0x20, 0x49, 0x66, 0x20, +0x79, 0x6f, 0x75, 0x20, 0x6e, 0x65, 0xfa, 0x05, 0x90, 0x6f, 0x20, 0x67, +0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x5a, 0x06, 0xc5, 0x74, 0x65, 0x72, +0x2d, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x6e, 0x00, 0xf0, +0x01, 0x65, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x28, 0x72, 0x65, +0x73, 0x70, 0x65, 0x63, 0x74, 0xfd, 0x04, 0x00, 0x25, 0x01, 0x60, 0x66, +0x72, 0x61, 0x6d, 0x65, 0x20, 0x13, 0x00, 0x05, 0x61, 0x06, 0x20, 0x29, +0x2c, 0x60, 0x00, 0x00, 0x90, 0x00, 0x00, 0xa4, 0x01, 0x22, 0x6c, 0x65, +0xa0, 0x01, 0x40, 0x6c, 0x69, 0x62, 0x72, 0x8f, 0x05, 0xf1, 0x0e, 0x68, +0x61, 0x6e, 0x64, 0x6c, 0x65, 0x20, 0x69, 0x74, 0x73, 0x20, 0x6f, 0x77, +0x6e, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x2c, 0x20, 0x70, 0x6c, +0x65, 0x61, 0x73, 0x65, 0xdc, 0x06, 0x31, 0x6c, 0x7a, 0x34, 0x56, 0x00, +0xb0, 0x2e, 0x68, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65, 0x61, 0x64, 0x2e, +0x50, 0x01, 0x3f, 0x0a, 0x2f, 0x2a, 0x01, 0x00, 0x12, 0x70, 0x0a, 0x2a, +0x20, 0x20, 0x56, 0x65, 0x72, 0x20, 0x01, 0x1f, 0x0a, 0x32, 0x00, 0x13, +0x32, 0x2f, 0x0a, 0x23, 0x9b, 0x01, 0x00, 0xd2, 0x00, 0xe0, 0x5f, 0x56, +0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x41, 0x4a, 0x4f, 0x52, +0x5d, 0x06, 0x10, 0x31, 0x05, 0x00, 0x20, 0x2f, 0x2a, 0x09, 0x02, 0x60, +0x20, 0x62, 0x72, 0x65, 0x61, 0x6b, 0xfc, 0x00, 0x01, 0x27, 0x01, 0x20, +0x66, 0x61, 0xe9, 0x06, 0x8f, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x20, +0x20, 0x48, 0x00, 0x05, 0x22, 0x49, 0x4e, 0x48, 0x00, 0x17, 0x37, 0x48, +0x00, 0x94, 0x6e, 0x65, 0x77, 0x20, 0x28, 0x6e, 0x6f, 0x6e, 0x2d, 0x51, +0x00, 0x18, 0x29, 0x52, 0x00, 0xbf, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, +0x69, 0x74, 0x69, 0x65, 0x73, 0x56, 0x00, 0x05, 0x7a, 0x52, 0x45, 0x4c, +0x45, 0x41, 0x53, 0x45, 0x9e, 0x00, 0xf0, 0x03, 0x74, 0x77, 0x65, 0x61, +0x6b, 0x73, 0x2c, 0x20, 0x62, 0x75, 0x67, 0x2d, 0x66, 0x69, 0x78, 0x65, +0x73, 0x2c, 0x08, 0x08, 0x70, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, +0x92, 0x06, 0x0f, 0x4e, 0x00, 0x05, 0x8e, 0x4e, 0x55, 0x4d, 0x42, 0x45, +0x52, 0x20, 0x28, 0x00, 0x01, 0x40, 0x2a, 0x31, 0x30, 0x30, 0x04, 0x00, +0x2f, 0x20, 0x2b, 0xd5, 0x00, 0x00, 0x0e, 0x19, 0x00, 0x04, 0x98, 0x00, +0x51, 0x29, 0x0a, 0x69, 0x6e, 0x74, 0x19, 0x00, 0x12, 0x76, 0x8b, 0x01, +0xef, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x28, 0x76, 0x6f, 0x69, +0x64, 0x29, 0x3b, 0xcd, 0x01, 0x1a, 0x30, 0x54, 0x75, 0x6e, 0x72, 0x01, +0x20, 0x70, 0x61, 0x15, 0x02, 0x3f, 0x74, 0x65, 0x72, 0xd6, 0x01, 0x16, +0x02, 0x45, 0x03, 0x00, 0x85, 0x00, 0xc0, 0x4d, 0x45, 0x4d, 0x4f, 0x52, +0x59, 0x5f, 0x55, 0x53, 0x41, 0x47, 0x45, 0x20, 0x04, 0x31, 0x2a, 0x20, +0x4d, 0x78, 0x02, 0x61, 0x20, 0x75, 0x73, 0x61, 0x67, 0x65, 0x23, 0x08, +0xf0, 0x1d, 0x75, 0x6c, 0x61, 0x20, 0x3a, 0x20, 0x4e, 0x2d, 0x3e, 0x32, +0x5e, 0x4e, 0x20, 0x42, 0x79, 0x74, 0x65, 0x73, 0x20, 0x28, 0x65, 0x78, +0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x20, 0x3a, 0x20, 0x31, 0x30, 0x20, +0x2d, 0x3e, 0x20, 0x31, 0x4b, 0x42, 0x3b, 0x20, 0x31, 0x32, 0x0b, 0x00, +0x80, 0x34, 0x4b, 0x42, 0x20, 0x3b, 0x20, 0x31, 0x36, 0x0c, 0x00, 0x20, +0x36, 0x34, 0x18, 0x00, 0x12, 0x32, 0x23, 0x00, 0x91, 0x4d, 0x42, 0x3b, +0x20, 0x65, 0x74, 0x63, 0x2e, 0x29, 0x66, 0x03, 0x60, 0x6e, 0x63, 0x72, +0x65, 0x61, 0x73, 0xc0, 0x00, 0x18, 0x6d, 0x72, 0x00, 0x20, 0x69, 0x6d, +0xd6, 0x03, 0x29, 0x65, 0x73, 0xce, 0x03, 0x10, 0x72, 0x3f, 0x03, 0x12, +0x0a, 0xcd, 0x08, 0x4a, 0x75, 0x63, 0x65, 0x64, 0x33, 0x00, 0x00, 0x4d, +0x03, 0x03, 0x37, 0x00, 0x00, 0x70, 0x03, 0x70, 0x65, 0x64, 0x2c, 0x20, +0x64, 0x75, 0x65, 0xbc, 0x03, 0xc0, 0x63, 0x61, 0x63, 0x68, 0x65, 0x20, +0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x3f, 0x00, 0xf1, 0x05, 0x44, 0x65, +0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, +0x69, 0x73, 0x20, 0x31, 0x34, 0x2c, 0x20, 0x02, 0xf0, 0x05, 0x31, 0x36, +0x4b, 0x42, 0x2c, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x6e, 0x69, +0x63, 0x65, 0x6c, 0x79, 0x20, 0x66, 0x89, 0x03, 0xf2, 0x02, 0x69, 0x6e, +0x74, 0x6f, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x6c, 0x20, 0x78, 0x38, 0x36, +0x20, 0x4c, 0x31, 0x53, 0x00, 0x1c, 0x0a, 0x2f, 0x02, 0x09, 0x47, 0x01, +0x3f, 0x31, 0x34, 0x0a, 0xc7, 0x01, 0x1a, 0x20, 0x53, 0x69, 0x4c, 0x01, +0x24, 0x20, 0x46, 0xb3, 0x04, 0x0f, 0xc7, 0x01, 0x16, 0x05, 0x4b, 0x02, +0x04, 0x2c, 0x01, 0x22, 0x5f, 0x64, 0xe1, 0x00, 0x60, 0x28, 0x63, 0x6f, +0x6e, 0x73, 0x74, 0x81, 0x03, 0x23, 0x72, 0x2a, 0xeb, 0x05, 0x13, 0x2c, +0x0e, 0x00, 0x50, 0x64, 0x65, 0x73, 0x74, 0x2c, 0xd8, 0x00, 0x03, 0x18, +0x00, 0x42, 0x53, 0x69, 0x7a, 0x65, 0x10, 0x00, 0x70, 0x6d, 0x61, 0x78, +0x44, 0x65, 0x73, 0x74, 0x11, 0x00, 0x25, 0x29, 0x3b, 0x5b, 0x00, 0x25, +0x64, 0x65, 0x5d, 0x00, 0x5f, 0x73, 0x61, 0x66, 0x65, 0x20, 0x5b, 0x00, +0x12, 0x06, 0x1c, 0x05, 0x0b, 0x5f, 0x00, 0x0a, 0x19, 0x00, 0x02, 0xef, +0x02, 0x1f, 0x0a, 0xc2, 0x00, 0x02, 0x12, 0x29, 0xae, 0x06, 0x24, 0x20, +0x43, 0x32, 0x00, 0x36, 0x73, 0x20, 0x27, 0xb2, 0x00, 0x31, 0x27, 0x20, +0x62, 0x89, 0x02, 0x44, 0x66, 0x72, 0x6f, 0x6d, 0xd2, 0x05, 0x03, 0x1f, +0x00, 0x11, 0x27, 0x37, 0x00, 0x01, 0xb9, 0x01, 0xe0, 0x61, 0x6c, 0x72, +0x65, 0x61, 0x64, 0x79, 0x20, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0xd3, +0x0b, 0x10, 0x27, 0xa4, 0x00, 0x14, 0x27, 0x32, 0x00, 0x00, 0x94, 0x0b, +0x57, 0x69, 0x7a, 0x65, 0x20, 0x27, 0xfb, 0x00, 0x29, 0x27, 0x2e, 0x77, +0x00, 0x00, 0x7e, 0x02, 0xa3, 0x69, 0x73, 0x20, 0x67, 0x75, 0x61, 0x72, +0x61, 0x6e, 0x74, 0x13, 0x06, 0x40, 0x73, 0x75, 0x63, 0x63, 0x0b, 0x00, +0x2a, 0x69, 0x66, 0x3b, 0x00, 0x39, 0x20, 0x3e, 0x3d, 0x8f, 0x01, 0x66, +0x42, 0x6f, 0x75, 0x6e, 0x64, 0x28, 0xb6, 0x00, 0x12, 0x29, 0x5c, 0x00, +0xf0, 0x11, 0x49, 0x74, 0x20, 0x61, 0x6c, 0x73, 0x6f, 0x20, 0x72, 0x75, +0x6e, 0x73, 0x20, 0x66, 0x61, 0x73, 0x74, 0x65, 0x72, 0x2c, 0x20, 0x73, +0x6f, 0x20, 0x69, 0x74, 0x27, 0x73, 0x20, 0x61, 0x20, 0x72, 0x26, 0x01, +0x30, 0x6d, 0x65, 0x6e, 0x03, 0x0b, 0x30, 0x73, 0x65, 0x74, 0x51, 0x06, +0x03, 0x38, 0x00, 0x12, 0x66, 0x64, 0x0b, 0x03, 0xdb, 0x06, 0x00, 0xf8, +0x02, 0x26, 0x6e, 0x6f, 0x6d, 0x01, 0x05, 0x01, 0x01, 0x03, 0xfd, 0x00, +0x40, 0x20, 0x6d, 0x6f, 0x72, 0x5e, 0x06, 0x29, 0x6d, 0x69, 0xfa, 0x00, +0x41, 0x64, 0x67, 0x65, 0x74, 0x4e, 0x09, 0x09, 0x62, 0x03, 0xf2, 0x04, +0x73, 0x74, 0x6f, 0x70, 0x73, 0x20, 0x2a, 0x69, 0x6d, 0x6d, 0x65, 0x64, +0x69, 0x61, 0x74, 0x65, 0x6c, 0x79, 0x2a, 0x3a, 0x07, 0x09, 0x72, 0x00, +0x30, 0x72, 0x65, 0x73, 0x3f, 0x03, 0x72, 0x69, 0x73, 0x20, 0x7a, 0x65, +0x72, 0x6f, 0x96, 0x00, 0x10, 0x41, 0xb4, 0x00, 0x00, 0x15, 0x02, 0x50, +0x65, 0x71, 0x75, 0x65, 0x6e, 0x0e, 0x02, 0x03, 0x6b, 0x00, 0x00, 0x62, +0x07, 0x21, 0x65, 0x6e, 0x2e, 0x00, 0x21, 0x6e, 0x6f, 0x74, 0x03, 0x22, +0x69, 0x64, 0x33, 0x00, 0x10, 0x54, 0x46, 0x0c, 0x05, 0x55, 0x00, 0x90, +0x6e, 0x65, 0x76, 0x65, 0x72, 0x20, 0x77, 0x72, 0x69, 0xd1, 0x01, 0x7a, +0x6f, 0x75, 0x74, 0x73, 0x69, 0x64, 0x65, 0xa9, 0x01, 0x60, 0x2c, 0x20, +0x6e, 0x6f, 0x72, 0x20, 0xcc, 0x01, 0x06, 0x20, 0x00, 0x04, 0xec, 0x00, +0x02, 0x22, 0x00, 0x05, 0xf0, 0x0c, 0x07, 0xd6, 0x02, 0xe0, 0x20, 0x20, +0x3a, 0x20, 0x4d, 0x61, 0x78, 0x20, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, +0x04, 0x01, 0x05, 0xf7, 0x03, 0x01, 0xb3, 0x03, 0xe5, 0x41, 0x58, 0x5f, +0x49, 0x4e, 0x50, 0x55, 0x54, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x41, +0x00, 0x07, 0xd1, 0x01, 0x22, 0x20, 0x3a, 0x33, 0x08, 0x20, 0x6f, 0x72, +0x64, 0x05, 0x42, 0x74, 0x69, 0x61, 0x6c, 0x30, 0x02, 0x25, 0x6f, 0x66, +0x74, 0x02, 0x02, 0xa7, 0x00, 0x12, 0x28, 0x3a, 0x04, 0x01, 0x4c, 0x0d, +0x2e, 0x62, 0x65, 0x78, 0x02, 0x15, 0x29, 0x5e, 0x00, 0x81, 0x72, 0x65, +0x74, 0x75, 0x72, 0x6e, 0x20, 0x3a, 0x58, 0x01, 0x12, 0x6e, 0xfb, 0x05, +0x23, 0x6f, 0x66, 0xce, 0x02, 0x00, 0x04, 0x01, 0x32, 0x74, 0x65, 0x6e, +0xc0, 0x01, 0x0b, 0x62, 0x00, 0xe0, 0x6e, 0x65, 0x63, 0x65, 0x73, 0x73, +0x61, 0x72, 0x69, 0x6c, 0x79, 0x20, 0x3c, 0x3d, 0xa6, 0x00, 0x52, 0x4f, +0x75, 0x74, 0x70, 0x75, 0xaf, 0x03, 0x29, 0x0a, 0x20, 0x01, 0x00, 0x40, +0x6f, 0x72, 0x20, 0x30, 0x9d, 0x02, 0x09, 0x11, 0x09, 0x6f, 0x61, 0x69, +0x6c, 0x73, 0x0a, 0x0a, 0xd3, 0x03, 0x00, 0x05, 0x6b, 0x03, 0x0a, 0x9d, +0x03, 0x20, 0x20, 0x3a, 0x2a, 0x01, 0x00, 0xa7, 0x00, 0x72, 0x70, 0x72, +0x65, 0x63, 0x69, 0x73, 0x65, 0x0c, 0x01, 0x04, 0x01, 0x01, 0x29, 0x74, +0x68, 0x03, 0x09, 0x01, 0x82, 0x09, 0x02, 0x86, 0x01, 0x0e, 0xe9, 0x03, +0x07, 0x4c, 0x00, 0x04, 0x3f, 0x00, 0x00, 0xd6, 0x00, 0x22, 0x69, 0x6e, +0x08, 0x0e, 0x04, 0xe5, 0x01, 0x0f, 0x45, 0x01, 0x0c, 0x2f, 0x2e, 0x0a, +0x41, 0x01, 0x0e, 0x17, 0x64, 0x78, 0x00, 0x02, 0x46, 0x01, 0x0e, 0x68, +0x00, 0x0e, 0x4b, 0x01, 0x0f, 0x99, 0x04, 0x00, 0x0a, 0x51, 0x01, 0x1f, +0x49, 0xb0, 0x00, 0x01, 0x04, 0xd8, 0x02, 0xd1, 0x6c, 0x61, 0x72, 0x67, +0x65, 0x20, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x2c, 0x82, 0x00, 0x10, +0x64, 0xd5, 0x06, 0x41, 0x77, 0x69, 0x6c, 0x6c, 0x56, 0x03, 0x01, 0x46, +0x03, 0x11, 0x6f, 0xac, 0x01, 0x92, 0x20, 0x61, 0x6e, 0x20, 0x65, 0x72, +0x72, 0x6f, 0x72, 0x04, 0x10, 0x5d, 0x28, 0x3c, 0x30, 0x29, 0x2e, 0x6a, +0x00, 0x01, 0x26, 0x01, 0x02, 0x9e, 0x0b, 0x60, 0x73, 0x74, 0x72, 0x65, +0x61, 0x6d, 0x69, 0x00, 0x50, 0x64, 0x65, 0x74, 0x65, 0x63, 0xc3, 0x02, +0x30, 0x6d, 0x61, 0x6c, 0x94, 0x07, 0x00, 0xe4, 0x06, 0x09, 0x9a, 0x03, +0x06, 0x6f, 0x00, 0x05, 0x82, 0x00, 0x00, 0x78, 0x00, 0x03, 0x2e, 0x01, +0xa3, 0x61, 0x20, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0xc3, +0x03, 0x0b, 0x77, 0x00, 0x0a, 0x91, 0x03, 0x11, 0x69, 0x84, 0x0f, 0x03, +0x71, 0x00, 0x30, 0x61, 0x67, 0x61, 0x6c, 0x0a, 0x05, 0x33, 0x05, 0xf0, +0x01, 0x76, 0x65, 0x72, 0x66, 0x6c, 0x6f, 0x77, 0x20, 0x65, 0x78, 0x70, +0x6c, 0x6f, 0x69, 0x74, 0x73, 0xdd, 0x05, 0x31, 0x63, 0x6c, 0x75, 0x72, +0x00, 0x92, 0x6d, 0x61, 0x6c, 0x69, 0x63, 0x69, 0x6f, 0x75, 0x73, 0x12, +0x0b, 0x7c, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0xe3, 0x00, 0x1f, +0x74, 0xf2, 0x03, 0x03, 0x03, 0x23, 0x01, 0x0c, 0xf2, 0x03, 0x06, 0x21, +0x00, 0x26, 0x69, 0x6e, 0x20, 0x00, 0x02, 0xf8, 0x0a, 0x0f, 0x65, 0x07, +0x19, 0x50, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x3b, 0x08, 0x0e, 0x67, 0x07, +0x0f, 0x04, 0x0b, 0x19, 0x06, 0x36, 0x04, 0x44, 0x53, 0x49, 0x5a, 0x45, +0xd4, 0x00, 0x51, 0x30, 0x78, 0x37, 0x45, 0x30, 0x01, 0x00, 0x02, 0x73, +0x0a, 0xd3, 0x32, 0x20, 0x31, 0x31, 0x33, 0x20, 0x39, 0x32, 0x39, 0x20, +0x32, 0x31, 0x36, 0x9c, 0x02, 0x0b, 0xaf, 0x0a, 0x31, 0x43, 0x4f, 0x4d, +0x69, 0x10, 0x70, 0x42, 0x4f, 0x55, 0x4e, 0x44, 0x28, 0x69, 0x18, 0x03, +0xe4, 0x29, 0x20, 0x20, 0x28, 0x28, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, +0x65, 0x64, 0x29, 0x14, 0x00, 0x26, 0x3e, 0x20, 0x14, 0x00, 0x0f, 0x82, +0x00, 0x00, 0x64, 0x3f, 0x20, 0x30, 0x20, 0x3a, 0x20, 0x2d, 0x00, 0x33, +0x2b, 0x20, 0x28, 0x0b, 0x00, 0x40, 0x2f, 0x32, 0x35, 0x35, 0x10, 0x00, +0x3d, 0x31, 0x36, 0x29, 0x65, 0x07, 0x02, 0x98, 0x06, 0x04, 0xf7, 0x03, +0x14, 0x50, 0x46, 0x0d, 0x00, 0x51, 0x02, 0x72, 0x6d, 0x61, 0x78, 0x69, +0x6d, 0x75, 0x6d, 0xa8, 0x03, 0x01, 0xf8, 0x12, 0x00, 0xcc, 0x0c, 0x08, +0x49, 0x04, 0x34, 0x6d, 0x61, 0x79, 0xac, 0x01, 0x10, 0x69, 0x5a, 0x02, +0x40, 0x22, 0x77, 0x6f, 0x72, 0x11, 0x08, 0xf2, 0x00, 0x61, 0x73, 0x65, +0x22, 0x20, 0x73, 0x63, 0x65, 0x6e, 0x61, 0x72, 0x69, 0x6f, 0x20, 0x28, +0xae, 0x01, 0x01, 0x08, 0x02, 0x08, 0xa5, 0x06, 0x33, 0x69, 0x62, 0x6c, +0x5e, 0x03, 0x0f, 0x74, 0x02, 0x00, 0x22, 0x69, 0x6d, 0x95, 0x03, 0x61, +0x75, 0x73, 0x65, 0x66, 0x75, 0x6c, 0x99, 0x09, 0x03, 0xe9, 0x09, 0x03, +0x05, 0x04, 0x00, 0x2a, 0x00, 0x50, 0x70, 0x75, 0x72, 0x70, 0x6f, 0x0f, +0x08, 0x1f, 0x28, 0x94, 0x03, 0x00, 0x16, 0x73, 0x66, 0x07, 0x5f, 0x4d, +0x61, 0x63, 0x72, 0x6f, 0x6b, 0x01, 0x00, 0x10, 0x29, 0x6c, 0x00, 0x01, +0x80, 0x07, 0x05, 0x69, 0x12, 0x11, 0x66, 0x92, 0x03, 0x41, 0x6d, 0x70, +0x69, 0x6c, 0x4d, 0x00, 0x70, 0x2d, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x65, +0x2e, 0x06, 0x02, 0x5d, 0x00, 0x6f, 0x28, 0x73, 0x74, 0x61, 0x63, 0x6b, +0x8c, 0x00, 0x00, 0x00, 0x39, 0x00, 0x03, 0x0b, 0x0b, 0x03, 0x76, 0x00, +0x36, 0x4e, 0x6f, 0x74, 0x38, 0x01, 0x0f, 0xd6, 0x08, 0x01, 0x05, 0xae, +0x07, 0x02, 0xf9, 0x07, 0x51, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x5e, 0x04, +0x08, 0xc3, 0x00, 0x00, 0xa3, 0x00, 0x0f, 0x4c, 0x08, 0x03, 0x2a, 0x72, +0x63, 0xa0, 0x04, 0x01, 0x67, 0x01, 0x04, 0xee, 0x06, 0x1f, 0x6d, 0xee, +0x06, 0x11, 0x00, 0x36, 0x02, 0x0e, 0x8f, 0x06, 0x04, 0xf8, 0x01, 0x03, +0xda, 0x01, 0x02, 0x85, 0x00, 0x0f, 0xdf, 0x01, 0x06, 0x0f, 0x70, 0x06, +0x00, 0x10, 0x2c, 0x71, 0x06, 0x26, 0x69, 0x6e, 0x3d, 0x00, 0x53, 0x73, +0x20, 0x74, 0x6f, 0x6f, 0x1e, 0x05, 0x3f, 0x28, 0x20, 0x3e, 0x86, 0x00, +0x00, 0x10, 0x29, 0xc5, 0x03, 0x0c, 0xc3, 0x0a, 0x02, 0xe8, 0x00, 0x00, +0x16, 0x00, 0x05, 0xdb, 0x00, 0x0f, 0x27, 0x0a, 0x01, 0x00, 0x3e, 0x01, +0x05, 0xc2, 0x02, 0x10, 0x53, 0x6a, 0x0f, 0x2f, 0x61, 0x73, 0x73, 0x01, +0x04, 0x00, 0xf6, 0x0d, 0x11, 0x74, 0xb6, 0x01, 0x21, 0x77, 0x73, 0xbe, +0x09, 0x41, 0x65, 0x6c, 0x65, 0x63, 0x8c, 0x05, 0x81, 0x22, 0x61, 0x63, +0x63, 0x65, 0x6c, 0x65, 0x72, 0xcd, 0x01, 0x84, 0x22, 0x20, 0x66, 0x61, +0x63, 0x74, 0x6f, 0x72, 0xa3, 0x08, 0x12, 0x65, 0xbc, 0x00, 0x12, 0x72, +0x44, 0x11, 0x07, 0x29, 0x00, 0x02, 0x59, 0x01, 0x03, 0x80, 0x05, 0x02, +0xc5, 0x01, 0x01, 0x23, 0x00, 0x04, 0x24, 0x17, 0x04, 0x70, 0x00, 0x22, +0x73, 0x6f, 0xdf, 0x0f, 0x00, 0x56, 0x06, 0x19, 0x72, 0x30, 0x07, 0x01, +0xc4, 0x14, 0x02, 0x0a, 0x0a, 0x01, 0xf2, 0x09, 0xa0, 0x74, 0x72, 0x61, +0x64, 0x65, 0x2d, 0x6f, 0x66, 0x66, 0x2e, 0x1e, 0x05, 0x00, 0xcf, 0x0c, +0x31, 0x62, 0x65, 0x20, 0x2a, 0x04, 0x53, 0x74, 0x75, 0x6e, 0x65, 0x64, +0xb9, 0x16, 0x42, 0x65, 0x61, 0x63, 0x68, 0x7b, 0x0a, 0x20, 0x73, 0x73, +0xca, 0x05, 0x02, 0xe0, 0x01, 0x02, 0xc5, 0x02, 0x00, 0x7e, 0x05, 0x10, +0x72, 0x82, 0x06, 0x71, 0x6c, 0x79, 0x20, 0x2b, 0x7e, 0x33, 0x25, 0xe8, +0x00, 0x00, 0x0b, 0x0d, 0x03, 0xa4, 0x09, 0x1f, 0x6e, 0xc2, 0x00, 0x00, +0x00, 0x37, 0x07, 0x35, 0x22, 0x31, 0x22, 0x9a, 0x07, 0x03, 0x45, 0x01, +0x7f, 0x72, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x4d, 0x01, 0x04, 0x01, +0x4f, 0x00, 0x10, 0x56, 0x3f, 0x00, 0x10, 0x73, 0x3c, 0x07, 0x12, 0x30, +0x79, 0x06, 0x11, 0x62, 0x4a, 0x12, 0x20, 0x6c, 0x61, 0x60, 0x05, 0xb0, +0x62, 0x79, 0x20, 0x41, 0x43, 0x43, 0x45, 0x4c, 0x45, 0x52, 0x41, 0x8a, +0x13, 0xc1, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x20, 0x28, +0x73, 0x65, 0xc2, 0x10, 0x34, 0x2e, 0x63, 0x29, 0xeb, 0x07, 0x00, 0x81, +0x0d, 0x1f, 0x2e, 0x05, 0x02, 0x01, 0x01, 0xdf, 0x01, 0x1f, 0x20, 0xc6, +0x0c, 0x2d, 0x02, 0x11, 0x00, 0x08, 0xf9, 0x00, 0x00, 0x4a, 0x02, 0x0f, +0x4b, 0x02, 0x02, 0x9a, 0x5f, 0x65, 0x78, 0x74, 0x53, 0x74, 0x61, 0x74, +0x65, 0x54, 0x02, 0x0f, 0x52, 0x12, 0x01, 0x30, 0x2c, 0x20, 0x6a, 0xa2, +0x08, 0x22, 0x75, 0x73, 0x64, 0x07, 0x12, 0x20, 0xa6, 0x12, 0x38, 0x61, +0x6c, 0x6c, 0x68, 0x0c, 0x03, 0x2b, 0x04, 0x41, 0x73, 0x70, 0x61, 0x63, +0x89, 0x0e, 0x20, 0x73, 0x74, 0x8c, 0x0b, 0x0a, 0x71, 0x0b, 0x32, 0x61, +0x74, 0x65, 0x9e, 0x01, 0x22, 0x55, 0x73, 0x13, 0x06, 0x00, 0x38, 0x03, +0x24, 0x6f, 0x66, 0x87, 0x00, 0xf4, 0x01, 0x74, 0x6f, 0x20, 0x6b, 0x6e, +0x6f, 0x77, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x6d, 0x75, 0x63, 0x68, 0x54, +0x00, 0x06, 0x20, 0x09, 0x03, 0x6d, 0x00, 0x02, 0xcd, 0x0b, 0x00, 0xee, +0x07, 0x04, 0x13, 0x00, 0x92, 0x20, 0x69, 0x74, 0x20, 0x6f, 0x6e, 0x20, +0x38, 0x2d, 0x7a, 0x06, 0x10, 0x62, 0x53, 0x03, 0x20, 0x61, 0x72, 0x34, +0x11, 0x33, 0x28, 0x75, 0x73, 0xa9, 0x07, 0x30, 0x6c, 0x6f, 0x63, 0x65, +0x00, 0x40, 0x79, 0x70, 0x69, 0x63, 0xbc, 0x00, 0x15, 0x29, 0xf7, 0x02, +0x24, 0x6e, 0x2c, 0x19, 0x05, 0x00, 0x47, 0x00, 0x40, 0x61, 0x73, 0x20, +0x27, 0x9a, 0x10, 0x12, 0x2a, 0xb1, 0x00, 0x11, 0x27, 0x56, 0x0f, 0x0f, +0x16, 0x01, 0x00, 0x09, 0xc7, 0x01, 0x08, 0xc9, 0x00, 0x03, 0xd7, 0x10, +0x04, 0x4f, 0x0e, 0x0f, 0x76, 0x01, 0x03, 0x27, 0x20, 0x28, 0x64, 0x00, +0x2f, 0x2c, 0x20, 0xf8, 0x01, 0x11, 0x05, 0x1e, 0x04, 0x0f, 0xf7, 0x01, +0x25, 0x13, 0x64, 0x2f, 0x00, 0x05, 0xf2, 0x01, 0x10, 0x52, 0x96, 0x08, +0x12, 0x73, 0x03, 0x19, 0x60, 0x6c, 0x6f, 0x67, 0x69, 0x63, 0x2c, 0xcc, +0x02, 0x05, 0xed, 0x00, 0x00, 0xee, 0x01, 0x12, 0x73, 0x8a, 0x01, 0x01, +0xd6, 0x06, 0x52, 0x61, 0x73, 0x20, 0x70, 0x6f, 0xd1, 0x06, 0x02, 0x87, +0x0e, 0x0b, 0x93, 0x0c, 0x0f, 0x87, 0x0e, 0x09, 0x0a, 0xdc, 0x0b, 0x05, +0x87, 0x0e, 0x10, 0x74, 0x71, 0x04, 0x1b, 0x74, 0x8a, 0x0e, 0x0a, 0x2d, +0x0d, 0x21, 0x65, 0x69, 0x2e, 0x19, 0x16, 0x63, 0x16, 0x0f, 0x00, 0xaf, +0x00, 0x57, 0x65, 0x6e, 0x74, 0x69, 0x72, 0x15, 0x0d, 0x05, 0x7b, 0x0d, +0x00, 0x7f, 0x00, 0x03, 0x66, 0x00, 0x22, 0x69, 0x66, 0x61, 0x0e, 0x09, +0xb0, 0x0a, 0x13, 0x0a, 0xbf, 0x05, 0x10, 0x66, 0xc6, 0x03, 0x0a, 0x1d, +0x0f, 0x00, 0x63, 0x00, 0x20, 0x6c, 0x65, 0x0a, 0x0e, 0x02, 0x7f, 0x04, +0x0f, 0xfd, 0x00, 0x13, 0x06, 0xed, 0x09, 0x16, 0x2a, 0x9a, 0x03, 0x55, +0x50, 0x74, 0x72, 0x20, 0x3a, 0x2a, 0x04, 0x02, 0x73, 0x1b, 0x02, 0x4a, +0x0f, 0x41, 0x69, 0x6e, 0x64, 0x69, 0xb2, 0x02, 0x01, 0xe6, 0x02, 0x34, +0x61, 0x6e, 0x79, 0x0a, 0x0d, 0x42, 0x68, 0x65, 0x72, 0x65, 0xf2, 0x0d, +0x0a, 0x5c, 0x01, 0x28, 0x74, 0x6f, 0xac, 0x00, 0x0b, 0x5b, 0x0a, 0x08, +0x01, 0x00, 0x36, 0x4e, 0x65, 0x77, 0x02, 0x07, 0x0b, 0xf2, 0x0b, 0x23, +0x6f, 0x6c, 0x1e, 0x07, 0x1e, 0x2e, 0x09, 0x07, 0x2f, 0x4e, 0x62, 0x8d, +0x0d, 0x01, 0x0f, 0x86, 0x0d, 0x04, 0x0a, 0xb1, 0x01, 0x0f, 0x87, 0x0d, +0x17, 0x0e, 0xf3, 0x04, 0x06, 0x90, 0x02, 0x0f, 0xf7, 0x04, 0x12, 0x29, +0x2a, 0x20, 0x5e, 0x01, 0x02, 0xf3, 0x02, 0x0b, 0x8e, 0x00, 0x07, 0xf5, +0x02, 0x2f, 0x64, 0x65, 0x39, 0x07, 0x03, 0x8a, 0x6f, 0x72, 0x69, 0x67, +0x69, 0x6e, 0x61, 0x6c, 0xa4, 0x0d, 0x04, 0x16, 0x00, 0x04, 0x00, 0x10, +0x30, 0x72, 0x65, 0x66, 0xbe, 0x04, 0x27, 0x75, 0x6e, 0x5d, 0x0d, 0x00, +0xb1, 0x02, 0x0f, 0x90, 0x0d, 0x0f, 0x06, 0xc1, 0x01, 0x07, 0xd6, 0x0c, +0x04, 0x87, 0x0d, 0x23, 0x69, 0x6e, 0xfb, 0x1b, 0x6c, 0x77, 0x6f, 0x72, +0x64, 0x73, 0x2c, 0x52, 0x0e, 0x01, 0xcb, 0x09, 0x0f, 0x1e, 0x0d, 0x72, +0x1e, 0x44, 0x68, 0x0a, 0x0f, 0xa5, 0x0e, 0x07, 0x42, 0x20, 0x49, 0x74, +0x73, 0xcf, 0x03, 0x05, 0x24, 0x00, 0x42, 0x20, 0x6d, 0x69, 0x6e, 0x5d, +0x09, 0x38, 0x66, 0x20, 0x27, 0x73, 0x01, 0x03, 0xc6, 0x12, 0x02, 0x6f, +0x00, 0x10, 0x6e, 0x3a, 0x0a, 0x1b, 0x3a, 0xef, 0x03, 0x00, 0x73, 0x0f, +0x23, 0x79, 0x20, 0x5a, 0x18, 0x04, 0x02, 0x06, 0x07, 0xd0, 0x05, 0x00, +0x81, 0x0a, 0x20, 0x70, 0x72, 0x94, 0x18, 0x12, 0x6c, 0xd0, 0x1d, 0x2c, +0x65, 0x64, 0x99, 0x18, 0x2a, 0x2e, 0x0a, 0x7d, 0x0d, 0x00, 0xfe, 0x0a, +0x46, 0x20, 0x62, 0x69, 0x74, 0xbc, 0x08, 0x3f, 0x61, 0x6e, 0x20, 0x17, +0x10, 0x02, 0x09, 0x3a, 0x00, 0x30, 0x48, 0x6f, 0x77, 0x20, 0x05, 0x10, +0x2c, 0x15, 0x06, 0x32, 0x64, 0x6f, 0x65, 0xfc, 0x0e, 0x04, 0x29, 0x06, +0x00, 0xb9, 0x03, 0x03, 0x33, 0x0e, 0x01, 0xd9, 0x1d, 0x03, 0x34, 0x0e, +0x11, 0x69, 0x86, 0x04, 0x22, 0x69, 0x6f, 0x1e, 0x07, 0x05, 0xf8, 0x03, +0x01, 0x42, 0x04, 0x03, 0xbe, 0x01, 0x16, 0x28, 0x34, 0x0e, 0x01, 0xd2, +0x05, 0x0a, 0x75, 0x00, 0x00, 0x1a, 0x07, 0x1a, 0x74, 0x28, 0x0c, 0x60, +0x6e, 0x20, 0x74, 0x72, 0x75, 0x73, 0xed, 0x01, 0x71, 0x65, 0x6e, 0x76, +0x69, 0x72, 0x6f, 0x6e, 0xbe, 0x17, 0x61, 0x6f, 0x6e, 0x6c, 0x79, 0x20, +0x28, 0x59, 0x00, 0x22, 0x74, 0x6f, 0xe5, 0x01, 0x01, 0x4d, 0x02, 0x04, +0x23, 0x14, 0x15, 0x61, 0x36, 0x00, 0x02, 0x3d, 0x02, 0x19, 0x29, 0xb0, +0x06, 0x2f, 0x64, 0x65, 0x79, 0x08, 0x20, 0x08, 0xc9, 0x01, 0x2f, 0x29, +0x3b, 0x6b, 0x03, 0x01, 0x00, 0x46, 0x01, 0x13, 0x5f, 0x39, 0x12, 0x05, +0x73, 0x03, 0x0a, 0xcf, 0x05, 0x06, 0x2e, 0x00, 0x2d, 0x20, 0x61, 0x4f, +0x11, 0x06, 0x19, 0x06, 0x0a, 0x9e, 0x10, 0x10, 0x27, 0xcc, 0x1b, 0x01, +0xb8, 0x1b, 0x00, 0x43, 0x00, 0x0e, 0xf7, 0x14, 0x0e, 0xf4, 0x10, 0x0d, +0x6a, 0x06, 0x0f, 0xf4, 0x10, 0x00, 0x05, 0x6f, 0x06, 0x07, 0x38, 0x03, +0x11, 0x74, 0x65, 0x02, 0x26, 0x74, 0x6f, 0x3c, 0x03, 0x06, 0x0d, 0x07, +0x24, 0x6f, 0x70, 0x4e, 0x0a, 0x52, 0x61, 0x73, 0x20, 0x73, 0x6f, 0x08, +0x00, 0x03, 0xc3, 0x06, 0x06, 0x9b, 0x12, 0x90, 0x27, 0x20, 0x68, 0x61, +0x73, 0x20, 0x62, 0x65, 0x65, 0x3d, 0x14, 0x00, 0x3b, 0x17, 0x03, 0xaf, +0x08, 0x10, 0x72, 0xc9, 0x17, 0x01, 0x28, 0x20, 0x18, 0x65, 0x1f, 0x05, +0x00, 0x7a, 0x0d, 0x0f, 0xe8, 0x11, 0x14, 0x00, 0xb9, 0x0d, 0x04, 0x57, +0x20, 0x0f, 0xe5, 0x11, 0x2b, 0x12, 0x4e, 0x7a, 0x03, 0x01, 0x69, 0x02, +0x03, 0x6a, 0x00, 0x03, 0x84, 0x0b, 0x1f, 0x3c, 0xd1, 0x00, 0x01, 0x6f, +0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x01, 0x13, 0x02, 0x07, 0x7d, 0x02, +0x40, 0x62, 0x65, 0x20, 0x73, 0x67, 0x09, 0x2b, 0x65, 0x72, 0x4e, 0x04, +0x65, 0x41, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x80, 0x1c, 0x0c, 0xf9, 0x06, +0x00, 0xf8, 0x06, 0x03, 0xdf, 0x00, 0x0f, 0x1c, 0x12, 0x81, 0x0f, 0xbb, +0x11, 0x03, 0x1c, 0x66, 0xbe, 0x11, 0x00, 0x60, 0x00, 0x02, 0x2b, 0x00, +0x0a, 0xc4, 0x11, 0x2a, 0x6f, 0x66, 0xc7, 0x11, 0x03, 0x91, 0x04, 0x06, +0x65, 0x06, 0x0e, 0x79, 0x12, 0x0f, 0x55, 0x12, 0x03, 0x0e, 0xbf, 0x03, +0x0d, 0x73, 0x03, 0x0f, 0xab, 0x18, 0x27, 0x0c, 0xf4, 0x01, 0x0f, 0xc1, +0x18, 0x0a, 0x0e, 0x85, 0x12, 0x0f, 0xf3, 0x19, 0x11, 0x01, 0xbe, 0x01, +0x00, 0x8a, 0x01, 0x08, 0x69, 0x18, 0x0f, 0x9b, 0x12, 0x00, 0x0f, 0xa4, +0x12, 0x21, 0x60, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4d, 0x62, 0x0f, 0xdc, +0x5f, 0x55, 0x36, 0x34, 0x20, 0x28, 0x28, 0x31, 0x20, 0x3c, 0x3c, 0x20, +0x28, 0xa8, 0x1a, 0x30, 0x2d, 0x33, 0x29, 0x21, 0x12, 0x2f, 0x34, 0x29, +0x3d, 0x00, 0x04, 0x01, 0xfe, 0x01, 0x1f, 0x28, 0x51, 0x00, 0x00, 0x22, +0x2a, 0x20, 0xe1, 0x0b, 0x60, 0x28, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x05, +0x00, 0x27, 0x29, 0x29, 0x53, 0x1c, 0x02, 0x9a, 0x02, 0x11, 0x5f, 0x71, +0x1b, 0x20, 0x69, 0x6e, 0x92, 0x02, 0x02, 0x9a, 0x03, 0x81, 0x73, 0x74, +0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x11, 0x0d, 0x20, 0x74, 0x72, 0x52, +0x11, 0x02, 0x7a, 0x06, 0x03, 0xcc, 0x02, 0x01, 0x7d, 0x1f, 0x20, 0x69, +0x6d, 0xbe, 0x10, 0x30, 0x61, 0x6e, 0x74, 0x8f, 0x08, 0x32, 0x6e, 0x69, +0x74, 0x96, 0x03, 0x06, 0x3b, 0x00, 0x04, 0xda, 0x0a, 0x12, 0x62, 0x2f, +0x02, 0x31, 0x66, 0x69, 0x72, 0x8c, 0x0d, 0x30, 0x65, 0x20, 0x21, 0x3e, +0x00, 0x03, 0x44, 0x07, 0x29, 0x6f, 0x6e, 0x8d, 0x0d, 0x82, 0x64, 0x69, +0x72, 0x65, 0x63, 0x74, 0x6c, 0x79, 0x3f, 0x03, 0x05, 0x4b, 0x00, 0x12, +0x69, 0xe8, 0x1f, 0x00, 0xf4, 0x25, 0x00, 0x78, 0x0c, 0x02, 0x08, 0x0d, +0x53, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0xc3, 0x1f, 0x00, 0x52, 0x00, 0x06, +0x7c, 0x03, 0x04, 0x2c, 0x00, 0x02, 0x42, 0x0d, 0x60, 0x6c, 0x69, 0x62, +0x6c, 0x7a, 0x34, 0xf3, 0x04, 0x59, 0x61, 0x20, 0x44, 0x4c, 0x4c, 0xa7, +0x1f, 0x20, 0x62, 0x65, 0x21, 0x15, 0x01, 0x7d, 0x02, 0x00, 0x6c, 0x00, +0x01, 0x35, 0x13, 0x66, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0xb7, 0x1f, +0x00, 0x0f, 0x14, 0x73, 0x74, 0x79, 0x70, 0x65, 0x64, 0x65, 0x66, 0x93, +0x00, 0x35, 0x20, 0x7b, 0x20, 0x50, 0x01, 0x20, 0x20, 0x74, 0x63, 0x20, +0x1e, 0x5b, 0x7c, 0x01, 0x49, 0x5d, 0x3b, 0x20, 0x7d, 0x65, 0x01, 0x27, +0x3b, 0x0a, 0x7a, 0x01, 0x52, 0x72, 0x65, 0x73, 0x65, 0x74, 0x5b, 0x02, +0x00, 0x13, 0x00, 0x0e, 0x3e, 0x07, 0x22, 0x74, 0x6f, 0x55, 0x01, 0x27, +0x61, 0x6e, 0x1f, 0x01, 0x08, 0x4f, 0x00, 0x06, 0x1f, 0x01, 0x01, 0xa2, +0x00, 0x00, 0x96, 0x0d, 0x0c, 0x5a, 0x00, 0x28, 0x20, 0x28, 0x31, 0x00, +0x13, 0x2a, 0xbd, 0x01, 0x49, 0x50, 0x74, 0x72, 0x29, 0x8c, 0x00, 0x00, +0xde, 0x1d, 0x23, 0x74, 0x65, 0x33, 0x00, 0x01, 0x82, 0x04, 0x05, 0x9e, +0x0e, 0x00, 0x1d, 0x04, 0x00, 0x87, 0x00, 0x30, 0x69, 0x61, 0x6c, 0x8d, +0x06, 0x2f, 0x61, 0x6e, 0x83, 0x00, 0x07, 0x01, 0x1a, 0x00, 0x34, 0x66, +0x72, 0x65, 0x49, 0x00, 0x21, 0x72, 0x65, 0x67, 0x01, 0x11, 0x73, 0x26, +0x21, 0x02, 0x0f, 0x09, 0x02, 0xb4, 0x21, 0x02, 0x09, 0x06, 0x01, 0x1e, +0x02, 0x11, 0x78, 0x9d, 0x26, 0x01, 0x97, 0x01, 0x22, 0x20, 0x28, 0xa8, +0x01, 0x19, 0x29, 0xa0, 0x01, 0x55, 0x74, 0x68, 0x65, 0x73, 0x65, 0x93, +0x01, 0x44, 0x72, 0x61, 0x74, 0x68, 0x07, 0x09, 0x24, 0x74, 0x68, 0x0c, +0x02, 0x03, 0x86, 0x00, 0x01, 0x5d, 0x00, 0x41, 0x54, 0x68, 0x65, 0x79, +0xfb, 0x01, 0x01, 0x51, 0x1b, 0x42, 0x66, 0x75, 0x74, 0x75, 0xa9, 0x04, +0x20, 0x6f, 0x66, 0x19, 0x04, 0x01, 0x1b, 0x13, 0x02, 0x72, 0x00, 0x02, +0xf1, 0x20, 0x00, 0x0c, 0x00, 0x0a, 0xd1, 0x00, 0x32, 0x69, 0x7a, 0x65, +0xf2, 0x01, 0x0a, 0x3a, 0x01, 0x0c, 0x27, 0x01, 0x08, 0x2c, 0x0f, 0x06, +0x01, 0x00, 0x0b, 0x02, 0x01, 0x0f, 0x7e, 0x01, 0x13, 0x8f, 0x6c, 0x6f, +0x61, 0x64, 0x44, 0x69, 0x63, 0x74, 0x07, 0x02, 0x06, 0x00, 0x21, 0x00, +0x24, 0x20, 0x61, 0xed, 0x00, 0x21, 0x64, 0x69, 0x19, 0x00, 0x00, 0x86, +0x22, 0x01, 0x42, 0x08, 0x06, 0x64, 0x00, 0x01, 0x95, 0x03, 0x11, 0x41, +0xdf, 0x09, 0x26, 0x65, 0x76, 0x86, 0x05, 0x04, 0xcc, 0x0d, 0x50, 0x66, +0x6f, 0x72, 0x67, 0x6f, 0x27, 0x0d, 0x12, 0x2c, 0x75, 0x03, 0x16, 0x27, +0x4a, 0x00, 0x12, 0x27, 0x25, 0x00, 0x30, 0x72, 0x65, 0x6d, 0xe4, 0x28, +0x28, 0x69, 0x6e, 0xaf, 0x01, 0x32, 0x4c, 0x6f, 0x61, 0x87, 0x06, 0x05, +0x10, 0x1a, 0x12, 0x30, 0x96, 0x15, 0x31, 0x6c, 0x6f, 0x77, 0xf8, 0x06, +0x00, 0xea, 0x1f, 0x03, 0x00, 0x08, 0x07, 0x9c, 0x00, 0x13, 0x73, 0x8c, +0x05, 0x03, 0x2c, 0x07, 0x0c, 0xe4, 0x07, 0x50, 0x36, 0x34, 0x20, 0x4b, +0x42, 0x5d, 0x20, 0x06, 0x1b, 0x06, 0x04, 0x08, 0x01, 0x0f, 0x37, 0x01, +0x06, 0x0a, 0x6d, 0x10, 0x06, 0x6c, 0x00, 0x02, 0xf3, 0x05, 0x00, 0x10, +0x00, 0x07, 0xe0, 0x09, 0x2f, 0x20, 0x2a, 0xc4, 0x10, 0x00, 0x00, 0x74, +0x02, 0x31, 0x69, 0x6e, 0x75, 0xae, 0x02, 0x04, 0xcd, 0x05, 0x08, 0x65, +0x24, 0x00, 0xae, 0x04, 0x63, 0x27, 0x73, 0x72, 0x63, 0x27, 0x2c, 0x3b, +0x04, 0x01, 0x41, 0x01, 0x01, 0x96, 0x0a, 0x04, 0x54, 0x01, 0x2d, 0x6c, +0x79, 0x4a, 0x08, 0x10, 0x73, 0x5b, 0x04, 0x07, 0xfb, 0x00, 0x25, 0x74, +0x6f, 0xe3, 0x20, 0x0d, 0x19, 0x21, 0x02, 0x02, 0x03, 0x07, 0x39, 0x05, +0x19, 0x50, 0xac, 0x01, 0x04, 0x50, 0x00, 0x10, 0x72, 0xdf, 0x13, 0x33, +0x73, 0x75, 0x6d, 0xc4, 0x1e, 0x13, 0x74, 0xc3, 0x01, 0x00, 0x4c, 0x00, +0x00, 0xa4, 0x00, 0x01, 0x41, 0x2b, 0x15, 0x6e, 0xa5, 0x0b, 0x01, 0x50, +0x05, 0x27, 0x27, 0x64, 0x11, 0x10, 0x0f, 0x99, 0x1b, 0x09, 0x01, 0x36, +0x25, 0x00, 0x21, 0x07, 0x03, 0xc4, 0x0e, 0x0f, 0xbd, 0x16, 0x0a, 0x00, +0x74, 0x01, 0x0f, 0x5e, 0x1f, 0x0f, 0x02, 0x45, 0x08, 0x07, 0x24, 0x1f, +0x04, 0x67, 0x00, 0x32, 0x6e, 0x6f, 0x74, 0x1c, 0x00, 0x2d, 0x69, 0x66, +0x85, 0x25, 0x03, 0x13, 0x1f, 0x25, 0x66, 0x69, 0xfc, 0x10, 0x07, 0xc1, +0x00, 0x02, 0x3f, 0x02, 0x0d, 0xf6, 0x1e, 0x02, 0x4d, 0x00, 0x07, 0xe4, +0x1e, 0x00, 0x79, 0x02, 0x00, 0xd8, 0x05, 0x03, 0xe4, 0x1e, 0x07, 0x4f, +0x02, 0x0f, 0xfa, 0x01, 0x03, 0x0f, 0x5d, 0x02, 0x14, 0x35, 0x73, 0x72, +0x63, 0x7f, 0x08, 0x05, 0xbe, 0x14, 0x2a, 0x72, 0x63, 0x61, 0x08, 0x0f, +0xc3, 0x12, 0x09, 0x07, 0x63, 0x07, 0x34, 0x61, 0x76, 0x65, 0xdf, 0x03, +0x2f, 0x49, 0x66, 0x48, 0x02, 0x04, 0x06, 0xfd, 0x01, 0x04, 0xab, 0x1c, +0x0a, 0x68, 0x01, 0x03, 0x9a, 0x03, 0x51, 0x61, 0x76, 0x61, 0x69, 0x6c, +0xd2, 0x26, 0x27, 0x61, 0x74, 0x57, 0x05, 0x14, 0x20, 0xe5, 0x18, 0x00, +0x64, 0x00, 0x00, 0x70, 0x00, 0x14, 0x20, 0x54, 0x01, 0x20, 0x61, 0x20, +0x66, 0x09, 0x21, 0x72, 0x20, 0xf0, 0x15, 0x23, 0x20, 0x28, 0xdd, 0x00, +0x41, 0x61, 0x66, 0x65, 0x42, 0x67, 0x01, 0x01, 0xde, 0x23, 0x03, 0x53, +0x0b, 0x00, 0x34, 0x07, 0x55, 0x64, 0x6f, 0x6e, 0x27, 0x74, 0x4e, 0x27, +0x00, 0x65, 0x07, 0x09, 0x9a, 0x03, 0xa0, 0x28, 0x29, 0x20, 0x61, 0x66, +0x74, 0x65, 0x72, 0x77, 0x61, 0x05, 0x10, 0x07, 0x73, 0x07, 0x08, 0x94, +0x04, 0x27, 0x73, 0x20, 0x99, 0x20, 0x00, 0xf6, 0x23, 0x63, 0x62, 0x6c, +0x65, 0x2c, 0x20, 0x79, 0xed, 0x28, 0x06, 0x3e, 0x0a, 0x05, 0x5e, 0x00, +0x0f, 0xa9, 0x01, 0x03, 0x29, 0x28, 0x29, 0x5a, 0x04, 0x00, 0xd6, 0x00, +0x1c, 0x64, 0x60, 0x04, 0x0f, 0x5f, 0x04, 0x07, 0x05, 0x0d, 0x04, 0x15, +0x2c, 0xda, 0x11, 0x01, 0xcd, 0x1d, 0x09, 0x22, 0x02, 0x04, 0x9a, 0x01, +0x0f, 0x71, 0x04, 0x09, 0x0b, 0x31, 0x01, 0x0e, 0x6b, 0x04, 0x0e, 0x53, +0x0a, 0x0f, 0x54, 0x0a, 0x1b, 0x06, 0xa7, 0x0a, 0x0f, 0x56, 0x0a, 0x2a, +0x00, 0x63, 0x1d, 0x0e, 0x1b, 0x0a, 0x65, 0x44, 0x45, 0x43, 0x4f, 0x44, +0x45, 0x0d, 0x0a, 0x2f, 0x20, 0x34, 0x24, 0x00, 0x0a, 0x0c, 0x45, 0x0a, +0x0b, 0x3e, 0x00, 0x05, 0x4b, 0x0a, 0x04, 0xe3, 0x1c, 0x18, 0x20, 0x54, +0x0a, 0x0d, 0x21, 0x09, 0x0e, 0x26, 0x00, 0x0d, 0x2a, 0x09, 0x0a, 0x61, +0x00, 0x0b, 0x30, 0x09, 0x11, 0x44, 0x59, 0x0d, 0x00, 0x36, 0x09, 0x0c, +0xaf, 0x0a, 0x04, 0x1a, 0x00, 0x0f, 0xb5, 0x0a, 0x23, 0x0f, 0xa9, 0x0a, +0x08, 0x23, 0x75, 0x73, 0x4e, 0x0a, 0x15, 0x5f, 0x42, 0x09, 0x02, 0x6c, +0x00, 0x12, 0x20, 0xde, 0x1c, 0x20, 0x73, 0x65, 0x03, 0x03, 0x0f, 0xcf, +0x0a, 0x02, 0x0f, 0xd9, 0x08, 0x11, 0x04, 0xd8, 0x08, 0x30, 0x70, 0x72, +0x65, 0x94, 0x03, 0x02, 0x11, 0x27, 0x2f, 0x6f, 0x66, 0x7e, 0x0a, 0x03, +0x01, 0x99, 0x0a, 0x0f, 0xd3, 0x08, 0x2f, 0x04, 0x2c, 0x01, 0x05, 0x30, +0x03, 0x24, 0x74, 0x68, 0x44, 0x00, 0x1f, 0x2e, 0xff, 0x09, 0x01, 0x03, +0xf0, 0x00, 0x0f, 0x05, 0x0a, 0x17, 0x06, 0x61, 0x00, 0x0f, 0x0b, 0x0a, +0x07, 0x03, 0x55, 0x00, 0x0f, 0x11, 0x0a, 0x04, 0x2e, 0x2f, 0x0a, 0x4e, +0x00, 0x0f, 0x99, 0x00, 0x05, 0x0e, 0x77, 0x09, 0x0f, 0x7d, 0x09, 0x05, +0x03, 0x74, 0x00, 0x1f, 0x28, 0x5c, 0x00, 0x05, 0x02, 0x14, 0x00, 0x0b, +0xab, 0x05, 0x0a, 0xf6, 0x01, 0x0f, 0x98, 0x0b, 0x08, 0x03, 0xe6, 0x02, +0x02, 0xfb, 0x16, 0x01, 0xe8, 0x16, 0x03, 0x7f, 0x25, 0x06, 0xa2, 0x04, +0x01, 0x5f, 0x01, 0x12, 0x53, 0x14, 0x26, 0x0f, 0x3d, 0x09, 0x04, 0x21, +0x20, 0x28, 0xc9, 0x1b, 0x02, 0xf4, 0x28, 0x02, 0xd0, 0x1b, 0x4a, 0x73, +0x65, 0x74, 0x29, 0x54, 0x09, 0x10, 0x31, 0xbd, 0x04, 0x3f, 0x4f, 0x4b, +0x2c, 0xc6, 0x04, 0x06, 0x2f, 0x65, 0x74, 0xf2, 0x00, 0x19, 0x02, 0x14, +0x00, 0x0f, 0x4b, 0x09, 0x1a, 0x17, 0x2a, 0x95, 0x05, 0x05, 0x1a, 0x13, +0x00, 0x97, 0x0b, 0x05, 0xa3, 0x10, 0x05, 0xc2, 0x2d, 0x02, 0xda, 0x00, +0x0b, 0x29, 0x12, 0x80, 0x6f, 0x66, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, +0x39, 0x29, 0x03, 0xe1, 0x08, 0x54, 0x69, 0x6e, 0x20, 0x22, 0x73, 0x04, +0x05, 0x10, 0x22, 0x6f, 0x14, 0x03, 0x4b, 0x12, 0x16, 0x50, 0x1f, 0x07, +0x04, 0x39, 0x12, 0x03, 0x64, 0x09, 0x10, 0x2a, 0xd4, 0x08, 0x1f, 0x2a, +0x0a, 0x07, 0x02, 0x01, 0x0d, 0x21, 0x02, 0x0a, 0x07, 0x05, 0x6b, 0x13, +0x03, 0x9b, 0x01, 0x00, 0x3c, 0x03, 0x08, 0xa8, 0x11, 0x40, 0x20, 0x28, +0x75, 0x70, 0xb1, 0x01, 0x04, 0x80, 0x0a, 0x25, 0x20, 0x20, 0xb7, 0x03, +0x05, 0x48, 0x03, 0x10, 0x72, 0xd3, 0x00, 0x02, 0x88, 0x08, 0x17, 0x73, +0x26, 0x24, 0x0b, 0x5b, 0x09, 0x03, 0xde, 0x19, 0x02, 0x10, 0x01, 0x51, +0x2d, 0x20, 0x45, 0x78, 0x61, 0xb8, 0x0e, 0x01, 0xd2, 0x01, 0x01, 0x3a, +0x25, 0x59, 0x61, 0x73, 0x20, 0x65, 0x6e, 0x3c, 0x00, 0x03, 0x1d, 0x1e, +0x01, 0x23, 0x00, 0x30, 0x75, 0x70, 0x64, 0x5b, 0x03, 0x62, 0x72, 0x75, +0x6c, 0x65, 0x20, 0x28, 0xfa, 0x07, 0x07, 0x2c, 0x16, 0x22, 0x61, 0x74, +0x26, 0x00, 0x04, 0xcf, 0x00, 0x14, 0x73, 0x01, 0x13, 0x23, 0x49, 0x6e, +0x90, 0x1d, 0x00, 0xaf, 0x00, 0x02, 0x3c, 0x12, 0x05, 0x86, 0x01, 0x16, +0x26, 0x70, 0x00, 0x07, 0xc3, 0x00, 0x01, 0x77, 0x07, 0x32, 0x68, 0x61, +0x76, 0xfa, 0x15, 0x04, 0x97, 0x0b, 0x04, 0x07, 0x24, 0x42, 0x76, 0x65, +0x72, 0x79, 0xfd, 0x12, 0x30, 0x20, 0x6f, 0x6e, 0x49, 0x07, 0x23, 0x20, +0x3c, 0x1c, 0x01, 0x13, 0x2e, 0xd9, 0x00, 0x14, 0x4c, 0x5a, 0x1f, 0x2e, +0x61, 0x6e, 0xd0, 0x00, 0x2a, 0x62, 0x79, 0x33, 0x17, 0x40, 0x6d, 0x61, +0x78, 0x42, 0xcc, 0x00, 0x01, 0x59, 0x0a, 0x01, 0xb0, 0x04, 0x07, 0x36, +0x17, 0x1a, 0x20, 0x1f, 0x00, 0x01, 0x2a, 0x08, 0x36, 0x70, 0x6c, 0x65, +0x65, 0x34, 0x30, 0x64, 0x65, 0x70, 0x4b, 0x29, 0x32, 0x6e, 0x74, 0x2e, +0x6e, 0x1f, 0x0d, 0xe5, 0x22, 0x00, 0x46, 0x08, 0x01, 0xa9, 0x16, 0x18, +0x64, 0xdc, 0x1c, 0x05, 0xeb, 0x08, 0x34, 0x69, 0x6e, 0x67, 0x63, 0x02, +0x1f, 0x2e, 0x30, 0x01, 0x03, 0x27, 0x65, 0x6e, 0x55, 0x13, 0x0b, 0xda, +0x01, 0x41, 0x73, 0x20, 0x64, 0x6f, 0x7b, 0x09, 0x04, 0x00, 0x09, 0x00, +0x17, 0x14, 0x94, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, +0x0d, 0x15, 0x02, 0xbe, 0x1d, 0x0f, 0x69, 0x01, 0x1f, 0x0f, 0x64, 0x01, +0x0a, 0x40, 0x5f, 0x41, 0x74, 0x20, 0x1c, 0x05, 0x22, 0x74, 0x5f, 0x19, +0x00, 0x43, 0x20, 0x2b, 0x20, 0x38, 0xda, 0x08, 0x19, 0x2b, 0x35, 0x01, +0x0f, 0xd7, 0x00, 0x7e, 0x17, 0x6c, 0x1e, 0x02, 0x0b, 0x79, 0x00, 0x02, +0xac, 0x00, 0x32, 0x57, 0x68, 0x65, 0x5d, 0x14, 0x02, 0xca, 0x0f, 0x0a, +0x8c, 0x37, 0x02, 0x99, 0x18, 0x03, 0x9d, 0x1c, 0x12, 0x2c, 0xbb, 0x0a, +0x01, 0xd3, 0x1d, 0x00, 0xda, 0x17, 0x00, 0x90, 0x2e, 0x02, 0x7f, 0x28, +0x02, 0xba, 0x03, 0x01, 0x24, 0x0b, 0x07, 0xd6, 0x0a, 0x04, 0x85, 0x02, +0x05, 0x53, 0x1f, 0x05, 0xa1, 0x1c, 0x02, 0xfc, 0x03, 0x11, 0x69, 0xaf, +0x14, 0x02, 0x39, 0x0a, 0x0f, 0xda, 0x07, 0x06, 0x2f, 0x28, 0x29, 0x9e, +0x14, 0x09, 0x0e, 0x36, 0x0c, 0x0f, 0x55, 0x05, 0x0b, 0x0f, 0x70, 0x2d, +0x3b, 0x0f, 0xf3, 0x18, 0x04, 0x0f, 0x96, 0x00, 0x42, 0x0c, 0x22, 0x19, +0x00, 0xf8, 0x05, 0x05, 0x87, 0x27, 0x0f, 0xe8, 0x05, 0x00, 0x41, 0x3a, +0x0a, 0x2a, 0x5f, 0x55, 0x01, 0x03, 0x18, 0x0c, 0x0f, 0x17, 0x06, 0x0c, +0x48, 0x77, 0x6f, 0x72, 0x6b, 0xba, 0x22, 0x02, 0xb4, 0x01, 0x00, 0x0c, +0x01, 0x14, 0x62, 0x0d, 0x18, 0x2f, 0x6f, 0x66, 0xa0, 0x01, 0x03, 0x03, +0xa8, 0x38, 0x02, 0xae, 0x22, 0x0b, 0x0f, 0x01, 0x19, 0x78, 0x2f, 0x0c, +0x26, 0x20, 0x20, 0x2c, 0x09, 0xc2, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x2d, +0x61, 0x6c, 0x6f, 0x6e, 0x65, 0x2e, 0x16, 0x00, 0x07, 0xdc, 0x0c, 0x00, +0xb0, 0x28, 0x03, 0x80, 0x05, 0x0f, 0xcc, 0x08, 0x0c, 0x1f, 0x2e, 0x1e, +0x02, 0x09, 0x05, 0x00, 0x01, 0x0f, 0x69, 0x2f, 0x3a, 0x0e, 0x9b, 0x07, +0x5d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x9a, 0x07, 0x0f, 0x1e, 0x02, 0x05, +0x0e, 0x96, 0x00, 0x0f, 0x1b, 0x1b, 0x12, 0x0f, 0x7b, 0x00, 0x19, 0x0f, +0xce, 0x29, 0x1b, 0x40, 0x4f, 0x62, 0x73, 0x6f, 0x9d, 0x20, 0x0f, 0xce, +0x29, 0x20, 0x10, 0x2f, 0x07, 0x32, 0x00, 0xd3, 0x2c, 0x00, 0xab, 0x01, +0x30, 0x57, 0x61, 0x72, 0x43, 0x33, 0x22, 0x73, 0x20, 0x19, 0x00, 0x15, +0x53, 0xdb, 0x19, 0x44, 0x73, 0x65, 0x20, 0x77, 0x1c, 0x00, 0x10, 0x6d, +0x06, 0x0e, 0x00, 0xc9, 0x34, 0x01, 0xcd, 0x1d, 0x71, 0x70, 0x72, 0x6f, +0x62, 0x6c, 0x65, 0x6d, 0x23, 0x04, 0x02, 0x0f, 0x04, 0x02, 0x22, 0x36, +0x00, 0x3d, 0x16, 0x05, 0x14, 0x21, 0x00, 0x08, 0x1a, 0x11, 0x69, 0xa7, +0x0e, 0x00, 0x4d, 0x00, 0x02, 0x2d, 0x00, 0x01, 0xa8, 0x07, 0x64, 0x2d, +0x57, 0x6e, 0x6f, 0x2d, 0x64, 0x80, 0x00, 0x72, 0x64, 0x2d, 0x64, 0x65, +0x63, 0x6c, 0x61, 0xe3, 0x0f, 0x02, 0xce, 0x1d, 0x42, 0x67, 0x63, 0x63, +0x0a, 0x3c, 0x20, 0x70, 0x5f, 0x43, 0x52, 0x54, 0x5f, 0x53, 0x45, 0x2f, +0x39, 0xc0, 0x5f, 0x4e, 0x4f, 0x5f, 0x57, 0x41, 0x52, 0x4e, 0x49, 0x4e, +0x47, 0x53, 0xe8, 0x08, 0x68, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x7f, +0x28, 0x18, 0x2e, 0xfe, 0x37, 0x01, 0x7c, 0x26, 0x07, 0x95, 0x0d, 0x94, +0x44, 0x45, 0x50, 0x52, 0x45, 0x43, 0x41, 0x54, 0x45, 0x45, 0x00, 0x00, +0x95, 0x25, 0x61, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x2e, 0x97, 0x2a, 0x30, +0x69, 0x66, 0x6e, 0x67, 0x0d, 0x0f, 0x2b, 0x00, 0x0b, 0x3e, 0x0a, 0x23, +0x20, 0x54, 0x00, 0x0f, 0x29, 0x00, 0x10, 0x34, 0x47, 0x43, 0x43, 0x04, +0x35, 0x00, 0xe0, 0x37, 0x92, 0x47, 0x4e, 0x55, 0x43, 0x5f, 0x5f, 0x20, +0x2a, 0x20, 0x22, 0x35, 0x03, 0x11, 0x00, 0x01, 0x36, 0x35, 0x30, 0x5f, +0x5f, 0x29, 0x3c, 0x00, 0x4c, 0x69, 0x66, 0x20, 0x28, 0x39, 0x00, 0xa4, +0x3e, 0x3d, 0x20, 0x34, 0x30, 0x35, 0x29, 0x20, 0x7c, 0x7c, 0x2c, 0x38, +0x00, 0x2b, 0x38, 0x43, 0x6c, 0x61, 0x6e, 0x67, 0x35, 0x00, 0x0f, 0x9c, +0x00, 0x03, 0x23, 0x44, 0x28, 0xbc, 0x01, 0x62, 0x29, 0x20, 0x5f, 0x5f, +0x61, 0x74, 0x42, 0x3c, 0x56, 0x65, 0x5f, 0x5f, 0x28, 0x28, 0x83, 0x01, +0x05, 0x23, 0x00, 0x11, 0x29, 0x49, 0x00, 0x2f, 0x65, 0x6c, 0x80, 0x00, +0x04, 0x3f, 0x33, 0x30, 0x31, 0x6a, 0x00, 0x2c, 0x07, 0x61, 0x00, 0x05, +0xc5, 0x00, 0x21, 0x4d, 0x53, 0x65, 0x00, 0x0f, 0x5a, 0x00, 0x15, 0x00, +0x2f, 0x02, 0x00, 0x0c, 0x20, 0x0f, 0xc0, 0x00, 0x02, 0x02, 0x5e, 0x00, +0x22, 0x73, 0x65, 0x4c, 0x00, 0x03, 0x65, 0x39, 0x03, 0x1e, 0x00, 0x23, +0x28, 0x22, 0xa7, 0x01, 0x37, 0x3a, 0x20, 0x59, 0xdd, 0x38, 0x05, 0x2d, +0x09, 0x0b, 0x74, 0x00, 0x02, 0x35, 0x37, 0x00, 0xa4, 0x0c, 0x02, 0x18, +0x2b, 0x3f, 0x65, 0x72, 0x22, 0xa3, 0x00, 0x12, 0x01, 0x83, 0x00, 0x01, +0xa9, 0x39, 0x02, 0xb0, 0x39, 0x00, 0x0d, 0x2d, 0x0f, 0x2e, 0x02, 0x0b, +0x12, 0x20, 0xc1, 0x38, 0x06, 0xd2, 0x03, 0x0f, 0xc6, 0x39, 0x02, 0x03, +0xa0, 0x03, 0x02, 0x0c, 0x06, 0x07, 0x1a, 0x0c, 0x00, 0xb6, 0x0e, 0x44, +0x6c, 0x61, 0x6e, 0x6e, 0xd4, 0x14, 0x36, 0x61, 0x72, 0x74, 0xb1, 0x39, +0x05, 0xc1, 0x03, 0xf2, 0x01, 0x62, 0x79, 0x20, 0x72, 0x31, 0x33, 0x31, +0x20, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x6d, 0x47, 0x12, 0x0f, +0xd8, 0x13, 0x00, 0x0b, 0xfe, 0x0d, 0x0f, 0x81, 0x28, 0x1c, 0x0f, 0xe7, +0x26, 0x01, 0x03, 0x7f, 0x33, 0x02, 0x4c, 0x1c, 0x0f, 0xd2, 0x28, 0x26, +0x07, 0xeb, 0x31, 0x0f, 0x64, 0x00, 0x00, 0x00, 0x59, 0x04, 0x02, 0x47, +0x27, 0x0b, 0xbf, 0x00, 0x0f, 0x55, 0x27, 0x27, 0x0f, 0xcb, 0x00, 0x0e, +0x07, 0x75, 0x00, 0x0f, 0xbc, 0x27, 0x31, 0x0f, 0xe1, 0x00, 0x0b, 0x05, +0x9d, 0x08, 0x0c, 0xe1, 0x00, 0x0e, 0x50, 0x19, 0x0e, 0x7c, 0x15, 0x0f, +0xf1, 0x00, 0x35, 0x06, 0x85, 0x00, 0x0f, 0x77, 0x00, 0x38, 0x0f, 0x01, +0x01, 0x03, 0x09, 0x10, 0x03, 0x2f, 0x64, 0x65, 0x12, 0x03, 0x17, 0x30, +0x20, 0x6e, 0x61, 0xf3, 0x22, 0x13, 0x61, 0x6c, 0x2a, 0x03, 0xbf, 0x27, +0x06, 0x2c, 0x04, 0x01, 0xd3, 0x0a, 0x01, 0x6d, 0x0e, 0x21, 0x6e, 0x6f, +0x3f, 0x13, 0x41, 0x65, 0x72, 0x20, 0x62, 0x15, 0x1b, 0x02, 0x6d, 0x20, +0x05, 0xeb, 0x08, 0x01, 0xcd, 0x19, 0x05, 0x20, 0x2f, 0x01, 0xfb, 0x0a, +0x04, 0x25, 0x2f, 0x31, 0x61, 0x74, 0x69, 0x83, 0x3b, 0x03, 0x17, 0x28, +0x20, 0x6f, 0x6c, 0x0d, 0x44, 0x03, 0x43, 0x3d, 0x15, 0x73, 0xe1, 0x0d, +0x36, 0x5a, 0x34, 0x5f, 0x30, 0x26, 0x0c, 0x63, 0x2c, 0x0f, 0x63, 0x08, +0x00, 0x0f, 0x38, 0x00, 0x02, 0x30, 0x5f, 0x75, 0x6e, 0x03, 0x2b, 0x16, +0x6e, 0x1d, 0x01, 0x0f, 0x4a, 0x00, 0x0c, 0x00, 0x43, 0x09, 0x03, 0xc8, +0x00, 0x08, 0x16, 0x01, 0x00, 0x55, 0x20, 0x10, 0x6f, 0x4d, 0x14, 0x04, +0x21, 0x0c, 0x14, 0x77, 0x9e, 0x07, 0x22, 0x64, 0x3b, 0xd7, 0x26, 0x01, +0x03, 0x05, 0x00, 0xaa, 0x07, 0x02, 0xfa, 0x00, 0x03, 0x1b, 0x1e, 0x21, +0x72, 0x65, 0xd6, 0x07, 0x02, 0x2d, 0x05, 0x20, 0x68, 0x65, 0xed, 0x13, +0x04, 0x43, 0x25, 0x21, 0x68, 0x69, 0x6c, 0x2d, 0x08, 0xac, 0x37, 0x04, +0x27, 0x23, 0x02, 0x18, 0x0c, 0x02, 0x44, 0x08, 0x08, 0x7a, 0x00, 0x00, +0x7b, 0x01, 0x21, 0x69, 0x67, 0x9a, 0x04, 0x30, 0x74, 0x6f, 0x20, 0x72, +0x10, 0x21, 0x74, 0x61, 0xf6, 0x3e, 0x01, 0xc1, 0x0d, 0x02, 0xcf, 0x01, +0x04, 0x84, 0x02, 0x07, 0x3c, 0x01, 0x0f, 0x72, 0x09, 0x13, 0x07, 0x3f, +0x02, 0x0e, 0x4b, 0x00, 0x0f, 0x4f, 0x01, 0x01, 0x0f, 0x6c, 0x28, 0x17, +0x3f, 0x20, 0x69, 0x73, 0xaa, 0x02, 0x05, 0x0d, 0xbd, 0x05, 0x05, 0x80, +0x11, 0x06, 0xa8, 0x0b, 0x11, 0x3b, 0xd0, 0x14, 0x00, 0xd7, 0x3d, 0x06, +0x1d, 0x00, 0x06, 0x24, 0x3e, 0x14, 0x77, 0xcb, 0x0d, 0x05, 0x3b, 0x09, +0x03, 0xbc, 0x13, 0x07, 0x5d, 0x06, 0x11, 0x22, 0x30, 0x46, 0x0c, 0x2d, +0x1d, 0x14, 0x29, 0x4d, 0x1f, 0x32, 0x22, 0x29, 0x20, 0x82, 0x04, 0x06, +0xdf, 0x13, 0x04, 0x96, 0x18, 0x01, 0x68, 0x03, 0x03, 0x97, 0x18, 0x1f, +0x3b, 0x57, 0x00, 0x1f, 0x02, 0x12, 0x14, 0x08, 0xd2, 0x2c, 0x00, 0x23, +0x00, 0x09, 0xd8, 0x2c, 0x0f, 0x54, 0x00, 0x05, 0x07, 0x31, 0x1f, 0x09, +0x53, 0x00, 0x07, 0x54, 0x00, 0x07, 0x23, 0x00, 0x06, 0x53, 0x00, 0x06, +0x48, 0x05, 0x0f, 0xc1, 0x00, 0x18, 0x04, 0x75, 0x18, 0x0a, 0x6a, 0x00, +0x23, 0x20, 0x20, 0x45, 0x00, 0x01, 0x23, 0x00, 0x56, 0x6c, 0x69, 0x64, +0x65, 0x49, 0x4e, 0x00, 0x09, 0xb6, 0x05, 0x2f, 0x29, 0x3b, 0xc6, 0x01, +0x05, 0x0f, 0x77, 0x0d, 0x00, 0x0f, 0xa0, 0x01, 0x03, 0x0f, 0xcd, 0x0c, +0x0b, 0x0d, 0x56, 0x01, 0x0f, 0xfb, 0x0c, 0x01, 0x00, 0x4f, 0x04, 0xbf, +0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x36, 0x34, 0x6b, 0x20, 0x28, 0x3b, +0x1b, 0x0d, 0x0f, 0xfb, 0x0c, 0x05, 0x05, 0xfe, 0x2a, 0x0f, 0xa6, 0x00, +0x10, 0x0a, 0xdd, 0x0c, 0x0f, 0xa6, 0x00, 0x0d, 0x01, 0x2e, 0x00, 0x0f, +0xa6, 0x00, 0x1c, 0x0d, 0x04, 0x0f, 0x0f, 0xef, 0x42, 0x07, 0x90, 0x7d, +0x0a, 0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x0a, +}; + +static unsigned char buf[18830]; + +int main() { + + unsigned long cksum = adler32(0, NULL, 0); + + decompress_lz4(compressed, buf, 18830); + cksum = adler32(cksum, buf, 18830); + + return cksum == 0xf748269d ? 0 : 1; +} From ee49ecdf432fd17a706032530cc2e3b34f0074c8 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Tue, 6 Jun 2017 19:31:16 +0300 Subject: [PATCH 356/407] Expand tabs to spaces in lz4.s --- libsrc/common/lz4.s | 328 ++++++++++++++++++++++---------------------- 1 file changed, 164 insertions(+), 164 deletions(-) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index ee215d4da..5a07a42ed 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -4,11 +4,11 @@ ; An optimized LZ4 decompressor ; - .importzp sp, sreg, regsave, regbank - .importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 - .macpack longbranch - .import memcpy_upwards,pushax,popax - .export _decompress_lz4 + .importzp sp, sreg, regsave, regbank + .importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 + .macpack longbranch + .import memcpy_upwards,pushax,popax + .export _decompress_lz4 _out = regsave _written = regsave + 2 @@ -22,262 +22,262 @@ _outlen = ptr4 ; void decompress_lz4 (const u8 *in, u8 * const out, const u16 outlen) ; --------------------------------------------------------------- -.segment "CODE" +.segment "CODE" -.proc _decompress_lz4: near +.proc _decompress_lz4: near - sta _outlen - stx _outlen+1 + sta _outlen + stx _outlen+1 - jsr popax - sta _out - stx _out+1 + jsr popax + sta _out + stx _out+1 - jsr popax - sta _in - stx _in+1 + jsr popax + sta _in + stx _in+1 ; ; written = 0; ; - lda #$00 - sta _written + lda #$00 + sta _written ; ; while (written < outlen) { ; - jmp L0046 + jmp L0046 ; ; token = *in++; ; -L0004: ldy #0 - lda (_in),y - sta _token +L0004: ldy #0 + lda (_in),y + sta _token - inc _in - bne L000A - inc _in+1 + inc _in + bne L000A + inc _in+1 L000A: ; ; offset = token >> 4; ; - ldx #$00 - lsr a - lsr a - lsr a - lsr a - sta _offset - stx _offset+1 + ldx #$00 + lsr a + lsr a + lsr a + lsr a + sta _offset + stx _offset+1 ; ; token &= 0xf; ; token += 4; // Minmatch ; - lda _token - and #$0F - clc - adc #4 - sta _token + lda _token + and #$0F + clc + adc #4 + sta _token ; ; if (offset == 15) { ; - lda _offset - cmp #$0F -L0013: bne L001A + lda _offset + cmp #$0F +L0013: bne L001A ; ; tmp = *in++; ; - ldy #0 - lda (_in),y - sta _tmp + ldy #0 + lda (_in),y + sta _tmp - inc _in - bne L0017 - inc _in+1 + inc _in + bne L0017 + inc _in+1 L0017: ; ; offset += tmp; ; - clc - adc _offset - sta _offset - lda #$00 - adc _offset+1 - sta _offset+1 + clc + adc _offset + sta _offset + lda #$00 + adc _offset+1 + sta _offset+1 ; ; if (tmp == 255) ; - lda _tmp - cmp #$FF + lda _tmp + cmp #$FF ; ; goto moreliterals; ; - jmp L0013 + jmp L0013 ; ; if (offset) { ; -L001A: lda _offset - ora _offset+1 - beq L001C +L001A: lda _offset + ora _offset+1 + beq L001C ; ; memcpy(&out[written], in, offset); ; - lda _out - clc - adc _written - sta ptr2 - lda _out+1 - adc _written+1 - tax - lda ptr2 - stx ptr2+1 - jsr pushax - lda _in - ldx _in+1 - sta ptr1 - stx ptr1+1 - ldy #0 - jsr memcpy_upwards + lda _out + clc + adc _written + sta ptr2 + lda _out+1 + adc _written+1 + tax + lda ptr2 + stx ptr2+1 + jsr pushax + lda _in + ldx _in+1 + sta ptr1 + stx ptr1+1 + ldy #0 + jsr memcpy_upwards ; ; written += offset; ; - lda _offset - clc - adc _written - sta _written - lda _offset+1 - adc _written+1 - sta _written+1 + lda _offset + clc + adc _written + sta _written + lda _offset+1 + adc _written+1 + sta _written+1 ; ; in += offset; ; - lda _offset - clc - adc _in - sta _in - lda _offset+1 - adc _in+1 - sta _in+1 + lda _offset + clc + adc _in + sta _in + lda _offset+1 + adc _in+1 + sta _in+1 ; ; if (written >= outlen) ; -L001C: lda _written - cmp _outlen - lda _written+1 - sbc _outlen+1 +L001C: lda _written + cmp _outlen + lda _written+1 + sbc _outlen+1 ; ; return; ; - bcc L0047 - rts + bcc L0047 + rts ; ; memcpy(&offset, in, 2); ; -L0047: ldy #0 - lda (_in),y - sta _offset - iny - lda (_in),y - sta _offset+1 +L0047: ldy #0 + lda (_in),y + sta _offset + iny + lda (_in),y + sta _offset+1 ; ; in += 2; ; - lda #$02 - clc - adc _in - sta _in - bcc L002F - inc _in+1 + lda #$02 + clc + adc _in + sta _in + bcc L002F + inc _in+1 ; ; copysrc = out + written - offset; ; -L002F: lda _out - clc - adc _written - pha - lda _out+1 - adc _written+1 - tax - pla - sec - sbc _offset - sta ptr1 - txa - sbc _offset+1 - sta ptr1+1 +L002F: lda _out + clc + adc _written + pha + lda _out+1 + adc _written+1 + tax + pla + sec + sbc _offset + sta ptr1 + txa + sbc _offset+1 + sta ptr1+1 ; ; offset = token; ; - lda #$00 - sta _offset+1 - lda _token - sta _offset + lda #$00 + sta _offset+1 + lda _token + sta _offset ; ; if (token == 19) { ; - cmp #$13 -L0045: bne L003C + cmp #$13 +L0045: bne L003C ; ; tmp = *in++; ; - ldy #0 - lda (_in),y - sta _tmp + ldy #0 + lda (_in),y + sta _tmp - inc _in - bne L0039 - inc _in+1 + inc _in + bne L0039 + inc _in+1 L0039: ; ; offset += tmp; ; - clc - adc _offset - sta _offset - tya - adc _offset+1 - sta _offset+1 + clc + adc _offset + sta _offset + tya + adc _offset+1 + sta _offset+1 ; ; if (tmp == 255) ; - lda _tmp - cmp #$FF + lda _tmp + cmp #$FF ; ; goto morematches; ; - jmp L0045 + jmp L0045 ; ; memcpy(&out[written], copysrc, offset); ; -L003C: lda _out - clc - adc _written - sta ptr2 - lda _out+1 - adc _written+1 - tax - lda ptr2 - stx ptr2+1 - jsr pushax - jsr memcpy_upwards +L003C: lda _out + clc + adc _written + sta ptr2 + lda _out+1 + adc _written+1 + tax + lda ptr2 + stx ptr2+1 + jsr pushax + jsr memcpy_upwards ; ; written += offset; ; - lda _offset - clc - adc _written - sta _written - lda _offset+1 - adc _written+1 -L0046: sta _written+1 + lda _offset + clc + adc _written + sta _written + lda _offset+1 + adc _written+1 +L0046: sta _written+1 ; ; while (written < outlen) { ; - lda _written - cmp _outlen - lda _written+1 - sbc _outlen+1 - jcc L0004 + lda _written + cmp _outlen + lda _written+1 + sbc _outlen+1 + jcc L0004 - rts + rts .endproc From a397a8c1a18a51e8c2bc7ac7a4d70e7599a75b36 Mon Sep 17 00:00:00 2001 From: greg-king5 <greg.king5@verizon.net> Date: Wed, 7 Jun 2017 10:20:20 -0400 Subject: [PATCH 357/407] Added missing -O configuration. --- test/val/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/val/Makefile b/test/val/Makefile index c7539c81b..fe194d892 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -31,7 +31,7 @@ SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ../../testwrk/val -OPTIONS = g O Os Osi Osir Oi Oir Or +OPTIONS = g O Os Osi Osir Osr Oi Oir Or .PHONY: all clean From e24bb372d0e54201da8905d15ccf81e0c99cb890 Mon Sep 17 00:00:00 2001 From: greg-king5 <greg.king5@verizon.net> Date: Wed, 7 Jun 2017 10:26:34 -0400 Subject: [PATCH 358/407] Added a missing -O configuration. --- test/ref/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ref/Makefile b/test/ref/Makefile index c986513b8..3c2e582e4 100644 --- a/test/ref/Makefile +++ b/test/ref/Makefile @@ -33,7 +33,7 @@ SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ..$S..$Stestwrk$Sref -OPTIONS = g O Os Osi Osir Oi Oir Or +OPTIONS = g O Os Osi Osir Osr Oi Oir Or DIFF = $(WORKDIR)$Sbdiff$(EXE) From 06c3cd830747c0049ada4a5a0eef2b1ad3fd29e7 Mon Sep 17 00:00:00 2001 From: greg-king5 <greg.king5@verizon.net> Date: Wed, 7 Jun 2017 10:31:09 -0400 Subject: [PATCH 359/407] Added a missing -O configuration. --- test/misc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/misc/Makefile b/test/misc/Makefile index 39a9a3868..330c9d500 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -35,7 +35,7 @@ SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) WORKDIR = ..$S..$Stestwrk$Smisc -OPTIONS = g O Os Osi Osir Oi Oir Or +OPTIONS = g O Os Osi Osir Osr Oi Oir Or DIFF = $(WORKDIR)$Sbdiff$(EXE) From e85796e028b152c68c7451c4bc73a06aa6be3749 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:35:16 +0300 Subject: [PATCH 360/407] Edit comment style, add second const --- include/lz4.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/lz4.h b/include/lz4.h index d6bf1b17c..fd11c3e2a 100644 --- a/include/lz4.h +++ b/include/lz4.h @@ -32,12 +32,11 @@ #ifndef _LZ4_H #define _LZ4_H -void __fastcall__ decompress_lz4 (const unsigned char* src, unsigned char* dst, +void __fastcall__ decompress_lz4 (const unsigned char* src, unsigned char* const dst, const unsigned short uncompressed_size); -/* - Decompresses the source buffer into the destination buffer. - The size of the decompressed data must be known in advance, LZ4 - does not include any terminator in-stream. +/* Decompresses the source buffer into the destination buffer. +** The size of the decompressed data must be known in advance, LZ4 +** does not include any terminator in-stream. */ /* end of lz4.h */ From cd460a81602851655dc83543a94609118dae976f Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:37:50 +0300 Subject: [PATCH 361/407] Remove _ from internal vars --- libsrc/common/lz4.s | 190 ++++++++++++++++++++++---------------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index 5a07a42ed..922cb2eba 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -10,13 +10,13 @@ .import memcpy_upwards,pushax,popax .export _decompress_lz4 -_out = regsave -_written = regsave + 2 -_tmp = tmp1 -_token = tmp2 -_offset = ptr3 -_in = sreg -_outlen = ptr4 +out = regsave +written = regsave + 2 +tmp = tmp1 +token = tmp2 +offset = ptr3 +in = sreg +outlen = ptr4 ; --------------------------------------------------------------- ; void decompress_lz4 (const u8 *in, u8 * const out, const u16 outlen) @@ -26,22 +26,22 @@ _outlen = ptr4 .proc _decompress_lz4: near - sta _outlen - stx _outlen+1 + sta outlen + stx outlen+1 jsr popax - sta _out - stx _out+1 + sta out + stx out+1 jsr popax - sta _in - stx _in+1 + sta in + stx in+1 ; ; written = 0; ; lda #$00 - sta _written + sta written ; ; while (written < outlen) { ; @@ -50,12 +50,12 @@ _outlen = ptr4 ; token = *in++; ; L0004: ldy #0 - lda (_in),y - sta _token + lda (in),y + sta token - inc _in + inc in bne L000A - inc _in+1 + inc in+1 L000A: ; ; offset = token >> 4; @@ -65,47 +65,47 @@ L000A: lsr a lsr a lsr a - sta _offset - stx _offset+1 + sta offset + stx offset+1 ; ; token &= 0xf; ; token += 4; // Minmatch ; - lda _token + lda token and #$0F clc adc #4 - sta _token + sta token ; ; if (offset == 15) { ; - lda _offset + lda offset cmp #$0F L0013: bne L001A ; ; tmp = *in++; ; ldy #0 - lda (_in),y - sta _tmp + lda (in),y + sta tmp - inc _in + inc in bne L0017 - inc _in+1 + inc in+1 L0017: ; ; offset += tmp; ; clc - adc _offset - sta _offset + adc offset + sta offset lda #$00 - adc _offset+1 - sta _offset+1 + adc offset+1 + sta offset+1 ; ; if (tmp == 255) ; - lda _tmp + lda tmp cmp #$FF ; ; goto moreliterals; @@ -114,24 +114,24 @@ L0017: ; ; if (offset) { ; -L001A: lda _offset - ora _offset+1 +L001A: lda offset + ora offset+1 beq L001C ; ; memcpy(&out[written], in, offset); ; - lda _out + lda out clc - adc _written + adc written sta ptr2 - lda _out+1 - adc _written+1 + lda out+1 + adc written+1 tax lda ptr2 stx ptr2+1 jsr pushax - lda _in - ldx _in+1 + lda in + ldx in+1 sta ptr1 stx ptr1+1 ldy #0 @@ -139,30 +139,30 @@ L001A: lda _offset ; ; written += offset; ; - lda _offset + lda offset clc - adc _written - sta _written - lda _offset+1 - adc _written+1 - sta _written+1 + adc written + sta written + lda offset+1 + adc written+1 + sta written+1 ; ; in += offset; ; - lda _offset + lda offset clc - adc _in - sta _in - lda _offset+1 - adc _in+1 - sta _in+1 + adc in + sta in + lda offset+1 + adc in+1 + sta in+1 ; ; if (written >= outlen) ; -L001C: lda _written - cmp _outlen - lda _written+1 - sbc _outlen+1 +L001C: lda written + cmp outlen + lda written+1 + sbc outlen+1 ; ; return; ; @@ -172,44 +172,44 @@ L001C: lda _written ; memcpy(&offset, in, 2); ; L0047: ldy #0 - lda (_in),y - sta _offset + lda (in),y + sta offset iny - lda (_in),y - sta _offset+1 + lda (in),y + sta offset+1 ; ; in += 2; ; lda #$02 clc - adc _in - sta _in + adc in + sta in bcc L002F - inc _in+1 + inc in+1 ; ; copysrc = out + written - offset; ; -L002F: lda _out +L002F: lda out clc - adc _written + adc written pha - lda _out+1 - adc _written+1 + lda out+1 + adc written+1 tax pla sec - sbc _offset + sbc offset sta ptr1 txa - sbc _offset+1 + sbc offset+1 sta ptr1+1 ; ; offset = token; ; lda #$00 - sta _offset+1 - lda _token - sta _offset + sta offset+1 + lda token + sta offset ; ; if (token == 19) { ; @@ -219,26 +219,26 @@ L0045: bne L003C ; tmp = *in++; ; ldy #0 - lda (_in),y - sta _tmp + lda (in),y + sta tmp - inc _in + inc in bne L0039 - inc _in+1 + inc in+1 L0039: ; ; offset += tmp; ; clc - adc _offset - sta _offset + adc offset + sta offset tya - adc _offset+1 - sta _offset+1 + adc offset+1 + sta offset+1 ; ; if (tmp == 255) ; - lda _tmp + lda tmp cmp #$FF ; ; goto morematches; @@ -247,12 +247,12 @@ L0039: ; ; memcpy(&out[written], copysrc, offset); ; -L003C: lda _out +L003C: lda out clc - adc _written + adc written sta ptr2 - lda _out+1 - adc _written+1 + lda out+1 + adc written+1 tax lda ptr2 stx ptr2+1 @@ -261,20 +261,20 @@ L003C: lda _out ; ; written += offset; ; - lda _offset + lda offset clc - adc _written - sta _written - lda _offset+1 - adc _written+1 -L0046: sta _written+1 + adc written + sta written + lda offset+1 + adc written+1 +L0046: sta written+1 ; ; while (written < outlen) { ; - lda _written - cmp _outlen - lda _written+1 - sbc _outlen+1 + lda written + cmp outlen + lda written+1 + sbc outlen+1 jcc L0004 rts From bba961e54deb382509425ec5544e68f59ed036c3 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:40:17 +0300 Subject: [PATCH 362/407] Use hex immediates --- libsrc/common/lz4.s | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index 922cb2eba..4901d1a3c 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -49,7 +49,7 @@ outlen = ptr4 ; ; token = *in++; ; -L0004: ldy #0 +L0004: ldy #$00 lda (in),y sta token @@ -74,7 +74,7 @@ L000A: lda token and #$0F clc - adc #4 + adc #$04 sta token ; ; if (offset == 15) { @@ -85,7 +85,7 @@ L0013: bne L001A ; ; tmp = *in++; ; - ldy #0 + ldy #$00 lda (in),y sta tmp @@ -134,7 +134,7 @@ L001A: lda offset ldx in+1 sta ptr1 stx ptr1+1 - ldy #0 + ldy #$00 jsr memcpy_upwards ; ; written += offset; @@ -171,7 +171,7 @@ L001C: lda written ; ; memcpy(&offset, in, 2); ; -L0047: ldy #0 +L0047: ldy #$00 lda (in),y sta offset iny @@ -218,7 +218,7 @@ L0045: bne L003C ; ; tmp = *in++; ; - ldy #0 + ldy #$00 lda (in),y sta tmp From c444ed5e4fbda9c011d5b2502ba4fabd9e37628c Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:42:24 +0300 Subject: [PATCH 363/407] Mention the optimizations in a comment --- libsrc/common/lz4.s | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index 4901d1a3c..a750f4bf8 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -2,6 +2,9 @@ ; Lauri Kasanen, 6 Jun 2017 ; (C) Mega Cat Studios ; An optimized LZ4 decompressor +; +; Almost 7 times faster, uses no RAM (vs 14 bytes BSS), and takes 1/4 the space +; vs the official C source. ; .importzp sp, sreg, regsave, regbank From 135041ac3cc809a1cc38e4567a559bdcf0f0c1dc Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 10:54:50 +0300 Subject: [PATCH 364/407] Add lz4 doc --- doc/funcref.sgml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index d160082bf..3e74b2785 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -398,6 +398,13 @@ function. (incomplete) +<sect1><tt/lz4.h/<label id="lz4.h"><p> + +<itemize> +<item><ref id="decompress_lz4" name="decompress_lz4"> +</itemize> + + <sect1><tt/modload.h/<label id="modload.h"><p> <itemize> @@ -2632,6 +2639,23 @@ used in presence of a prototype. </quote> +<sect1>decompress_lz4<label id="decompress_lz4"><p> + +<quote> +<descrip> +<tag/Function/Uncompress a LZ4-compressed buffer. +<tag/Header/<tt/<ref id="lz4.h" name="lz4.h">/ +<tag/Declaration/<tt/void decompress_lz4 (const unsigned char* src, unsigned char* const dst, const unsigned short uncompressed_size);/ +<tag/Description/<tt/decompress_lz4/ uncompresses a LZ4-compressed buffer. +<tag/Notes/<itemize> +<item>Use LZ4_compress_HC with compression level 16 for best compression. +</itemize> +<tag/Availability/cc65 +<tag/Example/None. +</descrip> +</quote> + + <sect1>div<label id="div"><p> <quote> From 4235e569d20cf64e52a26267149f4cf4ca1d4c89 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <cand@gmx.com> Date: Fri, 9 Jun 2017 16:57:47 +0300 Subject: [PATCH 365/407] Small lz4 optimizations --- libsrc/common/lz4.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index a750f4bf8..4702137bc 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -137,7 +137,7 @@ L001A: lda offset ldx in+1 sta ptr1 stx ptr1+1 - ldy #$00 +; ldy #$00 - not needed as pushax zeroes Y jsr memcpy_upwards ; ; written += offset; @@ -195,11 +195,11 @@ L0047: ldy #$00 L002F: lda out clc adc written - pha + tay lda out+1 adc written+1 tax - pla + tya sec sbc offset sta ptr1 From 30f941ba39def8d3e3e654f3e9f6fc9dd5eadac6 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Thu, 15 Jun 2017 16:44:46 -0400 Subject: [PATCH 366/407] Added a missing label to some conio cursor movement functions. It had prevented other functions, e.g. cputs(), from being linked into a program. --- libsrc/atmos/gotoxy.s | 10 ++++++---- libsrc/creativision/gotoxy.s | 8 ++++++-- libsrc/gamate/gotoxy.s | 6 ++---- libsrc/telestrat/gotoxy.s | 35 +++++++++++++++++++++-------------- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/libsrc/atmos/gotoxy.s b/libsrc/atmos/gotoxy.s index 80d4d5251..6652c9419 100644 --- a/libsrc/atmos/gotoxy.s +++ b/libsrc/atmos/gotoxy.s @@ -1,14 +1,18 @@ ; -; Ullrich von Bassewitz, 2003-04-13 +; 2003-04-13, Ullrich von Bassewitz +; 2017-06-15, Greg King ; ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy + .export gotoxy, _gotoxy + .import popa .include "atmos.inc" +gotoxy: jsr popa ; Get Y + .proc _gotoxy sta CURS_Y ; Set Y @@ -17,5 +21,3 @@ rts .endproc - - diff --git a/libsrc/creativision/gotoxy.s b/libsrc/creativision/gotoxy.s index 12ce0abea..588dd83a0 100644 --- a/libsrc/creativision/gotoxy.s +++ b/libsrc/creativision/gotoxy.s @@ -1,15 +1,19 @@ ; -; Ullrich von Bassewitz, 06.08.1998 +; 1998-08-06, Ullrich von Bassewitz +; 2017-06-15, Greg King ; ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy + .export gotoxy, _gotoxy + .import setcursor .import popa .include "creativision.inc" +gotoxy: jsr popa ; Get Y + .proc _gotoxy sta CURSOR_Y ; Set Y diff --git a/libsrc/gamate/gotoxy.s b/libsrc/gamate/gotoxy.s index 4a4871444..d49bd2967 100644 --- a/libsrc/gamate/gotoxy.s +++ b/libsrc/gamate/gotoxy.s @@ -9,7 +9,7 @@ .include "extzp.inc" gotoxy: - jsr popa ; Get X + jsr popa ; Get Y _gotoxy: sta CURS_Y ; Set Y @@ -20,6 +20,4 @@ _gotoxy: ;------------------------------------------------------------------------------- ; force the init constructor to be imported - .import initconio -conio_init = initconio - + .forceimport initconio diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s index e0c8154e3..e1470f848 100644 --- a/libsrc/telestrat/gotoxy.s +++ b/libsrc/telestrat/gotoxy.s @@ -1,19 +1,26 @@ ; -; jede jede@oric.org 2017-02-25 +; 2017-02-25, jede <jede@oric.org> +; 2017-06-15, Greg King +; +; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy - - .import popa - - .importzp sp - .include "telestrat.inc" + .export gotoxy, _gotoxy + + .import popa + .importzp sp + + .include "telestrat.inc" + +gotoxy: jsr popa ; Get Y .proc _gotoxy - ; This function move only cursor for display, it does not move the prompt position - ; in telemon, there is position for prompt, and another for the cursor - sta SCRY - jsr popa - sta SCRX - rts -.endproc + +; This function moves only the display cursor; it does not move the prompt position. +; In telemon, there is a position for the prompt, and another for the cursor. + + sta SCRY + jsr popa + sta SCRX + rts +.endproc From 035621aa95e2be6a6f5f0fc091e9fc4c7df2047d Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sat, 17 Jun 2017 02:26:54 +0200 Subject: [PATCH 367/407] fixed code a bit so it compiles again :) --- libsrc/c128/waitvblank.s | 15 ++++----------- libsrc/c64/waitvblank.s | 15 ++++----------- libsrc/cbm510/waitvblank.s | 27 ++++++++------------------- libsrc/vic20/waitvblank.s | 7 ++++++- 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvblank.s index a3904d858..54699286c 100644 --- a/libsrc/c128/waitvblank.s +++ b/libsrc/c128/waitvblank.s @@ -1,20 +1,13 @@ .export _waitvblank - .include "c128/c128.inc" + .include "c128.inc" _waitvblank: - lda PALFLAG - beq @ntsc - ldx #(312-24)-256 - .byte $2c -@ntsc: - ldx #(262-4)-256 @l1: lda VIC_CTRL1 - and #$80 - beq @l1 + bpl @l1 @l2: - cpx VIC_HLINE - bcs @l2 + lda VIC_CTRL1 + bmi @l2 rts diff --git a/libsrc/c64/waitvblank.s b/libsrc/c64/waitvblank.s index 09570f873..606f41681 100644 --- a/libsrc/c64/waitvblank.s +++ b/libsrc/c64/waitvblank.s @@ -1,20 +1,13 @@ .export _waitvblank - .include "c64/c64.inc" + .include "c64.inc" _waitvblank: - lda PALFLAG - beq @ntsc - ldx #(312-24)-256 - .byte $2c -@ntsc: - ldx #(262-4)-256 @l1: lda VIC_CTRL1 - and #$80 - beq @l1 + bpl @l1 @l2: - cpx VIC_HLINE - bcs @l2 + lda VIC_CTRL1 + bmi @l2 rts diff --git a/libsrc/cbm510/waitvblank.s b/libsrc/cbm510/waitvblank.s index 30cbf072f..975861f2c 100644 --- a/libsrc/cbm510/waitvblank.s +++ b/libsrc/cbm510/waitvblank.s @@ -5,33 +5,22 @@ .importzp vic - .include "cbm510/cbm510.inc" + .include "cbm510.inc" _waitvblank: rts ; FIXME jsr sys_bank ; Switch to the system bank - lda PALFLAG - beq ntsc - ldx #(312-24)-256 - .byte $2c -ntsc: - ldx #(262-2)-256 - sei - ldy #VIC_CTRL1 -l1: - lda (vic),y - and #$80 - beq l1 -;?!? -; ldy #VIC_HLINE -; txa -;l2: -; cmp (vic),y -; bcs l2 + ldy #VIC_CTRL1 +@l1: + lda (vic),y + bpl @l1 +@l2: + lda (vic),y + bmi @l2 cli jmp restore_bank diff --git a/libsrc/vic20/waitvblank.s b/libsrc/vic20/waitvblank.s index b99c74bed..246c44640 100644 --- a/libsrc/vic20/waitvblank.s +++ b/libsrc/vic20/waitvblank.s @@ -1,6 +1,11 @@ .export _waitvblank - .include "vic20/vic20.inc" + .include "vic20.inc" + +; FIXME +; this flag doesnt work on vic20!!! +; it will have to be filled by a get_tv() constructor or so +PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC _waitvblank: lda PALFLAG From d3ccc289c1a09d290e77935c13ac94972b18ca4c Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Fri, 16 Jun 2017 21:53:50 -0400 Subject: [PATCH 368/407] Stopped cc65 from putting redundant .segment directives into its Assembly output. --- src/cc65/compile.c | 25 +++++++++++++++---------- src/cc65/pragma.c | 20 ++++++++++++++++---- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 3c1042154..d79ef350b 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -243,19 +243,20 @@ static void Parse (void) } Entry->Flags &= ~(SC_STORAGE | SC_DEF); } else { - /* A global (including static) uninitialized variable - ** is only a tentative definition. For example, this is valid: + /* A global (including static) uninitialized variable is + ** only a tentative definition. For example, this is valid: ** int i; ** int i; ** static int j; ** static int j = 42; - ** Code for these will be generated in FinishCompile. + ** Code for them will be generated by FinishCompile(). ** For now, just save the BSS segment name - ** (can be set with #pragma bss-name) + ** (can be set by #pragma bss-name). */ const char* bssName = GetSegName (SEG_BSS); + if (Entry->V.BssName && strcmp (Entry->V.BssName, bssName) != 0) { - Error ("Global variable `%s' has already been defined in `%s' segment", + Error ("Global variable `%s' already was defined in the `%s' segment.", Entry->Name, Entry->V.BssName); } Entry->V.BssName = xstrdup (bssName); @@ -419,7 +420,7 @@ void FinishCompile (void) SymEntry* Entry; /* Walk over all global symbols: - ** - for functions do cleanup, optimizations ... + ** - for functions, do clean-up and optimizations ** - generate code for uninitialized global variables */ for (Entry = GetGlobalSymTab ()->SymHead; Entry; Entry = Entry->NextSym) { @@ -429,13 +430,17 @@ void FinishCompile (void) CS_MergeLabels (Entry->V.F.Seg->Code); RunOpt (Entry->V.F.Seg->Code); } else if ((Entry->Flags & (SC_STORAGE | SC_DEF | SC_STATIC)) == (SC_STORAGE | SC_STATIC)) { - /* Tentative definition of uninitialized global variable */ + /* Assembly definition of uninitialized global variable */ + + /* Set the segment name only when it changes */ + if (strcmp (GetSegName (SEG_BSS), Entry->V.BssName) != 0) { + SetSegName (SEG_BSS, Entry->V.BssName); + g_segname (SEG_BSS); + } g_usebss (); - SetSegName (SEG_BSS, Entry->V.BssName); - g_segname (SEG_BSS); /* TODO: skip if same as before */ g_defgloblabel (Entry->Name); g_res (SizeOf (Entry->Type)); - /* Mark as defined, so that it will be exported not imported */ + /* Mark as defined; so that it will be exported, not imported */ Entry->Flags |= SC_DEF; } } diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 3dfc62668..de1979c12 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -386,11 +386,11 @@ static void StringPragma (StrBuf* B, void (*Func) (const char*)) static void SegNamePragma (StrBuf* B, segment_t Seg) /* Handle a pragma that expects a segment name parameter */ { - StrBuf S = AUTO_STRBUF_INITIALIZER; const char* Name; + StrBuf S = AUTO_STRBUF_INITIALIZER; + int Push = 0; /* Check for the "push" or "pop" keywords */ - int Push = 0; switch (ParsePushPop (B)) { case PP_NONE: @@ -403,7 +403,13 @@ static void SegNamePragma (StrBuf* B, segment_t Seg) case PP_POP: /* Pop the old value and output it */ PopSegName (Seg); - g_segname (Seg); + + /* BSS variables are output at the end of the compilation. Don't + ** bother to change their segment, now. + */ + if (Seg != SEG_BSS) { + g_segname (Seg); + } /* Done */ goto ExitPoint; @@ -434,7 +440,13 @@ static void SegNamePragma (StrBuf* B, segment_t Seg) } else { SetSegName (Seg, Name); } - g_segname (Seg); + + /* BSS variables are output at the end of the compilation. Don't + ** bother to change their segment, now. + */ + if (Seg != SEG_BSS) { + g_segname (Seg); + } } else { From 49aad01bf105fb731270a964c6130c3f52165c0d Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Wed, 21 Jun 2017 23:18:00 +0200 Subject: [PATCH 369/407] dont trash akku if possible, use VDC register when in 80column mode --- libsrc/c128/waitvblank.s | 16 ++++++++++++++-- libsrc/c64/waitvblank.s | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvblank.s index 54699286c..e0a469d0e 100644 --- a/libsrc/c128/waitvblank.s +++ b/libsrc/c128/waitvblank.s @@ -4,10 +4,22 @@ .include "c128.inc" _waitvblank: + + lda MODE + bmi @c80 + @l1: - lda VIC_CTRL1 + bit VIC_CTRL1 bpl @l1 @l2: - lda VIC_CTRL1 + bit VIC_CTRL1 bmi @l2 rts + +@c80: + ;FIXME: do we have to switch banks? +@l3: + lda VDC_INDEX + and #$20 + beq @l3 + rts diff --git a/libsrc/c64/waitvblank.s b/libsrc/c64/waitvblank.s index 606f41681..dd9087841 100644 --- a/libsrc/c64/waitvblank.s +++ b/libsrc/c64/waitvblank.s @@ -5,9 +5,9 @@ _waitvblank: @l1: - lda VIC_CTRL1 + bit VIC_CTRL1 bpl @l1 @l2: - lda VIC_CTRL1 + bit VIC_CTRL1 bmi @l2 rts From 3ff4a1333c374c0092abe227523f940e6f1d4ea6 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Thu, 22 Jun 2017 00:19:39 +0200 Subject: [PATCH 370/407] use BIT so akku wont get trashed at least in 40 cols mode --- libsrc/c128/waitvblank.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvblank.s index e0a469d0e..c144e11c2 100644 --- a/libsrc/c128/waitvblank.s +++ b/libsrc/c128/waitvblank.s @@ -5,7 +5,7 @@ _waitvblank: - lda MODE + bit MODE bmi @c80 @l1: From bd883327ace3f7de952a48b394a8ce6b53636595 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Mon, 26 Jun 2017 02:34:23 -0400 Subject: [PATCH 371/407] Added two functions that make it easier to write portable programs for Ohio Scientific computers. --- libsrc/osic1p/doesclrscr.s | 14 ++++++++++++++ libsrc/osic1p/revers.s | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 libsrc/osic1p/doesclrscr.s create mode 100644 libsrc/osic1p/revers.s diff --git a/libsrc/osic1p/doesclrscr.s b/libsrc/osic1p/doesclrscr.s new file mode 100644 index 000000000..3d15e8ade --- /dev/null +++ b/libsrc/osic1p/doesclrscr.s @@ -0,0 +1,14 @@ +; +; 2016-06, Christian Groessler +; 2017-06-26, Greg King +; +; unsigned char doesclrscrafterexit (void); +; +; Returns 0/1 if, after program termination, the screen isn't/is cleared. +; + + .import return1 + +; cc65's OSI programs return to the monitor ROM which clears the screen. + + .export _doesclrscrafterexit := return1 diff --git a/libsrc/osic1p/revers.s b/libsrc/osic1p/revers.s new file mode 100644 index 000000000..bb178f647 --- /dev/null +++ b/libsrc/osic1p/revers.s @@ -0,0 +1,9 @@ +; +; 2017-06-26, Greg King +; +; unsigned char __fastcall__ revers (unsigned char onoff) +; + + .import return0 + + .export _revers := return0 ; no attribute From d1501731e4234354c21907a7ee42011d8d7aaf99 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 28 Jun 2017 05:51:46 -0400 Subject: [PATCH 372/407] Added a makefile dependency for the libraries' "extra" files. Some of the files in "libsrc/*/extra/" include other library files. But, the "lib/*.o" files weren't rebuilt when those other files changed. The new dependency rules must be "bootstrapped". You must force a rebuild of all of the extra library object files (it will create the dependency files). Use these commands: rm lib/*.o make lib --- libsrc/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index f4aa03101..e106aa239 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -196,6 +196,7 @@ DEPS = $(OBJS:.o=.d) EXTRA_SRCPAT = $(SRCDIR)/extra/%.s EXTRA_OBJPAT = ../lib/$(TARGET)-%.o EXTRA_OBJS := $(patsubst $(EXTRA_SRCPAT),$(EXTRA_OBJPAT),$(wildcard $(SRCDIR)/extra/*.s)) +DEPS += $(EXTRA_OBJS:../lib/%.o=../libwrk/$(TARGET)/%.d) ZPOBJ = ../libwrk/$(TARGET)/zeropage.o ifeq ($(TARGET),$(filter $(TARGET),$(EXTZP))) @@ -281,7 +282,7 @@ endef # COMPILE_recipe $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib @echo $(TARGET) - $(<F) - @$(CA65) -t $(TARGET) $(CA65FLAGS) -o $@ $< + @$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:../lib/%.o=../libwrk/$(TARGET)/%.d) -o $@ $< ../lib/$(TARGET).lib: $(OBJS) | ../lib $(AR65) a $@ $? From b31ae57be106d7586b1af740505a863779933ecd Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Wed, 28 Jun 2017 20:43:31 +0200 Subject: [PATCH 373/407] Make some arrays const. --- libsrc/common/strftime.c | 4 +- libsrc/conio/cputs.s | 4 +- libsrc/dbg/dbg.c | 40 ++++++++-------- libsrc/geos-common/dlgbox/messagebox.c | 10 ++-- src/ca65/dbginfo.c | 4 +- src/ca65/feature.c | 2 +- src/ca65/pseudo.c | 10 ++-- src/ca65/scanner.c | 2 +- src/ca65/scanner.h | 2 +- src/cc65/codegen.c | 66 +++++++++++++------------- src/cc65/coptstop.c | 2 +- src/cc65/standard.c | 2 +- src/co65/model.c | 2 +- src/da65/labels.c | 4 +- src/grc65/main.c | 13 ++--- src/sp65/attr.c | 2 +- src/sp65/attr.h | 2 +- src/sp65/main.c | 6 +-- 18 files changed, 87 insertions(+), 90 deletions(-) diff --git a/libsrc/common/strftime.c b/libsrc/common/strftime.c index 25cfd0606..38ea4850e 100644 --- a/libsrc/common/strftime.c +++ b/libsrc/common/strftime.c @@ -53,11 +53,11 @@ size_t __fastcall__ strftime (char* buf, size_t bufsize, const char* format, const struct tm* tm) { - static const char* days[7] = { + static const char* const days[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; - static const char* months[12] = { + static const char* const months[12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; diff --git a/libsrc/conio/cputs.s b/libsrc/conio/cputs.s index c9ca5df76..ef7c65462 100644 --- a/libsrc/conio/cputs.s +++ b/libsrc/conio/cputs.s @@ -1,8 +1,8 @@ ; ; Ullrich von Bassewitz, 06.08.1998 ; -; void cputsxy (unsigned char x, unsigned char y, char* s); -; void cputs (char* s); +; void cputsxy (unsigned char x, unsigned char y, const char* s); +; void cputs (const char* s); ; .export _cputsxy, _cputs diff --git a/libsrc/dbg/dbg.c b/libsrc/dbg/dbg.c index 8b09484f6..60b452799 100644 --- a/libsrc/dbg/dbg.c +++ b/libsrc/dbg/dbg.c @@ -32,7 +32,7 @@ static char DumpHandler (void); static char HelpHandler (void); /* Forwards for other functions */ -static void DisplayPrompt (char* s); +static void DisplayPrompt (const char* s); static void SingleStep (char StepInto); static void RedrawStatic (char Frame); static void Redraw (char Frame); @@ -166,7 +166,7 @@ extern unsigned DbgHI; /* High 16 bit of primary reg */ typedef struct { unsigned char x; unsigned char y; - char* text; + const char* text; } TextDesc; /* Window descriptor */ @@ -181,13 +181,13 @@ typedef struct { unsigned char fd_visible; /* Is the window currently visible? */ char (*fd_func) (void); /* Handler function */ unsigned char fd_textcount; /* Number of text lines to print */ - TextDesc* fd_text; /* Static text in the window */ + const TextDesc* fd_text; /* Static text in the window */ } FrameDesc; /* Texts for the windows */ -static TextDesc RegText [] = { +static const TextDesc RegText [] = { { 1, 0, "PC" }, { 1, 1, "SR" }, { 1, 2, "A" }, @@ -197,7 +197,7 @@ static TextDesc RegText [] = { { 1, 6, "CS" }, { 1, 7, "HI" } }; -static TextDesc HelpText [] = { +static const TextDesc HelpText [] = { { 1, 0, "F1, ? Help" }, { 1, 1, "F2, t Toggle breakpoint" }, { 1, 2, "F3, u Run until subroutine returns" }, @@ -220,7 +220,7 @@ static TextDesc HelpText [] = { /* Window data */ -static FrameDesc AsmFrame = { +static const FrameDesc AsmFrame = { CH_ULCORNER, CH_TTEE, CH_LTEE, CH_CROSS, 0, 0, MAX_X - 10, 15, MAX_X - 11, 14, @@ -228,7 +228,7 @@ static FrameDesc AsmFrame = { AsmHandler, 0, 0 }; -static FrameDesc RegFrame = { +static const FrameDesc RegFrame = { CH_TTEE, CH_URCORNER, CH_LTEE, CH_RTEE, MAX_X - 10, 0, MAX_X - 1, 9, 8, 8, @@ -236,7 +236,7 @@ static FrameDesc RegFrame = { RegHandler, sizeof (RegText) / sizeof (RegText [0]), RegText }; -static FrameDesc StackFrame = { +static const FrameDesc StackFrame = { CH_LTEE, CH_RTEE, CH_CROSS, CH_RTEE, MAX_X - 10, 9, MAX_X - 1, 15, 8, 5, @@ -244,7 +244,7 @@ static FrameDesc StackFrame = { StackHandler, 0, 0 }; -static FrameDesc CStackFrame = { +static const FrameDesc CStackFrame = { CH_CROSS, CH_RTEE, CH_BTEE, CH_LRCORNER, MAX_X - 10, 15, MAX_X - 1, MAX_Y - 1, 8, MAX_Y - 17, @@ -252,7 +252,7 @@ static FrameDesc CStackFrame = { CStackHandler, 0, 0 }; -static FrameDesc DumpFrame = { +static const FrameDesc DumpFrame = { CH_LTEE, CH_CROSS, CH_LLCORNER, CH_BTEE, 0, 15, MAX_X - 10, MAX_Y-1, MAX_X - 11, MAX_Y - 17, @@ -260,7 +260,7 @@ static FrameDesc DumpFrame = { DumpHandler, 0, 0 }; -static FrameDesc HelpFrame = { +static const FrameDesc HelpFrame = { CH_ULCORNER, CH_URCORNER, CH_LLCORNER, CH_LRCORNER, 0, 0, MAX_X - 1, MAX_Y-1, MAX_X - 2, MAX_Y - 2, @@ -268,7 +268,7 @@ static FrameDesc HelpFrame = { HelpHandler, sizeof (HelpText) / sizeof (HelpText [0]), HelpText }; -static FrameDesc* Frames [] = { +static const FrameDesc* const Frames [] = { &AsmFrame, &RegFrame, &StackFrame, @@ -297,7 +297,7 @@ static unsigned char StackAddr; /* Start address of output */ /* Prompt line data */ -static char* ActivePrompt = 0; /* Last prompt line displayed */ +static const char* ActivePrompt = 0; /* Last prompt line displayed */ static char PromptColor; /* Color behind prompt */ static char PromptLength; /* Length of current prompt string */ @@ -346,10 +346,10 @@ BreakPoint* DbgIsBreak (unsigned Addr); -static void DrawFrame (register FrameDesc* F, char Active) +static void DrawFrame (register const FrameDesc* F, char Active) /* Draw one window frame */ { - TextDesc* T; + const TextDesc* T; unsigned char Count; unsigned char tl, tr, bl, br; unsigned char x1, y1, width; @@ -410,7 +410,7 @@ static void DrawFrames (void) /* Draw all frames */ { unsigned char I; - FrameDesc* F; + const FrameDesc* F; /* Build the frame layout of the screen */ for (I = 0; I < sizeof (Frames) / sizeof (Frames [0]); ++I) { @@ -427,7 +427,7 @@ static void ActivateFrame (int Num, unsigned char Clear) /* Activate a new frame, deactivate the old one */ { unsigned char y; - register FrameDesc* F; + register const FrameDesc* F; if (ActiveFrame != Num) { @@ -462,7 +462,7 @@ static void ActivateFrame (int Num, unsigned char Clear) -static void DisplayPrompt (char* s) +static void DisplayPrompt (const char* s) /* Display a prompt */ { unsigned char OldColor; @@ -626,11 +626,11 @@ static char InputHex (char* Prompt, unsigned* Val) -static void ErrorPrompt (char* Msg) +static void ErrorPrompt (const char* Msg) /* Display an error message and wait for a key */ { /* Save the current prompt */ - char* OldPrompt = ActivePrompt; + const char* OldPrompt = ActivePrompt; /* Display the new one */ DisplayPrompt (Msg); diff --git a/libsrc/geos-common/dlgbox/messagebox.c b/libsrc/geos-common/dlgbox/messagebox.c index 533267be1..fd4a5cd11 100644 --- a/libsrc/geos-common/dlgbox/messagebox.c +++ b/libsrc/geos-common/dlgbox/messagebox.c @@ -10,21 +10,21 @@ void _mbprintout(void); -static dlgBoxStr _mbdlg_EMPTY = { +static const dlgBoxStr _mbdlg_EMPTY = { DB_DEFPOS(1), DB_OPVEC(&RstrFrmDialogue), DB_USRROUT(&_mbprintout), DB_END, }; -static dlgBoxStr _mbdlg_OK = { +static const dlgBoxStr _mbdlg_OK = { DB_DEFPOS(1), DB_USRROUT(&_mbprintout), DB_ICON(OK, DBI_X_1, DBI_Y_2), DB_END, }; -static dlgBoxStr _mbdlg_OKCANCEL = { +static const dlgBoxStr _mbdlg_OKCANCEL = { DB_DEFPOS(1), DB_USRROUT(&_mbprintout), DB_ICON(OK, DBI_X_0, DBI_Y_2), @@ -32,7 +32,7 @@ static dlgBoxStr _mbdlg_OKCANCEL = { DB_END, }; -static dlgBoxStr _mbdlg_YESNO = { +static const dlgBoxStr _mbdlg_YESNO = { DB_DEFPOS(1), DB_USRROUT(&_mbprintout), DB_ICON(YES, DBI_X_0, DBI_Y_2), @@ -40,7 +40,7 @@ static dlgBoxStr _mbdlg_YESNO = { DB_END, }; -static dlgBoxStr *_mbboxes[] = { +static const dlgBoxStr * const _mbboxes[] = { &_mbdlg_EMPTY, &_mbdlg_OK, &_mbdlg_OKCANCEL, diff --git a/src/ca65/dbginfo.c b/src/ca65/dbginfo.c index 8a55f9ddc..135739fb5 100644 --- a/src/ca65/dbginfo.c +++ b/src/ca65/dbginfo.c @@ -211,7 +211,7 @@ void DbgInfoFile (void) void DbgInfoFunc (void) /* Parse and handle func subcommand of the .dbg pseudo instruction */ { - static const char* StorageKeys[] = { + static const char* const StorageKeys[] = { "EXTERN", "STATIC", }; @@ -352,7 +352,7 @@ void DbgInfoLine (void) void DbgInfoSym (void) /* Parse and handle SYM subcommand of the .dbg pseudo instruction */ { - static const char* StorageKeys[] = { + static const char* const StorageKeys[] = { "AUTO", "EXTERN", "REGISTER", diff --git a/src/ca65/feature.c b/src/ca65/feature.c index 35bdf4b98..0fb766b6f 100644 --- a/src/ca65/feature.c +++ b/src/ca65/feature.c @@ -48,7 +48,7 @@ /* Names of the features */ -static const char* FeatureKeys[FEAT_COUNT] = { +static const char* const FeatureKeys[FEAT_COUNT] = { "dollar_is_pc", "labels_without_colons", "loose_string_term", diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index f84f21d7f..5dd67af90 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -151,7 +151,7 @@ static unsigned char OptionalAddrSize (void) static void SetBoolOption (unsigned char* Flag) /* Read a on/off/+/- option and set flag accordingly */ { - static const char* Keys[] = { + static const char* const Keys[] = { "OFF", "ON", }; @@ -451,7 +451,7 @@ static void DoASCIIZ (void) static void DoAssert (void) /* Add an assertion */ { - static const char* ActionTab [] = { + static const char* const ActionTab [] = { "WARN", "WARNING", "ERROR", "LDWARN", "LDWARNING", @@ -659,7 +659,7 @@ static void DoCode (void) static void DoConDes (void) /* Export a symbol as constructor/destructor */ { - static const char* Keys[] = { + static const char* const Keys[] = { "CONSTRUCTOR", "DESTRUCTOR", "INTERRUPTOR", @@ -744,7 +744,7 @@ static void DoData (void) static void DoDbg (void) /* Add debug information from high level code */ { - static const char* Keys[] = { + static const char* const Keys[] = { "FILE", "FUNC", "LINE", @@ -1039,7 +1039,7 @@ static void DoFileOpt (void) if (CurTok.Tok == TOK_IDENT) { /* Option given as keyword */ - static const char* Keys [] = { + static const char* const Keys [] = { "AUTHOR", "COMMENT", "COMPILER" }; diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index e186b19a7..7c291666c 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1477,7 +1477,7 @@ CharAgain: -int GetSubKey (const char** Keys, unsigned Count) +int GetSubKey (const char* const* Keys, unsigned Count) /* Search for a subkey in a table of keywords. The current token must be an ** identifier and all keys must be in upper case. The identifier will be ** uppercased in the process. The function returns the index of the keyword, diff --git a/src/ca65/scanner.h b/src/ca65/scanner.h index c445aefa6..4fd9041c1 100644 --- a/src/ca65/scanner.h +++ b/src/ca65/scanner.h @@ -84,7 +84,7 @@ void UpcaseSVal (void); void NextRawTok (void); /* Read the next raw token from the input stream */ -int GetSubKey (const char** Keys, unsigned Count); +int GetSubKey (const char* const* Keys, unsigned Count); /* Search for a subkey in a table of keywords. The current token must be an ** identifier and all keys must be in upper case. The identifier will be ** uppercased in the process. The function returns the index of the keyword, diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index bf0251813..d9074e539 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -2211,7 +2211,7 @@ void g_cmp (unsigned flags, unsigned long val) -static void oper (unsigned Flags, unsigned long Val, const char** Subs) +static void oper (unsigned Flags, unsigned long Val, const char* const* Subs) /* Encode a binary operation. subs is a pointer to four strings: ** 0 --> Operate on ints ** 1 --> Operate on unsigneds @@ -2499,7 +2499,7 @@ void g_stackcheck (void) void g_add (unsigned flags, unsigned long val) /* Primary = TOS + Primary */ { - static const char* ops[12] = { + static const char* const ops[4] = { "tosaddax", "tosaddax", "tosaddeax", "tosaddeax" }; @@ -2515,8 +2515,8 @@ void g_add (unsigned flags, unsigned long val) void g_sub (unsigned flags, unsigned long val) /* Primary = TOS - Primary */ { - static const char* ops[12] = { - "tossubax", "tossubax", "tossubeax", "tossubeax", + static const char* const ops[4] = { + "tossubax", "tossubax", "tossubeax", "tossubeax" }; if (flags & CF_CONST) { @@ -2531,8 +2531,8 @@ void g_sub (unsigned flags, unsigned long val) void g_rsub (unsigned flags, unsigned long val) /* Primary = Primary - TOS */ { - static const char* ops[12] = { - "tosrsubax", "tosrsubax", "tosrsubeax", "tosrsubeax", + static const char* const ops[4] = { + "tosrsubax", "tosrsubax", "tosrsubeax", "tosrsubeax" }; oper (flags, val, ops); } @@ -2542,8 +2542,8 @@ void g_rsub (unsigned flags, unsigned long val) void g_mul (unsigned flags, unsigned long val) /* Primary = TOS * Primary */ { - static const char* ops[12] = { - "tosmulax", "tosumulax", "tosmuleax", "tosumuleax", + static const char* const ops[4] = { + "tosmulax", "tosumulax", "tosmuleax", "tosumuleax" }; int p2; @@ -2649,8 +2649,8 @@ void g_mul (unsigned flags, unsigned long val) void g_div (unsigned flags, unsigned long val) /* Primary = TOS / Primary */ { - static const char* ops[12] = { - "tosdivax", "tosudivax", "tosdiveax", "tosudiveax", + static const char* const ops[4] = { + "tosdivax", "tosudivax", "tosdiveax", "tosudiveax" }; /* Do strength reduction if the value is constant and a power of two */ @@ -2674,8 +2674,8 @@ void g_div (unsigned flags, unsigned long val) void g_mod (unsigned flags, unsigned long val) /* Primary = TOS % Primary */ { - static const char* ops[12] = { - "tosmodax", "tosumodax", "tosmodeax", "tosumodeax", + static const char* const ops[4] = { + "tosmodax", "tosumodax", "tosmodeax", "tosumodeax" }; int p2; @@ -2699,8 +2699,8 @@ void g_mod (unsigned flags, unsigned long val) void g_or (unsigned flags, unsigned long val) /* Primary = TOS | Primary */ { - static const char* ops[12] = { - "tosorax", "tosorax", "tosoreax", "tosoreax", + static const char* const ops[4] = { + "tosorax", "tosorax", "tosoreax", "tosoreax" }; /* If the right hand side is const, the lhs is not on stack but still @@ -2769,8 +2769,8 @@ void g_or (unsigned flags, unsigned long val) void g_xor (unsigned flags, unsigned long val) /* Primary = TOS ^ Primary */ { - static const char* ops[12] = { - "tosxorax", "tosxorax", "tosxoreax", "tosxoreax", + static const char* const ops[4] = { + "tosxorax", "tosxorax", "tosxoreax", "tosxoreax" }; @@ -2837,8 +2837,8 @@ void g_xor (unsigned flags, unsigned long val) void g_and (unsigned Flags, unsigned long Val) /* Primary = TOS & Primary */ { - static const char* ops[12] = { - "tosandax", "tosandax", "tosandeax", "tosandeax", + static const char* const ops[4] = { + "tosandax", "tosandax", "tosandeax", "tosandeax" }; /* If the right hand side is const, the lhs is not on stack but still @@ -2929,8 +2929,8 @@ void g_and (unsigned Flags, unsigned long Val) void g_asr (unsigned flags, unsigned long val) /* Primary = TOS >> Primary */ { - static const char* ops[12] = { - "tosasrax", "tosshrax", "tosasreax", "tosshreax", + static const char* const ops[4] = { + "tosasrax", "tosshrax", "tosasreax", "tosshreax" }; /* If the right hand side is const, the lhs is not on stack but still @@ -3060,8 +3060,8 @@ void g_asr (unsigned flags, unsigned long val) void g_asl (unsigned flags, unsigned long val) /* Primary = TOS << Primary */ { - static const char* ops[12] = { - "tosaslax", "tosshlax", "tosasleax", "tosshleax", + static const char* const ops[4] = { + "tosaslax", "tosshlax", "tosasleax", "tosshleax" }; @@ -3438,8 +3438,8 @@ void g_dec (unsigned flags, unsigned long val) void g_eq (unsigned flags, unsigned long val) /* Test for equal */ { - static const char* ops[12] = { - "toseqax", "toseqax", "toseqeax", "toseqeax", + static const char* const ops[4] = { + "toseqax", "toseqax", "toseqeax", "toseqeax" }; unsigned L; @@ -3492,8 +3492,8 @@ void g_eq (unsigned flags, unsigned long val) void g_ne (unsigned flags, unsigned long val) /* Test for not equal */ { - static const char* ops[12] = { - "tosneax", "tosneax", "tosneeax", "tosneeax", + static const char* const ops[4] = { + "tosneax", "tosneax", "tosneeax", "tosneeax" }; unsigned L; @@ -3546,7 +3546,7 @@ void g_ne (unsigned flags, unsigned long val) void g_lt (unsigned flags, unsigned long val) /* Test for less than */ { - static const char* ops[12] = { + static const char* const ops[4] = { "tosltax", "tosultax", "toslteax", "tosulteax", }; @@ -3708,8 +3708,8 @@ void g_lt (unsigned flags, unsigned long val) void g_le (unsigned flags, unsigned long val) /* Test for less than or equal to */ { - static const char* ops[12] = { - "tosleax", "tosuleax", "tosleeax", "tosuleeax", + static const char* const ops[4] = { + "tosleax", "tosuleax", "tosleeax", "tosuleeax" }; @@ -3823,8 +3823,8 @@ void g_le (unsigned flags, unsigned long val) void g_gt (unsigned flags, unsigned long val) /* Test for greater than */ { - static const char* ops[12] = { - "tosgtax", "tosugtax", "tosgteax", "tosugteax", + static const char* const ops[4] = { + "tosgtax", "tosugtax", "tosgteax", "tosugteax" }; @@ -3954,8 +3954,8 @@ void g_gt (unsigned flags, unsigned long val) void g_ge (unsigned flags, unsigned long val) /* Test for greater than or equal to */ { - static const char* ops[12] = { - "tosgeax", "tosugeax", "tosgeeax", "tosugeeax", + static const char* const ops[4] = { + "tosgeax", "tosugeax", "tosgeeax", "tosugeeax" }; unsigned Label; diff --git a/src/cc65/coptstop.c b/src/cc65/coptstop.c index cf6392bd3..41d928750 100644 --- a/src/cc65/coptstop.c +++ b/src/cc65/coptstop.c @@ -1711,7 +1711,7 @@ static int HarmlessCall (const char* Name) ** the pushax/op sequence when encountered. */ { - static const char* Tab[] = { + static const char* const Tab[] = { "aslax1", "aslax2", "aslax3", diff --git a/src/cc65/standard.c b/src/cc65/standard.c index 36897a059..f26b63c20 100644 --- a/src/cc65/standard.c +++ b/src/cc65/standard.c @@ -50,7 +50,7 @@ IntStack Standard = INTSTACK(STD_UNKNOWN); /* Table mapping names to standards, sorted by standard. */ -static const char* StdNames[STD_COUNT] = { +static const char* const StdNames[STD_COUNT] = { "c89", "c99", "cc65" }; diff --git a/src/co65/model.c b/src/co65/model.c index 87a6966b7..bb815cd15 100644 --- a/src/co65/model.c +++ b/src/co65/model.c @@ -52,7 +52,7 @@ O65Model Model = O65_MODEL_NONE; /* Name table */ -static const char* NameTable[O65_MODEL_COUNT] = { +static const char* const NameTable[O65_MODEL_COUNT] = { "none", "os/a65", "lunix", diff --git a/src/da65/labels.c b/src/da65/labels.c index 547a79869..6aa7f38cf 100644 --- a/src/da65/labels.c +++ b/src/da65/labels.c @@ -264,11 +264,11 @@ const char* GetLabel (unsigned Addr, unsigned RefFrom) ** of unnamed labels, to determine the name. */ { - static const char* FwdLabels[] = { + static const char* const FwdLabels[] = { ":+", ":++", ":+++", ":++++", ":+++++", ":++++++", ":+++++++", ":++++++++", ":+++++++++", ":++++++++++" }; - static const char* BackLabels[] = { + static const char* const BackLabels[] = { ":-", ":--", ":---", ":----", ":-----", ":------", ":-------", ":--------", ":---------", ":----------" }; diff --git a/src/grc65/main.c b/src/grc65/main.c index 2a1fef953..d36f039e6 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -226,18 +226,15 @@ static void openSFile (void) } -static int findToken (const char **tokenTbl, const char *token) +static int findToken (const char * const *tokenTbl, const char *token) { /* takes as input table of tokens and token, returns position in table or -1 if not found */ - int a = 0; - - while (strlen (tokenTbl[a]) != 0) { - if (strcmp (tokenTbl[a], token) == 0) break; - a++; + int i; + for (i = 0; tokenTbl[i][0]; i++) { + if (strcmp (tokenTbl[i], token) == 0) return i; } - if (strlen (tokenTbl[a]) == 0) a = -1; - return a; + return -1; } diff --git a/src/sp65/attr.c b/src/sp65/attr.c index db026af48..e57b86973 100644 --- a/src/sp65/attr.c +++ b/src/sp65/attr.c @@ -240,7 +240,7 @@ void SplitAddAttr (Collection* C, const char* Combined, const char* Name) -Collection* ParseAttrList (const char* List, const char** NameList, unsigned NameCount) +Collection* ParseAttrList (const char* List, const char* const* NameList, unsigned NameCount) /* Parse a list containing name/value pairs into a sorted collection. Some ** attributes may not need a name, so NameList contains these names. If there ** were no errors, the function returns a alphabetically sorted collection diff --git a/src/sp65/attr.h b/src/sp65/attr.h index 2b7ce68b9..e93bcd937 100644 --- a/src/sp65/attr.h +++ b/src/sp65/attr.h @@ -111,7 +111,7 @@ void SplitAddAttr (Collection* C, const char* Combined, const char* Name); ** Name is NULL, terminate with an error. */ -Collection* ParseAttrList (const char* List, const char** NameList, unsigned NameCount); +Collection* ParseAttrList (const char* List, const char* const* NameList, unsigned NameCount); /* Parse a list containing name/value pairs into a sorted collection. Some ** attributes may not need a name, so NameList contains these names. If there ** were no errors, the function returns a alphabetically sorted collection diff --git a/src/sp65/main.c b/src/sp65/main.c index 828a48fc8..5c9724a8a 100644 --- a/src/sp65/main.c +++ b/src/sp65/main.c @@ -141,7 +141,7 @@ static void SetOutputData (StrBuf* N) static void OptConvertTo (const char* Opt attribute ((unused)), const char* Arg) /* Convert the bitmap into a target format */ { - static const char* NameList[] = { + static const char* const NameList[] = { "format" }; @@ -220,7 +220,7 @@ static void OptPop (const char* Opt attribute ((unused)), static void OptRead (const char* Opt attribute ((unused)), const char* Arg) /* Read an input file */ { - static const char* NameList[] = { + static const char* const NameList[] = { "name", "format" }; @@ -294,7 +294,7 @@ static void OptVersion (const char* Opt attribute ((unused)), static void OptWrite (const char* Opt attribute ((unused)), const char* Arg) /* Write an output file */ { - static const char* NameList[] = { + static const char* const NameList[] = { "name", "format" }; From 141c25b42b4df1c32ceb36e2661cddb48ac9c0e0 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Thu, 29 Jun 2017 13:34:10 -0400 Subject: [PATCH 374/407] Added the extra dependency file's directory as an order-only prerequisite. The extra dependency files are put into different places than the extra object files' location. Therefore, the rule must pre-make two directories. --- libsrc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index e106aa239..89d4b7752 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -280,7 +280,7 @@ endef # COMPILE_recipe ../libwrk/$(TARGET)/%.o: %.c | ../libwrk/$(TARGET) $(COMPILE_recipe) -$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib +$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../libwrk/$(TARGET) ../lib @echo $(TARGET) - $(<F) @$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:../lib/%.o=../libwrk/$(TARGET)/%.d) -o $@ $< From c0812670c11411ed99404cc3f936a2cd9259bc14 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Fri, 30 Jun 2017 07:35:21 +0200 Subject: [PATCH 375/407] Fix coding style. --- src/cc65/codegen.c | 2 +- src/grc65/main.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index d9074e539..dfc06fccc 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -3547,7 +3547,7 @@ void g_lt (unsigned flags, unsigned long val) /* Test for less than */ { static const char* const ops[4] = { - "tosltax", "tosultax", "toslteax", "tosulteax", + "tosltax", "tosultax", "toslteax", "tosulteax" }; unsigned Label; diff --git a/src/grc65/main.c b/src/grc65/main.c index d36f039e6..a53801a39 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -230,8 +230,11 @@ static int findToken (const char * const *tokenTbl, const char *token) { /* takes as input table of tokens and token, returns position in table or -1 if not found */ int i; + for (i = 0; tokenTbl[i][0]; i++) { - if (strcmp (tokenTbl[i], token) == 0) return i; + if (strcmp (tokenTbl[i], token) == 0) { + return i; + } } return -1; From 6de78c536f78bc47129a7d4da4ad10f7e3a27b8f Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 30 Jun 2017 09:50:28 +0200 Subject: [PATCH 376/407] Made DOS 3.3 IRQ statement more general. I recently came across that the question if a driver is compatible with DOS 3.3 isn't about the fact if it actually uses IRQs but if it potentially could use IRQs as the driver kernel pulls in the IRQ handler anyway. This is especially suboptimal in the scenario of statically linked drivers where it is concpetually totally clear at link time they use IRQs or not. Apart from that it might make sense to be able to define on a per-target basis if _any_ of the drivers of a certain class uses IRQs. If that isn't the cases the driver kernel for that driver class for that target could omit IRQ handling too. I'm aware that Uz imagined drivers being loaded which weren't known when the program was linked - but I don't see this. --- doc/apple2.sgml | 2 +- doc/apple2enh.sgml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index d0405b6de..3089a04c4 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -435,7 +435,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3: <tag/Interrupts/ There's no <tt/interruptor/ support. Any attempt to use it yields the message 'FAILED TO ALLOC INTERRUPT' on program startup. This implicitly means that - <tt/a2.stdmou.mou/ and <tt/a2.ssc.ser/ are not functional as they depend on + joystick, mouse and RS232 device drivers are not functional as they depend on interrupts. </descrip><p> diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index b5231b4cd..5e4626fbc 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -436,7 +436,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3: <tag/Interrupts/ There's no <tt/interruptor/ support. Any attempt to use it yields the message 'Failed to alloc interrupt' on program startup. This implicitly means that - <tt/a2e.stdmou.mou/ and <tt/a2e.ssc.ser/ are not functional as they depend on + joystick, mouse and RS232 device drivers are not functional as they depend on interrupts. </descrip><p> From ea7f4d748942ad0fd34f68502531db6c0b15aca5 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Mon, 17 Jul 2017 19:43:11 +0200 Subject: [PATCH 377/407] pragma: bring pragma_t enum in line with Pragmas struct fixes an inconsequential inconsistency, might prevent some confusion in the future. --- src/cc65/pragma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index de1979c12..d50d151a7 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -79,8 +79,8 @@ typedef enum { PRAGMA_INLINE_STDFUNCS, PRAGMA_LOCAL_STRINGS, PRAGMA_OPTIMIZE, - PRAGMA_REGVARADDR, PRAGMA_REGISTER_VARS, + PRAGMA_REGVARADDR, PRAGMA_REGVARS, /* obsolete */ PRAGMA_RODATA_NAME, PRAGMA_RODATASEG, /* obsolete */ From 1abce3a2a1d7df81a580e9120a34e1d697085b3e Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 17 Jul 2017 23:15:05 +0200 Subject: [PATCH 378/407] rename all waitvblank() to waitvsync() --- doc/funcref.sgml | 2 +- doc/nes.sgml | 4 ++-- doc/pce.sgml | 2 +- doc/supervision.sgml | 2 +- include/gamate.h | 4 ++-- include/nes.h | 4 ++-- include/pce.h | 4 ++-- libsrc/c128/{waitvblank.s => waitvsync.s} | 4 ++-- libsrc/c64/{waitvblank.s => waitvsync.s} | 4 ++-- libsrc/cbm510/{waitvblank.s => waitvsync.s} | 4 ++-- libsrc/gamate/{waitvblank.s => waitvsync.s} | 6 +++--- libsrc/nes/{waitvblank.s => waitvsync.s} | 6 +++--- libsrc/pce/{waitvblank.s => waitvsync.s} | 6 +++--- libsrc/vic20/{waitvblank.s => waitvsync.s} | 4 ++-- testcode/lib/conio.c | 4 ++-- testcode/lib/gamate/ctest.c | 2 +- testcode/lib/pce/conio.c | 2 +- 17 files changed, 32 insertions(+), 32 deletions(-) rename libsrc/c128/{waitvblank.s => waitvsync.s} (87%) rename libsrc/c64/{waitvblank.s => waitvsync.s} (75%) rename libsrc/cbm510/{waitvblank.s => waitvsync.s} (88%) rename libsrc/gamate/{waitvblank.s => waitvsync.s} (74%) rename libsrc/nes/{waitvblank.s => waitvsync.s} (73%) rename libsrc/pce/{waitvblank.s => waitvsync.s} (71%) rename libsrc/vic20/{waitvblank.s => waitvsync.s} (88%) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index a2ccf6c73..b5295a63b 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -415,7 +415,7 @@ function. <!-- <itemize> --> <!-- <item><ref id="get_tv" name="get_tv"> --> -<!-- <item><ref id="waitvblank" name="waitvblank"> --> +<!-- <item><ref id="waitvsync" name="waitvsync"> --> <!-- </itemize> --> (incomplete) diff --git a/doc/nes.sgml b/doc/nes.sgml index 98c25b6af..31d1aa396 100644 --- a/doc/nes.sgml +++ b/doc/nes.sgml @@ -1,4 +1,4 @@ -<!doctype linuxdoc system> +<!-- <!doctype linuxdoc system> //--> <article> @@ -69,7 +69,7 @@ Programs containing NES specific code may use the <tt/nes.h/ header file. <sect1>NES specific functions<p> <itemize> -<item>waitvblank - wait until the start of vblank +<item>waitvsync - wait until the start of the next frame <item>get_tv </itemize> diff --git a/doc/pce.sgml b/doc/pce.sgml index ba59c31a7..124cb329e 100644 --- a/doc/pce.sgml +++ b/doc/pce.sgml @@ -77,7 +77,7 @@ Programs containing PCE specific code may use the <tt/pce.h/ header file. <sect1>PCE specific functions<p> <itemize> -<item>waitvblank</item> +<item>waitvsync</item> <item>get_tv (since all PCE systems are NTSC, this always returns TV_NTSC)</item> </itemize> diff --git a/doc/supervision.sgml b/doc/supervision.sgml index 97495dea5..2466aa480 100644 --- a/doc/supervision.sgml +++ b/doc/supervision.sgml @@ -66,7 +66,7 @@ Programs containing Supervision specific code may use the <tt/supervision.h/ hea <sect1>Supervision specific functions<p> <itemize> -<item>waitvblank +<item>waitvsync </itemize> diff --git a/include/gamate.h b/include/gamate.h index 82bca08b1..96c70c9bc 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -188,8 +188,8 @@ extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ #define JOY_START 6 #define JOY_SELECT 7 -void waitvblank (void); -/* Wait for the vertical blanking */ +void waitvsync (void); +/* Wait for start of next frame */ /* NOTE: all Gamate are "NTSC" */ #define get_tv() TV_NTSC diff --git a/include/nes.h b/include/nes.h index a472a0f3c..95e2fe93b 100644 --- a/include/nes.h +++ b/include/nes.h @@ -163,8 +163,8 @@ extern void nes_64_56_2_tgi[]; /* Referred to by tgi_static_stddrv[] */ -void waitvblank (void); -/* Wait for the vertical blanking */ +void waitvsync (void); +/* Wait for start of the next frame */ unsigned char get_tv (void); /* Return the video mode the machine is using. */ diff --git a/include/pce.h b/include/pce.h index 7700654c8..856a2fa1d 100644 --- a/include/pce.h +++ b/include/pce.h @@ -83,8 +83,8 @@ extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ #define JOY_SELECT 6 #define JOY_RUN 7 -void waitvblank (void); -/* Wait for the vertical blanking */ +void waitvsync (void); +/* Wait for start of the next frame */ /* NOTE: all PCE are NTSC */ #define get_tv() TV_NTSC diff --git a/libsrc/c128/waitvblank.s b/libsrc/c128/waitvsync.s similarity index 87% rename from libsrc/c128/waitvblank.s rename to libsrc/c128/waitvsync.s index c144e11c2..1597e5fa0 100644 --- a/libsrc/c128/waitvblank.s +++ b/libsrc/c128/waitvsync.s @@ -1,9 +1,9 @@ - .export _waitvblank + .export _waitvsync .include "c128.inc" -_waitvblank: +_waitvsync: bit MODE bmi @c80 diff --git a/libsrc/c64/waitvblank.s b/libsrc/c64/waitvsync.s similarity index 75% rename from libsrc/c64/waitvblank.s rename to libsrc/c64/waitvsync.s index dd9087841..15ef61bb7 100644 --- a/libsrc/c64/waitvblank.s +++ b/libsrc/c64/waitvsync.s @@ -1,9 +1,9 @@ - .export _waitvblank + .export _waitvsync .include "c64.inc" -_waitvblank: +_waitvsync: @l1: bit VIC_CTRL1 bpl @l1 diff --git a/libsrc/cbm510/waitvblank.s b/libsrc/cbm510/waitvsync.s similarity index 88% rename from libsrc/cbm510/waitvblank.s rename to libsrc/cbm510/waitvsync.s index 975861f2c..bd631e4d6 100644 --- a/libsrc/cbm510/waitvblank.s +++ b/libsrc/cbm510/waitvsync.s @@ -1,5 +1,5 @@ - .export _waitvblank + .export _waitvsync .import PALFLAG .import sys_bank, restore_bank @@ -7,7 +7,7 @@ .include "cbm510.inc" -_waitvblank: +_waitvsync: rts ; FIXME jsr sys_bank ; Switch to the system bank diff --git a/libsrc/gamate/waitvblank.s b/libsrc/gamate/waitvsync.s similarity index 74% rename from libsrc/gamate/waitvblank.s rename to libsrc/gamate/waitvsync.s index 66686c08a..9b1199055 100644 --- a/libsrc/gamate/waitvblank.s +++ b/libsrc/gamate/waitvsync.s @@ -1,16 +1,16 @@ ; -; void waitvblank (void); +; void waitvsync (void); ; .include "gamate.inc" .include "extzp.inc" .forceimport ticktock - .export _waitvblank + .export _waitvsync ; FIXME: is this actually correct? -.proc _waitvblank +.proc _waitvsync lda tickcount @lp: cmp tickcount diff --git a/libsrc/nes/waitvblank.s b/libsrc/nes/waitvsync.s similarity index 73% rename from libsrc/nes/waitvblank.s rename to libsrc/nes/waitvsync.s index 408646904..11a231ac4 100644 --- a/libsrc/nes/waitvblank.s +++ b/libsrc/nes/waitvsync.s @@ -2,14 +2,14 @@ ; Written by Groepaz/Hitmen <groepaz@gmx.net> ; Cleanup by Ullrich von Bassewitz <uz@cc65.org> ; -; void waitvblank(void); +; void waitvsync(void); ; - .export _waitvblank + .export _waitvsync .include "nes.inc" -.proc _waitvblank +.proc _waitvsync wait: lda PPU_STATUS bpl wait diff --git a/libsrc/pce/waitvblank.s b/libsrc/pce/waitvsync.s similarity index 71% rename from libsrc/pce/waitvblank.s rename to libsrc/pce/waitvsync.s index b9f0f902f..f1eab36f8 100644 --- a/libsrc/pce/waitvblank.s +++ b/libsrc/pce/waitvsync.s @@ -1,14 +1,14 @@ ; -; void waitvblank (void); +; void waitvsync (void); ; .include "pce.inc" .include "extzp.inc" .forceimport ticktock - .export _waitvblank + .export _waitvsync -.proc _waitvblank +.proc _waitvsync lda tickcount @lp: cmp tickcount diff --git a/libsrc/vic20/waitvblank.s b/libsrc/vic20/waitvsync.s similarity index 88% rename from libsrc/vic20/waitvblank.s rename to libsrc/vic20/waitvsync.s index 246c44640..9f0d50565 100644 --- a/libsrc/vic20/waitvblank.s +++ b/libsrc/vic20/waitvsync.s @@ -1,4 +1,4 @@ - .export _waitvblank + .export _waitvsync .include "vic20.inc" @@ -7,7 +7,7 @@ ; it will have to be filled by a get_tv() constructor or so PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC -_waitvblank: +_waitvsync: lda PALFLAG beq @ntsc ldx #(312-8)/2 diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index fe977ec08..13188d1cd 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -117,8 +117,8 @@ void main(void) gotoxy(7 + inpos,1); #if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) - /* not all targets have waitvblank */ - waitvblank(); + /* not all targets have waitvsync */ + waitvsync(); /* for targets that do not have a keyboard, read the first joystick */ joy = joy_read(JOY_1); diff --git a/testcode/lib/gamate/ctest.c b/testcode/lib/gamate/ctest.c index dfebd9bef..793770cee 100644 --- a/testcode/lib/gamate/ctest.c +++ b/testcode/lib/gamate/ctest.c @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) break; } - waitvblank(); + waitvsync(); (*((unsigned char*)LCD_XPOS)) = x; (*((unsigned char*)LCD_YPOS)) = y; diff --git a/testcode/lib/pce/conio.c b/testcode/lib/pce/conio.c index a4bd63b15..00ae3c157 100644 --- a/testcode/lib/pce/conio.c +++ b/testcode/lib/pce/conio.c @@ -123,7 +123,7 @@ void main(void) p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]); } - waitvblank(); + waitvsync(); ++n; } } From d965601a5e56a04c14ba6ba7abd6f56a459a7238 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 17 Jul 2017 23:31:01 +0200 Subject: [PATCH 379/407] fix sgml --- doc/nes.sgml | 4 ++-- doc/supervision.sgml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/nes.sgml b/doc/nes.sgml index 31d1aa396..e806d753f 100644 --- a/doc/nes.sgml +++ b/doc/nes.sgml @@ -69,8 +69,8 @@ Programs containing NES specific code may use the <tt/nes.h/ header file. <sect1>NES specific functions<p> <itemize> -<item>waitvsync - wait until the start of the next frame -<item>get_tv +<item>waitvsync - wait until the start of the next frame</item> +<item>get_tv</item> </itemize> diff --git a/doc/supervision.sgml b/doc/supervision.sgml index 2466aa480..cf2af7967 100644 --- a/doc/supervision.sgml +++ b/doc/supervision.sgml @@ -66,7 +66,7 @@ Programs containing Supervision specific code may use the <tt/supervision.h/ hea <sect1>Supervision specific functions<p> <itemize> -<item>waitvsync +<item>waitvsync</item> </itemize> From 33791c6efdae474ac2ee9fc35e4dfc942e2a6bd5 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 17 Jul 2017 23:43:08 +0200 Subject: [PATCH 380/407] added prototype to cbm.h --- include/cbm.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/cbm.h b/include/cbm.h index 701924d57..4bbd278e3 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -153,7 +153,10 @@ struct cbm_dirent { unsigned char get_tv (void); /* Return the video mode the machine is using. */ - +#if !defined(__PLUS4__) && !defined(__C16__) && !defined(__CBM610__) && !defined(__PET__) +void waitvsync (void); +/* wait for the start of the next frame */ +#endif /*****************************************************************************/ /* CBM kernal functions */ From fe850fece8d6352f695586e9c34830ae94f52ae3 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 17 Jul 2017 23:55:18 +0200 Subject: [PATCH 381/407] implement waitvsync for plus4/c16 --- include/cbm.h | 2 +- libsrc/plus4/waitvsync.s | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 libsrc/plus4/waitvsync.s diff --git a/include/cbm.h b/include/cbm.h index 4bbd278e3..f35f83828 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -153,7 +153,7 @@ struct cbm_dirent { unsigned char get_tv (void); /* Return the video mode the machine is using. */ -#if !defined(__PLUS4__) && !defined(__C16__) && !defined(__CBM610__) && !defined(__PET__) +#if !defined(__CBM610__) && !defined(__PET__) void waitvsync (void); /* wait for the start of the next frame */ #endif diff --git a/libsrc/plus4/waitvsync.s b/libsrc/plus4/waitvsync.s new file mode 100644 index 000000000..84654d996 --- /dev/null +++ b/libsrc/plus4/waitvsync.s @@ -0,0 +1,12 @@ + + .export _waitvsync + + .include "plus4.inc" + +_waitvsync: +@l1: + lda TED_VLINEHI + and #$01 + ora TED_VLINELO + bne @l1 + rts From cbdad764f0eff850d37bf0a0520a33c69c840c66 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 18 Jul 2017 00:01:15 +0200 Subject: [PATCH 382/407] oops --- doc/nes.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/nes.sgml b/doc/nes.sgml index e806d753f..8f4374e05 100644 --- a/doc/nes.sgml +++ b/doc/nes.sgml @@ -1,4 +1,4 @@ -<!-- <!doctype linuxdoc system> //--> +<!doctype linuxdoc system> <article> From c24080f28931976f8919fd1d2d65e931d0d91fa0 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 18 Jul 2017 00:41:54 +0200 Subject: [PATCH 383/407] do banking --- libsrc/cbm510/waitvsync.s | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libsrc/cbm510/waitvsync.s b/libsrc/cbm510/waitvsync.s index bd631e4d6..db6c16179 100644 --- a/libsrc/cbm510/waitvsync.s +++ b/libsrc/cbm510/waitvsync.s @@ -8,10 +8,7 @@ .include "cbm510.inc" _waitvsync: - rts ; FIXME - - jsr sys_bank ; Switch to the system bank - + jsr sys_bank ; Switch to the system bank sei ldy #VIC_CTRL1 From 8eee51913a43e1f5614033e745e6f3c1bf11000a Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 18 Jul 2017 01:04:53 +0200 Subject: [PATCH 384/407] add headers/fix formatting --- libsrc/c128/waitvsync.s | 5 +++++ libsrc/c64/waitvsync.s | 5 +++++ libsrc/cbm510/waitvsync.s | 19 ++++++++++++------- libsrc/gamate/waitvsync.s | 2 ++ libsrc/nes/waitvsync.s | 2 +- libsrc/pce/waitvsync.s | 2 ++ libsrc/plus4/waitvsync.s | 5 +++++ libsrc/vic20/waitvsync.s | 6 ++++++ 8 files changed, 38 insertions(+), 8 deletions(-) diff --git a/libsrc/c128/waitvsync.s b/libsrc/c128/waitvsync.s index 1597e5fa0..e4bbbf7c9 100644 --- a/libsrc/c128/waitvsync.s +++ b/libsrc/c128/waitvsync.s @@ -1,3 +1,8 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; .export _waitvsync diff --git a/libsrc/c64/waitvsync.s b/libsrc/c64/waitvsync.s index 15ef61bb7..a4bf13080 100644 --- a/libsrc/c64/waitvsync.s +++ b/libsrc/c64/waitvsync.s @@ -1,3 +1,8 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; .export _waitvsync diff --git a/libsrc/cbm510/waitvsync.s b/libsrc/cbm510/waitvsync.s index db6c16179..ed7300f7c 100644 --- a/libsrc/cbm510/waitvsync.s +++ b/libsrc/cbm510/waitvsync.s @@ -1,3 +1,8 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; .export _waitvsync .import PALFLAG @@ -8,16 +13,16 @@ .include "cbm510.inc" _waitvsync: - jsr sys_bank ; Switch to the system bank + jsr sys_bank ; Switch to the system bank sei - ldy #VIC_CTRL1 + ldy #VIC_CTRL1 @l1: - lda (vic),y - bpl @l1 + lda (vic),y + bpl @l1 @l2: - lda (vic),y - bmi @l2 + lda (vic),y + bmi @l2 cli - jmp restore_bank + jmp restore_bank diff --git a/libsrc/gamate/waitvsync.s b/libsrc/gamate/waitvsync.s index 9b1199055..dee83400d 100644 --- a/libsrc/gamate/waitvsync.s +++ b/libsrc/gamate/waitvsync.s @@ -1,4 +1,6 @@ ; +; Written by Groepaz <groepaz@gmx.net> +; ; void waitvsync (void); ; diff --git a/libsrc/nes/waitvsync.s b/libsrc/nes/waitvsync.s index 11a231ac4..4bdf9a9d0 100644 --- a/libsrc/nes/waitvsync.s +++ b/libsrc/nes/waitvsync.s @@ -1,5 +1,5 @@ ; -; Written by Groepaz/Hitmen <groepaz@gmx.net> +; Written by Groepaz <groepaz@gmx.net> ; Cleanup by Ullrich von Bassewitz <uz@cc65.org> ; ; void waitvsync(void); diff --git a/libsrc/pce/waitvsync.s b/libsrc/pce/waitvsync.s index f1eab36f8..c6435dabd 100644 --- a/libsrc/pce/waitvsync.s +++ b/libsrc/pce/waitvsync.s @@ -1,4 +1,6 @@ ; +; Written by Groepaz <groepaz@gmx.net> +; ; void waitvsync (void); ; diff --git a/libsrc/plus4/waitvsync.s b/libsrc/plus4/waitvsync.s index 84654d996..32b81b52b 100644 --- a/libsrc/plus4/waitvsync.s +++ b/libsrc/plus4/waitvsync.s @@ -1,3 +1,8 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; .export _waitvsync diff --git a/libsrc/vic20/waitvsync.s b/libsrc/vic20/waitvsync.s index 9f0d50565..b5861ada3 100644 --- a/libsrc/vic20/waitvsync.s +++ b/libsrc/vic20/waitvsync.s @@ -1,3 +1,9 @@ +; +; Written by Groepaz <groepaz@gmx.net> +; +; void waitvsync (void); +; + .export _waitvsync .include "vic20.inc" From b6d3d32e88468eff8c10939efb8653833702512d Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 18 Jul 2017 01:06:20 +0200 Subject: [PATCH 385/407] wait for line 0 instead of last line --- libsrc/vic20/waitvsync.s | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/libsrc/vic20/waitvsync.s b/libsrc/vic20/waitvsync.s index b5861ada3..1c76f2497 100644 --- a/libsrc/vic20/waitvsync.s +++ b/libsrc/vic20/waitvsync.s @@ -8,20 +8,9 @@ .include "vic20.inc" -; FIXME -; this flag doesnt work on vic20!!! -; it will have to be filled by a get_tv() constructor or so -PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC - _waitvsync: - lda PALFLAG - beq @ntsc - ldx #(312-8)/2 - .byte $2c -@ntsc: - ldx #(262-8)/2 @l2: - cpx VIC_HLINE - bcs @l2 + lda VIC_HLINE + bne @l2 rts From 6e93c1ba7332c55eb2067d7be6d20050912ef27d Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Tue, 18 Jul 2017 18:12:19 +0200 Subject: [PATCH 386/407] pragma: add minimalist message pragma implementation for example: #pragma message ("in a bottle") results in: hello.c(207): Note: in a bottle --- src/cc65/pragma.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index d50d151a7..25bc29d43 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -78,6 +78,7 @@ typedef enum { PRAGMA_DATASEG, /* obsolete */ PRAGMA_INLINE_STDFUNCS, PRAGMA_LOCAL_STRINGS, + PRAGMA_MESSAGE, PRAGMA_OPTIMIZE, PRAGMA_REGISTER_VARS, PRAGMA_REGVARADDR, @@ -114,6 +115,7 @@ static const struct Pragma { { "dataseg", PRAGMA_DATASEG }, /* obsolete */ { "inline-stdfuncs", PRAGMA_INLINE_STDFUNCS }, { "local-strings", PRAGMA_LOCAL_STRINGS }, + { "message", PRAGMA_MESSAGE }, { "optimize", PRAGMA_OPTIMIZE }, { "register-vars", PRAGMA_REGISTER_VARS }, { "regvaraddr", PRAGMA_REGVARADDR }, @@ -750,6 +752,13 @@ static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High) +static void MakeMessage (const char* Message) +{ + fprintf (stderr, "%s(%u): Note: %s\n", GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Message); +} + + + static void ParsePragma (void) /* Parse the contents of the _Pragma statement */ { @@ -849,6 +858,10 @@ static void ParsePragma (void) FlagPragma (&B, &LocalStrings); break; + case PRAGMA_MESSAGE: + StringPragma (&B, MakeMessage); + break; + case PRAGMA_OPTIMIZE: FlagPragma (&B, &Optimize); break; From 2d9922a46e6112ed901dc675d37a6bfc4f928c4d Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Wed, 19 Jul 2017 18:02:13 +0200 Subject: [PATCH 387/407] nes: remove semiredundant KEY_ defines There are already JOY_ defines for most of these, and this should be expanded upon instead. --- include/nes.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/include/nes.h b/include/nes.h index 95e2fe93b..2687e2626 100644 --- a/include/nes.h +++ b/include/nes.h @@ -90,16 +90,6 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 -/* The joystick keys - all keys are supported */ -#define KEY_A 0x01 -#define KEY_B 0x02 -#define KEY_SELECT 0x04 -#define KEY_START 0x08 -#define KEY_UP 0x10 -#define KEY_DOWN 0x20 -#define KEY_LEFT 0x40 -#define KEY_RIGHT 0x80 - /* Define hardware */ /* Picture Processing Unit */ From d277055b5a06ee314fd3c93a562fd494cefbd767 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Wed, 19 Jul 2017 18:14:44 +0200 Subject: [PATCH 388/407] nes: add system specific joy_masks array indices and macros --- include/nes.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/nes.h b/include/nes.h index 2687e2626..3e139e00c 100644 --- a/include/nes.h +++ b/include/nes.h @@ -90,6 +90,17 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 +/* Expanding upon joystick.h */ +#define JOY_A 4 +#define JOY_B 5 +#define JOY_SELECT 6 +#define JOY_START 7 + +#define JOY_BTN_A(v) ((v) & joy_masks[JOY_A]) +#define JOY_BTN_B(v) ((v) & joy_masks[JOY_B]) +#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT]) +#define JOY_BTN_START(v) ((v) & joy_masks[JOY_START]) + /* Define hardware */ /* Picture Processing Unit */ From 8ad72fc9ca78b8018ec1ef223eb1911bbd8965d5 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Wed, 19 Jul 2017 18:29:35 +0200 Subject: [PATCH 389/407] pce: add system specific joy_masks array indices and macros --- include/pce.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/pce.h b/include/pce.h index 856a2fa1d..ac6b2503f 100644 --- a/include/pce.h +++ b/include/pce.h @@ -76,6 +76,17 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 +/* Expanding upon joystick.h */ +#define JOY_I 4 +#define JOY_II 5 +#define JOY_SELECT 6 +#define JOY_RUN 7 + +#define JOY_BTN_I(v) ((v) & joy_masks[JOY_I]) +#define JOY_BTN_II(v) ((v) & joy_masks[JOY_II]) +#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT]) +#define JOY_BTN_RUN(v) ((v) & joy_masks[JOY_RUN]) + /* The addresses of the static drivers */ extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ From 80b27bde5e4eff1ed11dc6c84e3fbe99ae34f038 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Thu, 20 Jul 2017 18:13:39 +0200 Subject: [PATCH 390/407] pragma: add minimalist message pragma documentation documents 6e93c1ba7332c55eb2067d7be6d20050912ef27d --- doc/cc65.sgml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 3689c0b35..cd94f50ac 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1119,6 +1119,23 @@ parameter with the <tt/#pragma/. remembered and output as a whole when translation is finished. +<sect1><tt>#pragma message (<message>)</tt><label id="pragma-message"><p> + + This pragma is used to display informational messages at compile-time. + + The message intented to be displayed must be a string literal. + + Example: + <tscreen><verb> + #pragma message ("in a bottle") + </verb></tscreen> + + Results in the compiler outputting the following to stderr: + <tscreen><verb> + example.c(42): Note: in a bottle + </verb></tscreen> + + <sect1><tt>#pragma optimize ([push,] on|off)</tt><label id="pragma-optimize"><p> Switch optimization on or off. If the argument is "off", optimization is From 64581b65b037b09e0ba80198c092a976a2d49076 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Sat, 22 Jul 2017 16:33:42 +0200 Subject: [PATCH 391/407] samples: install to subdirectory --- samples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Makefile b/samples/Makefile index 949940022..eb2b78f1c 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -237,7 +237,7 @@ samples.atr: samples # Installation rules INSTALL = install -samplesdir = $(prefix)/share/cc65 +samplesdir = $(prefix)/share/cc65/samples install: $(if $(prefix),,$(error variable `prefix' must be set)) From 19f6ae1d54da28dc6d4c13828262a9ea3cd1c5cc Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Sat, 22 Jul 2017 16:38:50 +0200 Subject: [PATCH 392/407] make: change uppercase prefix var --- doc/Makefile | 6 +++--- libsrc/Makefile | 4 ++-- samples/Makefile | 4 ++-- src/Makefile | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 96a3ba59b..33b5c2686 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -6,8 +6,8 @@ endif .SUFFIXES: -htmldir = $(prefix)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html -infodir = $(prefix)/share/info +htmldir = $(PREFIX)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html +infodir = $(PREFIX)/share/info ifdef CMD_EXE @@ -46,7 +46,7 @@ clean: $(RM) -r ../html ../info install: - $(if $(prefix),,$(error variable `prefix' must be set)) + $(if $(PREFIX),,$(error variable `PREFIX' must be set)) ifeq ($(wildcard ../html),../html) $(INSTALL) -d $(DESTDIR)$(htmldir) $(INSTALL) -m0644 ../html/*.* $(DESTDIR)$(htmldir) diff --git a/libsrc/Makefile b/libsrc/Makefile index 89d4b7752..0583b6761 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -72,7 +72,7 @@ endif ifndef TARGET -datadir = $(prefix)/share/cc65 +datadir = $(PREFIX)/share/cc65 all lib: $(TARGETS) @@ -92,7 +92,7 @@ INSTALL = install define INSTALL_recipe -$(if $(prefix),,$(error variable `prefix' must be set)) +$(if $(PREFIX),,$(error variable `PREFIX' must be set)) $(INSTALL) -d $(DESTDIR)$(datadir)/$(dir) $(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir) diff --git a/samples/Makefile b/samples/Makefile index eb2b78f1c..59841d655 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -237,10 +237,10 @@ samples.atr: samples # Installation rules INSTALL = install -samplesdir = $(prefix)/share/cc65/samples +samplesdir = $(PREFIX)/share/cc65/samples install: - $(if $(prefix),,$(error variable `prefix' must be set)) + $(if $(PREFIX),,$(error variable `PREFIX' must be set)) $(INSTALL) -d $(DESTDIR)$(samplesdir) $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos $(INSTALL) -d $(DESTDIR)$(samplesdir)/tutorial diff --git a/src/Makefile b/src/Makefile index 3ce4b676a..8b41ceb9c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -19,8 +19,8 @@ PROGS = ar65 \ .SUFFIXES: -bindir := $(prefix)/bin -datadir := $(if $(prefix),$(prefix)/share/cc65,$(abspath ..)) +bindir := $(PREFIX)/bin +datadir := $(if $(PREFIX),$(PREFIX)/share/cc65,$(abspath ..)) CA65_INC = $(datadir)/asminc CC65_INC = $(datadir)/include @@ -107,7 +107,7 @@ $(RM) /usr/local/bin/$(prog) endef # UNAVAIL_recipe install: - $(if $(prefix),,$(error variable `prefix' must be set)) + $(if $(PREFIX),,$(error variable `PREFIX' must be set)) $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) ../bin/* $(DESTDIR)$(bindir) From c802c9c946376801a0bbf5c501f5f73716c2b00f Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn <pmjdebruijn@pcode.nl> Date: Sat, 22 Jul 2017 15:49:34 +0200 Subject: [PATCH 393/407] joy: refactor generic joy_masks array indices and macros --- include/cbm.h | 7 +++++++ include/gamate.h | 26 +++++++++++--------------- include/joystick.h | 32 ++++++++++++++++++-------------- include/lynx.h | 9 +++++++++ include/nes.h | 16 ++++++++-------- include/pce.h | 20 ++++++++------------ 6 files changed, 61 insertions(+), 49 deletions(-) diff --git a/include/cbm.h b/include/cbm.h index 226a09793..27e82f9f3 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -75,6 +75,13 @@ +/* Expanding upon joystick.h */ +#define JOY_FIRE_IDX 4 + +#define JOY_FIRE(v) ((v) & joy_masks[JOY_FIRE_IDX]) + + + /*****************************************************************************/ /* Variables */ /*****************************************************************************/ diff --git a/include/gamate.h b/include/gamate.h index 96c70c9bc..7355ede84 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -80,17 +80,6 @@ bit 3: */ -#define JOY_DATA 0x4400 - -#define JOY_DATA_UP 0x01 -#define JOY_DATA_DOWN 0x02 -#define JOY_DATA_LEFT 0x04 -#define JOY_DATA_RIGHT 0x08 -#define JOY_DATA_FIRE_A 0x10 -#define JOY_DATA_FIRE_B 0x20 -#define JOY_DATA_START 0x40 -#define JOY_DATA_SELECT 0x80 - /* LCD resolution 160x152 in 4 greys/greens @@ -181,13 +170,20 @@ /* No support for dynamically loadable drivers */ #define DYN_DRV 0 +/* Expanding upon joystick.h */ +#define JOY_BTN_A_IDX 4 +#define JOY_BTN_B_IDX 5 +#define JOY_START_IDX 6 +#define JOY_SELECT_IDX 7 + +#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX]) +#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX]) +#define JOY_START(v) ((v) & joy_masks[JOY_START_IDX]) +#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX]) + /* The addresses of the static drivers */ extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ -#define JOY_FIRE_B 5 -#define JOY_START 6 -#define JOY_SELECT 7 - void waitvsync (void); /* Wait for start of next frame */ diff --git a/include/joystick.h b/include/joystick.h index 710d9b5a6..f08dd432a 100644 --- a/include/joystick.h +++ b/include/joystick.h @@ -52,27 +52,31 @@ #define JOY_ERR_NO_DEVICE 4 /* Device (hardware) not found */ /* Argument for the joy_read function */ -#define JOY_1 0 -#define JOY_2 1 +#define JOY_1 0 +#define JOY_2 1 /* The following codes are *indices* into the joy_masks array */ -#define JOY_UP 0 -#define JOY_DOWN 1 -#define JOY_LEFT 2 -#define JOY_RIGHT 3 -#define JOY_FIRE 4 -#define JOY_FIRE2 5 /* Second fire button if available */ +#define JOY_UP_IDX 0 +#define JOY_DOWN_IDX 1 +#define JOY_LEFT_IDX 2 +#define JOY_RIGHT_IDX 3 +#define JOY_BTN_1_IDX 4 /* Universally available */ +#define JOY_BTN_2_IDX 5 /* Second fire button if available */ +#define JOY_BTN_3_IDX 6 /* Third fire button if available */ +#define JOY_BTN_4_IDX 7 /* Fourth fire button if available */ /* Array of masks used to check the return value of joy_read for a state */ extern const unsigned char joy_masks[8]; /* Macros that evaluate the return code of joy_read */ -#define JOY_BTN_UP(v) ((v) & joy_masks[JOY_UP]) -#define JOY_BTN_DOWN(v) ((v) & joy_masks[JOY_DOWN]) -#define JOY_BTN_LEFT(v) ((v) & joy_masks[JOY_LEFT]) -#define JOY_BTN_RIGHT(v) ((v) & joy_masks[JOY_RIGHT]) -#define JOY_BTN_FIRE(v) ((v) & joy_masks[JOY_FIRE]) -#define JOY_BTN_FIRE2(v) ((v) & joy_masks[JOY_FIRE2]) +#define JOY_UP(v) ((v) & joy_masks[JOY_UP_IDX]) +#define JOY_DOWN(v) ((v) & joy_masks[JOY_DOWN_IDX]) +#define JOY_LEFT(v) ((v) & joy_masks[JOY_LEFT_IDX]) +#define JOY_RIGHT(v) ((v) & joy_masks[JOY_RIGHT_IDX]) +#define JOY_BTN_1(v) ((v) & joy_masks[JOY_BTN_1_IDX]) +#define JOY_BTN_2(v) ((v) & joy_masks[JOY_BTN_2_IDX]) +#define JOY_BTN_3(v) ((v) & joy_masks[JOY_BTN_3_IDX]) +#define JOY_BTN_4(v) ((v) & joy_masks[JOY_BTN_4_IDX]) /* The name of the standard joystick driver for a platform */ extern const char joy_stddrv[]; diff --git a/include/lynx.h b/include/lynx.h index 72f3d5bfd..c30ca6265 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -92,6 +92,15 @@ +/* Expanding upon joystick.h */ +#define JOY_BTN_A_IDX 4 +#define JOY_BTN_B_IDX 5 + +#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX]) +#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX]) + + + /*****************************************************************************/ /* Variables */ /*****************************************************************************/ diff --git a/include/nes.h b/include/nes.h index 3e139e00c..0b65cdbe4 100644 --- a/include/nes.h +++ b/include/nes.h @@ -91,15 +91,15 @@ #define DYN_DRV 0 /* Expanding upon joystick.h */ -#define JOY_A 4 -#define JOY_B 5 -#define JOY_SELECT 6 -#define JOY_START 7 +#define JOY_BTN_A_IDX 4 +#define JOY_BTN_B_IDX 5 +#define JOY_SELECT_IDX 6 +#define JOY_START_IDX 7 -#define JOY_BTN_A(v) ((v) & joy_masks[JOY_A]) -#define JOY_BTN_B(v) ((v) & joy_masks[JOY_B]) -#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT]) -#define JOY_BTN_START(v) ((v) & joy_masks[JOY_START]) +#define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX]) +#define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX]) +#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX]) +#define JOY_START(v) ((v) & joy_masks[JOY_START_IDX]) /* Define hardware */ diff --git a/include/pce.h b/include/pce.h index ac6b2503f..12b596cf9 100644 --- a/include/pce.h +++ b/include/pce.h @@ -77,23 +77,19 @@ #define DYN_DRV 0 /* Expanding upon joystick.h */ -#define JOY_I 4 -#define JOY_II 5 -#define JOY_SELECT 6 -#define JOY_RUN 7 +#define JOY_BTN_I_IDX 4 +#define JOY_BTN_II_IDX 5 +#define JOY_SELECT_IDX 6 +#define JOY_RUN_IDX 7 -#define JOY_BTN_I(v) ((v) & joy_masks[JOY_I]) -#define JOY_BTN_II(v) ((v) & joy_masks[JOY_II]) -#define JOY_BTN_SELECT(v) ((v) & joy_masks[JOY_SELECT]) -#define JOY_BTN_RUN(v) ((v) & joy_masks[JOY_RUN]) +#define JOY_BTN_I(v) ((v) & joy_masks[JOY_BTN_I_IDX]) +#define JOY_BTN_II(v) ((v) & joy_masks[JOY_BTN_II_IDX]) +#define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX]) +#define JOY_RUN(v) ((v) & joy_masks[JOY_RUN_IDX]) /* The addresses of the static drivers */ extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ -#define JOY_FIRE_B 5 -#define JOY_SELECT 6 -#define JOY_RUN 7 - void waitvsync (void); /* Wait for start of the next frame */ From a623169477d5925a1a4e43085f34d0f589804353 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Wed, 26 Jul 2017 11:15:49 -0400 Subject: [PATCH 394/407] Added ProDOS file type definitions --- .gitignore | 3 + include/apple2.h | 1 + include/apple2_filetype.h | 254 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100644 include/apple2_filetype.h diff --git a/.gitignore b/.gitignore index ad4d26c3f..39d5b59fa 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ /testwrk/ /wrk/ /cc65.zip + +# Vim swap files +.*.swp diff --git a/include/apple2.h b/include/apple2.h index a1b094d4d..a2150c173 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -42,6 +42,7 @@ #endif +#include <apple2_filetype.h> /*****************************************************************************/ /* Data */ diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h new file mode 100644 index 000000000..51e7d3e51 --- /dev/null +++ b/include/apple2_filetype.h @@ -0,0 +1,254 @@ +/*****************************************************************************/ +/* */ +/* apple2_filetype.h */ +/* */ +/* Apple ][ file type definitions */ +/* */ +/* */ +/* */ +/* (C) 2000 Kevin Ruland, <kevin@rodin.wustl.edu> */ +/* (C) 2003 Ullrich von Bassewitz, <uz@cc65.org> */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef _APPLE2_FILETYPE_H +#define _APPLE2_FILETYPE_H + + + +/* Check for errors */ +#if !defined(__APPLE2__) +# error This module may only be used when compiling for the Apple ][! +#endif + + +/* ProDOS general file types */ +#define PRODOS_FILE_TYPE_UNK 0x00 /* Unknown */ +#define PRODOS_FILE_TYPE_BAD 0x01 /* Bad blocks */ +#define PRODOS_FILE_TYPE_PCD 0x02 /* Pascal code */ +#define PRODOS_FILE_TYPE_PTX 0x03 /* Pascal text */ +#define PRODOS_FILE_TYPE_TXT 0x04 /* ASCII text */ +#define PRODOS_FILE_TYPE_PDA 0x05 /* Pascal data */ +#define PRODOS_FILE_TYPE_BIN 0x06 /* Binary */ +#define PRODOS_FILE_TYPE_FNT 0x07 /* Apple III font */ +#define PRODOS_FILE_TYPE_FOT 0x08 /* Hi-res, dbl hi-res graphics */ +#define PRODOS_FILE_TYPE_BA3 0x09 /* Apple III BASIC program */ +#define PRODOS_FILE_TYPE_DA3 0x09 /* Apple III BASIC data */ +#define PRODOS_FILE_TYPE_WPF 0x0A /* Generic word processing */ +#define PRODOS_FILE_TYPE_SOS 0x0B /* SOS system */ +#define PRODOS_FILE_TYPE_DIR 0x0F /* ProDOS directory */ + +/* ProDOS productivity file types */ +#define PRODOS_FILE_TYPE_RPD 0x10 /* RPS data */ +#define PRODOS_FILE_TYPE_RPI 0x11 /* RPS index */ +#define PRODOS_FILE_TYPE_AFD 0x12 /* AppleFile discard */ +#define PRODOS_FILE_TYPE_AFM 0x13 /* AppleFile model */ +#define PRODOS_FILE_TYPE_AFR 0x14 /* AppleFile report */ +#define PRODOS_FILE_TYPE_SCL 0x15 /* Screen library */ +#define PRODOS_FILE_TYPE_PFS 0x16 /* PFS document */ +#define PRODOS_FILE_TYPE_ADB 0x19 /* AppleWorks database */ +#define PRODOS_FILE_TYPE_AWP 0x1A /* AppleWorks word processing */ +#define PRODOS_FILE_TYPE_ASP 0x1B /* AppleWorks spreadsheet */ + +/* ProDOS code file types */ +#define PRODOS_FILE_TYPE_TDM 0x20 /* Desktop Manager */ +#define PRODOS_FILE_TYPE_IPS 0x21 /* Instant Pascal source */ +#define PRODOS_FILE_TYPE_UPV 0x22 /* USCD Pascal volume */ +#define PRODOS_FILE_TYPE_3SD 0x29 /* SOS directory */ +#define PRODOS_FILE_TYPE_8SC 0x2A /* Source code */ +#define PRODOS_FILE_TYPE_8OB 0x2B /* Object code */ +#define PRODOS_FILE_TYPE_8IC 0x2C /* Interpreted code */ +#define PRODOS_FILE_TYPE_8LD 0x2D /* Language data */ +#define PRODOS_FILE_TYPE_P8C 0x2E /* ProDOS 8 code module */ + +/* ProDOS miscellaneous file types */ +#define PRODOS_FILE_TYPE_OCR 0x41 /* Optical char recognition */ +#define PRODOS_FILE_TYPE_FTD 0x42 /* File type definitions */ + +/* ProDOS Apple IIgs general file types */ +#define PRODOS_FILE_TYPE_GWP 0x50 /* Apple IIgs word processing */ +#define PRODOS_FILE_TYPE_GSS 0x51 /* Apple IIgs spreadsheet */ +#define PRODOS_FILE_TYPE_GDB 0x52 /* Apple IIgs database */ +#define PRODOS_FILE_TYPE_DRW 0x53 /* Object oriented graphics */ +#define PRODOS_FILE_TYPE_GDP 0x54 /* Apple IIgs desktop publish */ +#define PRODOS_FILE_TYPE_HMD 0x55 /* HyperMedia */ +#define PRODOS_FILE_TYPE_EDU 0x56 /* Educational program data */ +#define PRODOS_FILE_TYPE_STN 0x57 /* Stationary */ +#define PRODOS_FILE_TYPE_HLP 0x58 /* Help */ +#define PRODOS_FILE_TYPE_COM 0x59 /* Communications */ +#define PRODOS_FILE_TYPE_CFG 0x5A /* Configuration */ +#define PRODOS_FILE_TYPE_ANM 0x5B /* Animation */ +#define PRODOS_FILE_TYPE_MUM 0x5C /* Multimedia */ +#define PRODOS_FILE_TYPE_ENT 0x5D /* Entertainment */ +#define PRODOS_FILE_TYPE_DVU 0x5E /* Development utility */ + +/* ProDOS PC Transporter file types */ +#define PRODOS_FILE_TYPE_PRE 0x60 /* PC pre-boot */ +#define PRODOS_FILE_TYPE_BIO 0x6B /* PC BIOS */ +#define PRODOS_FILE_TYPE_NCF 0x66 /* ProDOS File Nav command file */ +#define PRODOS_FILE_TYPE_DVR 0x6D /* PC driver */ +#define PRODOS_FILE_TYPE_PRE2 0x6E /* PC pre-boot */ +#define PRODOS_FILE_TYPE_HDV 0x6F /* PC hard disk image */ + +/* ProDOS Kreative Software file types */ +#define PRODOS_FILE_TYPE_SN2 0x70 /* Sabine's Notebook 2.0 */ +#define PRODOS_FILE_TYPE_KMT 0x71 +#define PRODOS_FILE_TYPE_DSR 0x72 +#define PRODOS_FILE_TYPE_BAN 0x73 +#define PRODOS_FILE_TYPE_CG7 0x74 +#define PRODOS_FILE_TYPE_TNJ 0x75 +#define PRODOS_FILE_TYPE_SA7 0x76 +#define PRODOS_FILE_TYPE_KES 0x77 +#define PRODOS_FILE_TYPE_JAP 0x78 +#define PRODOS_FILE_TYPE_CSL 0x79 +#define PRODOS_FILE_TYPE_TME 0x7A +#define PRODOS_FILE_TYPE_TLB 0x7B +#define PRODOS_FILE_TYPE_MR7 0x7C +#define PRODOS_FILE_TYPE_MLR 0x7D /* Mika City */ +#define PRODOS_FILE_TYPE_MMM 0x7E +#define PRODOS_FILE_TYPE_JCP 0x7F + +/* ProDOS GEOS file types */ +#define PRODOS_FILE_TYPE_GES 0x80 /* GEOS system file */ +#define PRODOS_FILE_TYPE_GEA 0x81 /* GEOS desk accessory */ +#define PRODOS_FILE_TYPE_GEO 0x82 /* GEOS application */ +#define PRODOS_FILE_TYPE_GED 0x83 /* GEOS document */ +#define PRODOS_FILE_TYPE_GEF 0x84 /* GEOS font */ +#define PRODOS_FILE_TYPE_GEP 0x85 /* GEOS printer driver */ +#define PRODOS_FILE_TYPE_GEI 0x86 /* GEOS input driver */ +#define PRODOS_FILE_TYPE_GEX 0x87 /* GEOS auxiliary driver */ +#define PRODOS_FILE_TYPE_GEV 0x89 /* GEOS swap file */ +#define PRODOS_FILE_TYPE_GEC 0x8B /* GEOS clock driver */ +#define PRODOS_FILE_TYPE_GEK 0x8C /* GEOS interface card driver */ +#define PRODOS_FILE_TYPE_GEW 0x8D /* GEOS formatting data */ + +/* ProDOS Apple IIgs BASIC file types */ +#define PRODOS_FILE_TYPE_WP 0xA0 /* WordPerfect */ +#define PRODOS_FILE_TYPE_GSB 0xAB /* Apple IIgs BASIC program */ +#define PRODOS_FILE_TYPE_TDF 0xAB /* Apple IIgs BASIC TDF */ +#define PRODOS_FILE_TYPE_BDF 0xAB /* Apple IIgs BASIC data */ + +/* ProDOS Apple IIgs system file types */ +#define PRODOS_FILE_TYPE_SRC 0xB0 /* Apple IIgs source code */ +#define PRODOS_FILE_TYPE_OBJ 0xB1 /* Apple IIgs object code */ +#define PRODOS_FILE_TYPE_LIB 0xB2 /* Apple IIgs library */ +#define PRODOS_FILE_TYPE_S16 0xB3 /* Apple IIgs application pgm */ +#define PRODOS_FILE_TYPE_RTL 0xB4 /* Apple IIgs runtime library */ +#define PRODOS_FILE_TYPE_EXE 0xB5 /* Apple IIgs shell script */ +#define PRODOS_FILE_TYPE_PIF 0xB6 /* Apple IIgs permanent init */ +#define PRODOS_FILE_TYPE_TIF 0xB7 /* Apple IIgs temporary init */ +#define PRODOS_FILE_TYPE_NDA 0xB8 /* Apple IIgs new desk accesry */ +#define PRODOS_FILE_TYPE_CDA 0xB9 /* Apple IIgs classic desk aces */ +#define PRODOS_FILE_TYPE_TOL 0xBA /* Apple IIgs tool */ +#define PRODOS_FILE_TYPE_DRV 0xBB /* Apple IIgs device driver */ +#define PRODOS_FILE_TYPE_LDF 0xBC /* Apple IIgs generic load file */ +#define PRODOS_FILE_TYPE_FST 0xBD /* Apple IIgs file sys translat */ +#define PRODOS_FILE_TYPE_DOC 0xBF /* Apple IIgs document */ + +/* ProDOS graphics file types */ +#define PRODOS_FILE_TYPE_PNT 0xC0 /* Apple IIgs packed sup hi-res */ +#define PRODOS_FILE_TYPE_PIC 0xC1 /* Apple IIgs super hi-res */ +#define PRODOS_FILE_TYPE_ANI 0xC2 /* PaintWorks animation */ +#define PRODOS_FILE_TYPE_PAL 0xC3 /* PaintWorks palette */ +#define PRODOS_FILE_TYPE_OOG 0xC5 /* Object-oriented graphics */ +#define PRODOS_FILE_TYPE_SCR 0xC6 /* Script */ +#define PRODOS_FILE_TYPE_CDV 0xC7 /* Apple IIgs control panel */ +#define PRODOS_FILE_TYPE_FON 0xC8 /* Apple IIgs font */ +#define PRODOS_FILE_TYPE_FND 0xC9 /* Apple IIgs Finder data */ +#define PRODOS_FILE_TYPE_ICN 0xCA /* Apple IIgs icon */ + +/* ProDOS audio file types */ +#define PRODOS_FILE_TYPE_MUS 0xD5 /* Music */ +#define PRODOS_FILE_TYPE_INS 0xD6 /* Instrument */ +#define PRODOS_FILE_TYPE_MID 0xD7 /* MIDI */ +#define PRODOS_FILE_TYPE_SND 0xD8 /* Apple IIgs audio */ +#define PRODOS_FILE_TYPE_DBM 0xDB /* DB master document */ + +/* ProDOS miscellaneous file types */ +#define PRODOS_FILE_TYPE_LBR 0xE0 /* Archive */ +#define PRODOS_FILE_TYPE_ATK 0xE2 /* AppleTalk data */ +#define PRODOS_FILE_TYPE_R16 0xEE /* EDASM 816 relocatable code */ +#define PRODOS_FILE_TYPE_PAR 0xEF /* Pascal area */ + +/* ProDOS system file types */ +#define PRODOS_FILE_TYPE_CMD 0xF0 /* ProDOS command file */ +#define PRODOS_T_OVL 0xF1 /* User defined 1 */ +#define PRODOS_FILE_TYPE_UD2 0xF2 /* User defined 2 */ +#define PRODOS_FILE_TYPE_UD3 0xF3 /* User defined 3 */ +#define PRODOS_FILE_TYPE_UD4 0xF4 /* User defined 4 */ +#define PRODOS_FILE_TYPE_BAT 0xF5 /* User defined 5 */ +#define PRODOS_FILE_TYPE_UD6 0xF6 /* User defined 6 */ +#define PRODOS_FILE_TYPE_UD7 0xF7 /* User defined 7 */ +#define PRODOS_FILE_TYPE_PRG 0xF8 /* User defined 8 */ +#define PRODOS_FILE_TYPE_P16 0xF9 /* ProDOS-16 system file */ +#define PRODOS_FILE_TYPE_INT 0xFA /* Integer BASIC program */ +#define PRODOS_FILE_TYPE_IVR 0xFB /* Integer BASIC variables */ +#define PRODOS_FILE_TYPE_BAS 0xFC /* Applesoft BASIC program */ +#define PRODOS_FILE_TYPE_VAR 0xFD /* Applesoft BASIC variables */ +#define PRODOS_FILE_TYPE_REL 0xFE /* EDASM relocatable code */ +#define PRODOS_FILE_TYPE_SYS 0xFF /* ProDOS-8 system file */ + +/* The auxiliary type of a text file specifies its record length. +** A record length of 0 indicates a sequential text file, which is +** equivalent to text files of other operating systems like MacOS +** or Windows, except that lines are delimited by carriage returns +** only. An auxiliary type value greater than 0 for a text file, +** which is the record length, indicates a random access text file +** with fixed-length lines. +*/ +#define PRODOS_AUX_T_TXT_SEQ 0x0000 /* Sequential text */ + +/* 8IC auxiliary type */ +#define PRODOS_AUX_T_8IC_APEX_PGM 0x8003 /* Apex program */ + +/* GWP auxiliary types */ +#define PRODOS_AUX_T_GWP_TEACH 0x5445 /* Teach */ +#define PRODOS_AUX_T_GWP_DELUXEWRITE 0x8001 /* DeluxeWrite */ +#define PRODOS_AUX_T_GWP_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ + +/* GSS auxiliary type */ +#define PRODOS_AUX_T_GSS_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ + +/* GDB auxiliary types */ +#define PRODOS_GDB_AUX_TYPE_APLWRKSGS 0x8010 /* AppleWorks GS DB */ +#define PRODOS_GDB_AUX_TYPE_AWGS_TMPL 0x8011 /* AWGS template */ +#define PRODOS_GDB_AUX_TYPE_GSAS 0x8013 + +/* DRW auxiliary type */ +#define PRODOS_DRW_AUX_TYPE_APLWRKSGS 0x8013 /* AWGS O-O graphics */ + +/* GDP auxiliary types */ +#define PRODOS_GDP_AUX_TYPE_GRFCWRTR 0x8002 /* AWGS GraphicWriter */ +#define PRODOS_GDP_AUX_TYPE_APLWRKSGS 0x8010 /* AWGS */ + +/* HMD auxiliary types */ +#define PRODOS_HMD_AUX_TYPE_HYPRCRDGS 0x0001 /* HyperCard GS */ +#define PRODOS_HMD_AUX_TYPE_TUTORTECH 0x8001 /* Tutor-Tech */ +#define PRODOS_HMD_AUX_TYPE_HYPRSTDIO 0x8002 /* HyperStudio */ +#define PRODOS_HMD_AUX_TYPE_NEXUS 0x8003 /* Nexus */ + +/* COM auxiliary type */ +#define PRODOS_COM_AUX_TYPE_APLWRKSGS 0x8003 /* AppleWorks GS */ + +/* End of apple2_filetypes.h */ +#endif From e64e11d2c5e43962967b6bc9664fd67e113c38fd Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Thu, 27 Jul 2017 14:44:02 -0400 Subject: [PATCH 395/407] Finished adding all types and comments --- include/apple2_filetype.h | 372 ++++++++++++++++++++++---------------- 1 file changed, 213 insertions(+), 159 deletions(-) diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h index 51e7d3e51..96cf49581 100644 --- a/include/apple2_filetype.h +++ b/include/apple2_filetype.h @@ -42,171 +42,178 @@ #endif + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + /* ProDOS general file types */ -#define PRODOS_FILE_TYPE_UNK 0x00 /* Unknown */ -#define PRODOS_FILE_TYPE_BAD 0x01 /* Bad blocks */ -#define PRODOS_FILE_TYPE_PCD 0x02 /* Pascal code */ -#define PRODOS_FILE_TYPE_PTX 0x03 /* Pascal text */ -#define PRODOS_FILE_TYPE_TXT 0x04 /* ASCII text */ -#define PRODOS_FILE_TYPE_PDA 0x05 /* Pascal data */ -#define PRODOS_FILE_TYPE_BIN 0x06 /* Binary */ -#define PRODOS_FILE_TYPE_FNT 0x07 /* Apple III font */ -#define PRODOS_FILE_TYPE_FOT 0x08 /* Hi-res, dbl hi-res graphics */ -#define PRODOS_FILE_TYPE_BA3 0x09 /* Apple III BASIC program */ -#define PRODOS_FILE_TYPE_DA3 0x09 /* Apple III BASIC data */ -#define PRODOS_FILE_TYPE_WPF 0x0A /* Generic word processing */ -#define PRODOS_FILE_TYPE_SOS 0x0B /* SOS system */ -#define PRODOS_FILE_TYPE_DIR 0x0F /* ProDOS directory */ +#define PRODOS_T_UNK 0x00 /* Unknown */ +#define PRODOS_T_BAD 0x01 /* Bad blocks */ +#define PRODOS_T_PCD 0x02 /* Pascal code */ +#define PRODOS_T_PTX 0x03 /* Pascal text */ +#define PRODOS_T_TXT 0x04 /* ASCII text */ +#define PRODOS_T_PDA 0x05 /* Pascal data */ +#define PRODOS_T_BIN 0x06 /* Binary */ +#define PRODOS_T_FNT 0x07 /* Apple III font */ +#define PRODOS_T_FOT 0x08 /* Hi-res, dbl hi-res graphics */ +#define PRODOS_T_BA3 0x09 /* Apple III BASIC program */ +#define PRODOS_T_DA3 0x09 /* Apple III BASIC data */ +#define PRODOS_T_WPF 0x0A /* Generic word processing */ +#define PRODOS_T_SOS 0x0B /* SOS system */ +#define PRODOS_T_DIR 0x0F /* ProDOS directory */ /* ProDOS productivity file types */ -#define PRODOS_FILE_TYPE_RPD 0x10 /* RPS data */ -#define PRODOS_FILE_TYPE_RPI 0x11 /* RPS index */ -#define PRODOS_FILE_TYPE_AFD 0x12 /* AppleFile discard */ -#define PRODOS_FILE_TYPE_AFM 0x13 /* AppleFile model */ -#define PRODOS_FILE_TYPE_AFR 0x14 /* AppleFile report */ -#define PRODOS_FILE_TYPE_SCL 0x15 /* Screen library */ -#define PRODOS_FILE_TYPE_PFS 0x16 /* PFS document */ -#define PRODOS_FILE_TYPE_ADB 0x19 /* AppleWorks database */ -#define PRODOS_FILE_TYPE_AWP 0x1A /* AppleWorks word processing */ -#define PRODOS_FILE_TYPE_ASP 0x1B /* AppleWorks spreadsheet */ +#define PRODOS_T_RPD 0x10 /* RPS data */ +#define PRODOS_T_RPI 0x11 /* RPS index */ +#define PRODOS_T_AFD 0x12 /* AppleFile discard */ +#define PRODOS_T_AFM 0x13 /* AppleFile model */ +#define PRODOS_T_AFR 0x14 /* AppleFile report */ +#define PRODOS_T_SCL 0x15 /* Screen library */ +#define PRODOS_T_PFS 0x16 /* PFS document */ +#define PRODOS_T_ADB 0x19 /* AppleWorks database */ +#define PRODOS_T_AWP 0x1A /* AppleWorks word processing */ +#define PRODOS_T_ASP 0x1B /* AppleWorks spreadsheet */ /* ProDOS code file types */ -#define PRODOS_FILE_TYPE_TDM 0x20 /* Desktop Manager */ -#define PRODOS_FILE_TYPE_IPS 0x21 /* Instant Pascal source */ -#define PRODOS_FILE_TYPE_UPV 0x22 /* USCD Pascal volume */ -#define PRODOS_FILE_TYPE_3SD 0x29 /* SOS directory */ -#define PRODOS_FILE_TYPE_8SC 0x2A /* Source code */ -#define PRODOS_FILE_TYPE_8OB 0x2B /* Object code */ -#define PRODOS_FILE_TYPE_8IC 0x2C /* Interpreted code */ -#define PRODOS_FILE_TYPE_8LD 0x2D /* Language data */ -#define PRODOS_FILE_TYPE_P8C 0x2E /* ProDOS 8 code module */ +#define PRODOS_T_TDM 0x20 /* Desktop Manager */ +#define PRODOS_T_IPS 0x21 /* Instant Pascal source */ +#define PRODOS_T_UPV 0x22 /* USCD Pascal volume */ +#define PRODOS_T_3SD 0x29 /* SOS directory */ +#define PRODOS_T_8SC 0x2A /* Source code */ +#define PRODOS_T_8OB 0x2B /* Object code */ +#define PRODOS_T_8IC 0x2C /* Interpreted code */ +#define PRODOS_T_8LD 0x2D /* Language data */ +#define PRODOS_T_P8C 0x2E /* ProDOS 8 code module */ /* ProDOS miscellaneous file types */ -#define PRODOS_FILE_TYPE_OCR 0x41 /* Optical char recognition */ -#define PRODOS_FILE_TYPE_FTD 0x42 /* File type definitions */ +#define PRODOS_T_OCR 0x41 /* Optical char recognition */ +#define PRODOS_T_FTD 0x42 /* File type definitions */ /* ProDOS Apple IIgs general file types */ -#define PRODOS_FILE_TYPE_GWP 0x50 /* Apple IIgs word processing */ -#define PRODOS_FILE_TYPE_GSS 0x51 /* Apple IIgs spreadsheet */ -#define PRODOS_FILE_TYPE_GDB 0x52 /* Apple IIgs database */ -#define PRODOS_FILE_TYPE_DRW 0x53 /* Object oriented graphics */ -#define PRODOS_FILE_TYPE_GDP 0x54 /* Apple IIgs desktop publish */ -#define PRODOS_FILE_TYPE_HMD 0x55 /* HyperMedia */ -#define PRODOS_FILE_TYPE_EDU 0x56 /* Educational program data */ -#define PRODOS_FILE_TYPE_STN 0x57 /* Stationary */ -#define PRODOS_FILE_TYPE_HLP 0x58 /* Help */ -#define PRODOS_FILE_TYPE_COM 0x59 /* Communications */ -#define PRODOS_FILE_TYPE_CFG 0x5A /* Configuration */ -#define PRODOS_FILE_TYPE_ANM 0x5B /* Animation */ -#define PRODOS_FILE_TYPE_MUM 0x5C /* Multimedia */ -#define PRODOS_FILE_TYPE_ENT 0x5D /* Entertainment */ -#define PRODOS_FILE_TYPE_DVU 0x5E /* Development utility */ +#define PRODOS_T_GWP 0x50 /* Apple IIgs word processing */ +#define PRODOS_T_GSS 0x51 /* Apple IIgs spreadsheet */ +#define PRODOS_T_GDB 0x52 /* Apple IIgs database */ +#define PRODOS_T_DRW 0x53 /* Object oriented graphics */ +#define PRODOS_T_GDP 0x54 /* Apple IIgs desktop publish */ +#define PRODOS_T_HMD 0x55 /* HyperMedia */ +#define PRODOS_T_EDU 0x56 /* Educational program data */ +#define PRODOS_T_STN 0x57 /* Stationary */ +#define PRODOS_T_HLP 0x58 /* Help */ +#define PRODOS_T_COM 0x59 /* Communications */ +#define PRODOS_T_CFG 0x5A /* Configuration */ +#define PRODOS_T_ANM 0x5B /* Animation */ +#define PRODOS_T_MUM 0x5C /* Multimedia */ +#define PRODOS_T_ENT 0x5D /* Entertainment */ +#define PRODOS_T_DVU 0x5E /* Development utility */ /* ProDOS PC Transporter file types */ -#define PRODOS_FILE_TYPE_PRE 0x60 /* PC pre-boot */ -#define PRODOS_FILE_TYPE_BIO 0x6B /* PC BIOS */ -#define PRODOS_FILE_TYPE_NCF 0x66 /* ProDOS File Nav command file */ -#define PRODOS_FILE_TYPE_DVR 0x6D /* PC driver */ -#define PRODOS_FILE_TYPE_PRE2 0x6E /* PC pre-boot */ -#define PRODOS_FILE_TYPE_HDV 0x6F /* PC hard disk image */ +#define PRODOS_T_PRE 0x60 /* PC pre-boot */ +#define PRODOS_T_BIO 0x6B /* PC BIOS */ +#define PRODOS_T_NCF 0x66 /* ProDOS File Nav command file */ +#define PRODOS_T_DVR 0x6D /* PC driver */ +#define PRODOS_T_PRE2 0x6E /* PC pre-boot */ +#define PRODOS_T_HDV 0x6F /* PC hard disk image */ /* ProDOS Kreative Software file types */ -#define PRODOS_FILE_TYPE_SN2 0x70 /* Sabine's Notebook 2.0 */ -#define PRODOS_FILE_TYPE_KMT 0x71 -#define PRODOS_FILE_TYPE_DSR 0x72 -#define PRODOS_FILE_TYPE_BAN 0x73 -#define PRODOS_FILE_TYPE_CG7 0x74 -#define PRODOS_FILE_TYPE_TNJ 0x75 -#define PRODOS_FILE_TYPE_SA7 0x76 -#define PRODOS_FILE_TYPE_KES 0x77 -#define PRODOS_FILE_TYPE_JAP 0x78 -#define PRODOS_FILE_TYPE_CSL 0x79 -#define PRODOS_FILE_TYPE_TME 0x7A -#define PRODOS_FILE_TYPE_TLB 0x7B -#define PRODOS_FILE_TYPE_MR7 0x7C -#define PRODOS_FILE_TYPE_MLR 0x7D /* Mika City */ -#define PRODOS_FILE_TYPE_MMM 0x7E -#define PRODOS_FILE_TYPE_JCP 0x7F +#define PRODOS_T_SN2 0x70 /* Sabine's Notebook 2.0 */ +#define PRODOS_T_KMT 0x71 +#define PRODOS_T_DSR 0x72 +#define PRODOS_T_BAN 0x73 +#define PRODOS_T_CG7 0x74 +#define PRODOS_T_TNJ 0x75 +#define PRODOS_T_SA7 0x76 +#define PRODOS_T_KES 0x77 +#define PRODOS_T_JAP 0x78 +#define PRODOS_T_CSL 0x79 +#define PRODOS_T_TME 0x7A +#define PRODOS_T_TLB 0x7B +#define PRODOS_T_MR7 0x7C +#define PRODOS_T_MLR 0x7D /* Mika City */ +#define PRODOS_T_MMM 0x7E +#define PRODOS_T_JCP 0x7F /* ProDOS GEOS file types */ -#define PRODOS_FILE_TYPE_GES 0x80 /* GEOS system file */ -#define PRODOS_FILE_TYPE_GEA 0x81 /* GEOS desk accessory */ -#define PRODOS_FILE_TYPE_GEO 0x82 /* GEOS application */ -#define PRODOS_FILE_TYPE_GED 0x83 /* GEOS document */ -#define PRODOS_FILE_TYPE_GEF 0x84 /* GEOS font */ -#define PRODOS_FILE_TYPE_GEP 0x85 /* GEOS printer driver */ -#define PRODOS_FILE_TYPE_GEI 0x86 /* GEOS input driver */ -#define PRODOS_FILE_TYPE_GEX 0x87 /* GEOS auxiliary driver */ -#define PRODOS_FILE_TYPE_GEV 0x89 /* GEOS swap file */ -#define PRODOS_FILE_TYPE_GEC 0x8B /* GEOS clock driver */ -#define PRODOS_FILE_TYPE_GEK 0x8C /* GEOS interface card driver */ -#define PRODOS_FILE_TYPE_GEW 0x8D /* GEOS formatting data */ +#define PRODOS_T_GES 0x80 /* GEOS system file */ +#define PRODOS_T_GEA 0x81 /* GEOS desk accessory */ +#define PRODOS_T_GEO 0x82 /* GEOS application */ +#define PRODOS_T_GED 0x83 /* GEOS document */ +#define PRODOS_T_GEF 0x84 /* GEOS font */ +#define PRODOS_T_GEP 0x85 /* GEOS printer driver */ +#define PRODOS_T_GEI 0x86 /* GEOS input driver */ +#define PRODOS_T_GEX 0x87 /* GEOS auxiliary driver */ +#define PRODOS_T_GEV 0x89 /* GEOS swap file */ +#define PRODOS_T_GEC 0x8B /* GEOS clock driver */ +#define PRODOS_T_GEK 0x8C /* GEOS interface card driver */ +#define PRODOS_T_GEW 0x8D /* GEOS formatting data */ /* ProDOS Apple IIgs BASIC file types */ -#define PRODOS_FILE_TYPE_WP 0xA0 /* WordPerfect */ -#define PRODOS_FILE_TYPE_GSB 0xAB /* Apple IIgs BASIC program */ -#define PRODOS_FILE_TYPE_TDF 0xAB /* Apple IIgs BASIC TDF */ -#define PRODOS_FILE_TYPE_BDF 0xAB /* Apple IIgs BASIC data */ +#define PRODOS_T_WP 0xA0 /* WordPerfect */ +#define PRODOS_T_GSB 0xAB /* Apple IIgs BASIC program */ +#define PRODOS_T_TDF 0xAB /* Apple IIgs BASIC TDF */ +#define PRODOS_T_BDF 0xAB /* Apple IIgs BASIC data */ /* ProDOS Apple IIgs system file types */ -#define PRODOS_FILE_TYPE_SRC 0xB0 /* Apple IIgs source code */ -#define PRODOS_FILE_TYPE_OBJ 0xB1 /* Apple IIgs object code */ -#define PRODOS_FILE_TYPE_LIB 0xB2 /* Apple IIgs library */ -#define PRODOS_FILE_TYPE_S16 0xB3 /* Apple IIgs application pgm */ -#define PRODOS_FILE_TYPE_RTL 0xB4 /* Apple IIgs runtime library */ -#define PRODOS_FILE_TYPE_EXE 0xB5 /* Apple IIgs shell script */ -#define PRODOS_FILE_TYPE_PIF 0xB6 /* Apple IIgs permanent init */ -#define PRODOS_FILE_TYPE_TIF 0xB7 /* Apple IIgs temporary init */ -#define PRODOS_FILE_TYPE_NDA 0xB8 /* Apple IIgs new desk accesry */ -#define PRODOS_FILE_TYPE_CDA 0xB9 /* Apple IIgs classic desk aces */ -#define PRODOS_FILE_TYPE_TOL 0xBA /* Apple IIgs tool */ -#define PRODOS_FILE_TYPE_DRV 0xBB /* Apple IIgs device driver */ -#define PRODOS_FILE_TYPE_LDF 0xBC /* Apple IIgs generic load file */ -#define PRODOS_FILE_TYPE_FST 0xBD /* Apple IIgs file sys translat */ -#define PRODOS_FILE_TYPE_DOC 0xBF /* Apple IIgs document */ +#define PRODOS_T_SRC 0xB0 /* Apple IIgs source code */ +#define PRODOS_T_OBJ 0xB1 /* Apple IIgs object code */ +#define PRODOS_T_LIB 0xB2 /* Apple IIgs library */ +#define PRODOS_T_S16 0xB3 /* Apple IIgs application pgm */ +#define PRODOS_T_RTL 0xB4 /* Apple IIgs runtime library */ +#define PRODOS_T_EXE 0xB5 /* Apple IIgs shell script */ +#define PRODOS_T_PIF 0xB6 /* Apple IIgs permanent init */ +#define PRODOS_T_TIF 0xB7 /* Apple IIgs temporary init */ +#define PRODOS_T_NDA 0xB8 /* Apple IIgs new desk accesry */ +#define PRODOS_T_CDA 0xB9 /* Apple IIgs classic desk aces */ +#define PRODOS_T_TOL 0xBA /* Apple IIgs tool */ +#define PRODOS_T_DRV 0xBB /* Apple IIgs device driver */ +#define PRODOS_T_LDF 0xBC /* Apple IIgs generic load file */ +#define PRODOS_T_FST 0xBD /* Apple IIgs file sys translat */ +#define PRODOS_T_DOC 0xBF /* Apple IIgs document */ /* ProDOS graphics file types */ -#define PRODOS_FILE_TYPE_PNT 0xC0 /* Apple IIgs packed sup hi-res */ -#define PRODOS_FILE_TYPE_PIC 0xC1 /* Apple IIgs super hi-res */ -#define PRODOS_FILE_TYPE_ANI 0xC2 /* PaintWorks animation */ -#define PRODOS_FILE_TYPE_PAL 0xC3 /* PaintWorks palette */ -#define PRODOS_FILE_TYPE_OOG 0xC5 /* Object-oriented graphics */ -#define PRODOS_FILE_TYPE_SCR 0xC6 /* Script */ -#define PRODOS_FILE_TYPE_CDV 0xC7 /* Apple IIgs control panel */ -#define PRODOS_FILE_TYPE_FON 0xC8 /* Apple IIgs font */ -#define PRODOS_FILE_TYPE_FND 0xC9 /* Apple IIgs Finder data */ -#define PRODOS_FILE_TYPE_ICN 0xCA /* Apple IIgs icon */ +#define PRODOS_T_PNT 0xC0 /* Apple IIgs packed sup hi-res */ +#define PRODOS_T_PIC 0xC1 /* Apple IIgs super hi-res */ +#define PRODOS_T_ANI 0xC2 /* PaintWorks animation */ +#define PRODOS_T_PAL 0xC3 /* PaintWorks palette */ +#define PRODOS_T_OOG 0xC5 /* Object-oriented graphics */ +#define PRODOS_T_SCR 0xC6 /* Script */ +#define PRODOS_T_CDV 0xC7 /* Apple IIgs control panel */ +#define PRODOS_T_FON 0xC8 /* Apple IIgs font */ +#define PRODOS_T_FND 0xC9 /* Apple IIgs Finder data */ +#define PRODOS_T_ICN 0xCA /* Apple IIgs icon */ /* ProDOS audio file types */ -#define PRODOS_FILE_TYPE_MUS 0xD5 /* Music */ -#define PRODOS_FILE_TYPE_INS 0xD6 /* Instrument */ -#define PRODOS_FILE_TYPE_MID 0xD7 /* MIDI */ -#define PRODOS_FILE_TYPE_SND 0xD8 /* Apple IIgs audio */ -#define PRODOS_FILE_TYPE_DBM 0xDB /* DB master document */ +#define PRODOS_T_MUS 0xD5 /* Music */ +#define PRODOS_T_INS 0xD6 /* Instrument */ +#define PRODOS_T_MID 0xD7 /* MIDI */ +#define PRODOS_T_SND 0xD8 /* Apple IIgs audio */ +#define PRODOS_T_DBM 0xDB /* DB master document */ /* ProDOS miscellaneous file types */ -#define PRODOS_FILE_TYPE_LBR 0xE0 /* Archive */ -#define PRODOS_FILE_TYPE_ATK 0xE2 /* AppleTalk data */ -#define PRODOS_FILE_TYPE_R16 0xEE /* EDASM 816 relocatable code */ -#define PRODOS_FILE_TYPE_PAR 0xEF /* Pascal area */ +#define PRODOS_T_LBR 0xE0 /* Archive */ +#define PRODOS_T_ATK 0xE2 /* AppleTalk data */ +#define PRODOS_T_R16 0xEE /* EDASM 816 relocatable code */ +#define PRODOS_T_PAR 0xEF /* Pascal area */ /* ProDOS system file types */ -#define PRODOS_FILE_TYPE_CMD 0xF0 /* ProDOS command file */ +#define PRODOS_T_CMD 0xF0 /* ProDOS command file */ #define PRODOS_T_OVL 0xF1 /* User defined 1 */ -#define PRODOS_FILE_TYPE_UD2 0xF2 /* User defined 2 */ -#define PRODOS_FILE_TYPE_UD3 0xF3 /* User defined 3 */ -#define PRODOS_FILE_TYPE_UD4 0xF4 /* User defined 4 */ -#define PRODOS_FILE_TYPE_BAT 0xF5 /* User defined 5 */ -#define PRODOS_FILE_TYPE_UD6 0xF6 /* User defined 6 */ -#define PRODOS_FILE_TYPE_UD7 0xF7 /* User defined 7 */ -#define PRODOS_FILE_TYPE_PRG 0xF8 /* User defined 8 */ -#define PRODOS_FILE_TYPE_P16 0xF9 /* ProDOS-16 system file */ -#define PRODOS_FILE_TYPE_INT 0xFA /* Integer BASIC program */ -#define PRODOS_FILE_TYPE_IVR 0xFB /* Integer BASIC variables */ -#define PRODOS_FILE_TYPE_BAS 0xFC /* Applesoft BASIC program */ -#define PRODOS_FILE_TYPE_VAR 0xFD /* Applesoft BASIC variables */ -#define PRODOS_FILE_TYPE_REL 0xFE /* EDASM relocatable code */ -#define PRODOS_FILE_TYPE_SYS 0xFF /* ProDOS-8 system file */ +#define PRODOS_T_UD2 0xF2 /* User defined 2 */ +#define PRODOS_T_UD3 0xF3 /* User defined 3 */ +#define PRODOS_T_UD4 0xF4 /* User defined 4 */ +#define PRODOS_T_BAT 0xF5 /* User defined 5 */ +#define PRODOS_T_UD6 0xF6 /* User defined 6 */ +#define PRODOS_T_UD7 0xF7 /* User defined 7 */ +#define PRODOS_T_PRG 0xF8 /* User defined 8 */ +#define PRODOS_T_P16 0xF9 /* ProDOS-16 system file */ +#define PRODOS_T_INT 0xFA /* Integer BASIC program */ +#define PRODOS_T_IVR 0xFB /* Integer BASIC variables */ +#define PRODOS_T_BAS 0xFC /* Applesoft BASIC program */ +#define PRODOS_T_VAR 0xFD /* Applesoft BASIC variables */ +#define PRODOS_T_REL 0xFE /* EDASM relocatable code */ +#define PRODOS_T_SYS 0xFF /* ProDOS-8 system file */ /* The auxiliary type of a text file specifies its record length. ** A record length of 0 indicates a sequential text file, which is @@ -216,39 +223,86 @@ ** which is the record length, indicates a random access text file ** with fixed-length lines. */ -#define PRODOS_AUX_T_TXT_SEQ 0x0000 /* Sequential text */ +#define PRODOS_AUX_T_TXT_SEQ 0x0000 /* Sequential text */ -/* 8IC auxiliary type */ -#define PRODOS_AUX_T_8IC_APEX_PGM 0x8003 /* Apex program */ +/* 8IC auxiliary types */ +#define PRODOS_AUX_T_8IC_APEX_PGM 0x8003 /* Apex program */ /* GWP auxiliary types */ -#define PRODOS_AUX_T_GWP_TEACH 0x5445 /* Teach */ -#define PRODOS_AUX_T_GWP_DELUXEWRITE 0x8001 /* DeluxeWrite */ -#define PRODOS_AUX_T_GWP_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ +#define PRODOS_AUX_T_GWP_TEACH 0x5445 /* Teach */ +#define PRODOS_AUX_T_GWP_DELUXEWRITE 0x8001 /* DeluxeWrite */ +#define PRODOS_AUX_T_GWP_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ -/* GSS auxiliary type */ -#define PRODOS_AUX_T_GSS_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ +/* GSS auxiliary types */ +#define PRODOS_AUX_T_GSS_APPLEWORKS_GS 0x8010 /* AppleWorks GS */ /* GDB auxiliary types */ -#define PRODOS_GDB_AUX_TYPE_APLWRKSGS 0x8010 /* AppleWorks GS DB */ -#define PRODOS_GDB_AUX_TYPE_AWGS_TMPL 0x8011 /* AWGS template */ -#define PRODOS_GDB_AUX_TYPE_GSAS 0x8013 +#define PRODOS_AUX_T_GDB_APPLEWORKS_GS 0x8010 /* AppleWorks GS DB */ +#define PRODOS_AUX_T_GDB_AWGS_TMPL 0x8011 /* AWGS template */ +#define PRODOS_AUX_T_GDB_GSAS 0x8013 -/* DRW auxiliary type */ -#define PRODOS_DRW_AUX_TYPE_APLWRKSGS 0x8013 /* AWGS O-O graphics */ +/* DRW auxiliary types */ +#define PRODOS_AUX_T_DRW_OO_GRAPHICS 0x8013 /* AWGS O-O graphics */ /* GDP auxiliary types */ -#define PRODOS_GDP_AUX_TYPE_GRFCWRTR 0x8002 /* AWGS GraphicWriter */ -#define PRODOS_GDP_AUX_TYPE_APLWRKSGS 0x8010 /* AWGS */ +#define PRODOS_AUX_T_GDP_GRAPHICWRITER 0x8002 /* A2gs GraphicWriter */ +#define PRODOS_AUX_T_GDP_APPLEWORKS_GS 0x8010 /* A2gs AWGS */ /* HMD auxiliary types */ -#define PRODOS_HMD_AUX_TYPE_HYPRCRDGS 0x0001 /* HyperCard GS */ -#define PRODOS_HMD_AUX_TYPE_TUTORTECH 0x8001 /* Tutor-Tech */ -#define PRODOS_HMD_AUX_TYPE_HYPRSTDIO 0x8002 /* HyperStudio */ -#define PRODOS_HMD_AUX_TYPE_NEXUS 0x8003 /* Nexus */ +#define PRODOS_AUX_T_HMD_HYPERCARD_GS 0x0001 /* HyperCard GS */ +#define PRODOS_AUX_T_HMD_TUTOR_TECH 0x8001 /* Tutor-Tech */ +#define PRODOS_AUX_T_HMD_HYPERSTUDIO 0x8002 /* HyperStudio */ +#define PRODOS_AUX_T_HMD_NEXUS 0x8003 /* Nexus */ -/* COM auxiliary type */ -#define PRODOS_COM_AUX_TYPE_APLWRKSGS 0x8003 /* AppleWorks GS */ +/* COM auxiliary types */ +#define PRODOS_AUX_T_COM_APPLEWORKS_GS 0x8003 /* AppleWorks GS */ -/* End of apple2_filetypes.h */ +/* MLR auxiliary types */ +#define PRODOS_AUX_T_MLR_SCRIPT 0x005C /* Mika City script */ +#define PRODOS_AUX_T_MLR_COLOR_TABLE 0xC7AB /* Mika City color table */ +#define PRODOS_AUX_T_MLR_CHARACTER_DEF 0xCDEF /* Mika City character def */ + +/* LDF auxiliary types */ +#define PRODOS_AUX_T_LDF_NIFTY_LIST_MOD 0x4001 /* Nifty list module */ +#define PRODOS_AUX_T_LDF_SUPER_INFO_MOD 0x4002 /* Super info module */ +#define PRODOS_AUX_T_LDF_TWILIGHT_MOD 0x4004 /* Twilight module */ +#define PRODOS_AUX_T_LDF_MARINETTI_LLM 0x4004 /* Marinetti link layer mod */ + +/* PNT auxiliary types */ +#define PRODOS_AUX_T_PNT_PK_SUPER_HIRES 0x0001 /* Packed super hi-res */ +#define PRODOS_AUX_T_PNT_APPLE_PREF 0x0002 /* Apple preferred format */ +#define PRODOS_AUX_T_PNT_PK_QUICKDRAWII 0x0003 /* Packed QuickDraw II */ + +/* PIC auxiliary types */ +#define PRODOS_AUX_T_PIC_QUICKDRAW 0x0001 /* QuickDraw image */ +#define PRODOS_AUX_T_PIC_SHIRES_3200 0x0002 /* Super hi-res 3200 */ + +/* FON auxiliary types */ +#define PRODOS_AUX_T_FON_QUICKDRAW_BIT 0x0000 /* QuickDraw bitmap font */ +#define PRODOS_AUX_T_FON_POINTLESS_TT 0x0001 /* Pointless TrueType font */ + +/* SND auxiliary types */ +#define PRODOS_AUX_T_SND_AIFF 0x0000 /* AIFF */ +#define PRODOS_AUX_T_SND_AIFF_C 0x0001 /* AIFF-C */ +#define PRODOS_AUX_T_SND_ASIF_INSTR 0x0002 /* ASIF instrument */ +#define PRODOS_AUX_T_SND_SOUND_RSRC 0x0003 /* Sound resource */ +#define PRODOS_AUX_T_SND_MIDI_SYNTH_WAV 0x0004 /* MIDI synth wave */ +#define PRODOS_AUX_T_SND_HYPERSTUDIO 0x8001 /* HyperStudio sound */ + +/* LBR auxiliary types */ +#define PRODOS_AUX_T_LBR_ALU 0x0000 /* ALU */ +#define PRODOS_AUX_T_LBR_APPLE_SINGLE 0x0001 /* AppleSingle */ +#define PRODOS_AUX_T_LBR_APPLEDBL_HDR 0x0002 /* AppleDouble header */ +#define PRODOS_AUX_T_LBR_APPLEDBL_DATA 0x0003 /* AppleDouble data */ +#define PRODOS_AUX_T_LBR_BINARY_II 0x8000 /* Binary II */ +#define PRODOS_AUX_T_LBR_APPLELINK_ACU 0x8001 /* AppleLink ACU */ +#define PRODOS_AUX_T_LBR_SHRINKIT 0x8002 /* ShrinkIt */ + +/* LBR auxiliary types */ +#define PRODOS_AUX_T_ATK_EASYMNT_ALIAS 0x0000 /* EasyMount alias */ + +/* BAS auxiliary types */ +#define PRODOS_AUX_T_BAS_PGM_LOAD_ADDR 0x0801 /* Applesoft pgm load addr */ + +/* End of apple2_filetype.h */ #endif From 91d06596635980e3ba4110faa702b1972e9b0f81 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 11:29:11 -0400 Subject: [PATCH 396/407] Rolled back changes to exclude vim swap files Only files generated by the tools in the project are to be ignored --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 39d5b59fa..ad4d26c3f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,3 @@ /testwrk/ /wrk/ /cc65.zip - -# Vim swap files -.*.swp From 9459f11688542104c2dbb4d32d9b6e0ec59ecc25 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 12:01:57 -0400 Subject: [PATCH 397/407] Corrected copyright and moved file type globals The file type globals., _filetype and _auxtype, were moved from apple2.h to this file. --- include/apple2_filetype.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h index 96cf49581..bdfa93093 100644 --- a/include/apple2_filetype.h +++ b/include/apple2_filetype.h @@ -6,8 +6,7 @@ /* */ /* */ /* */ -/* (C) 2000 Kevin Ruland, <kevin@rodin.wustl.edu> */ -/* (C) 2003 Ullrich von Bassewitz, <uz@cc65.org> */ +/* (C) 2017 Bill Chatfield, <bill_chatfield@yahoo.com> */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -304,5 +303,12 @@ /* BAS auxiliary types */ #define PRODOS_AUX_T_BAS_PGM_LOAD_ADDR 0x0801 /* Applesoft pgm load addr */ +/* The file stream implementation and the POSIX I/O functions will use the +** following variables to determine the file type and auxiliary type to use. +** This applies specifically to the fopen and open functions. +*/ +extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ +extern unsigned int _auxtype; /* Default: 0 */ + /* End of apple2_filetype.h */ #endif From abb2e8034b4ead55364f75938ae894826339f54e Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 12:09:58 -0400 Subject: [PATCH 398/407] Moved file type variables to apple2_filetype.h --- include/apple2.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/apple2.h b/include/apple2.h index a2150c173..e73023693 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -137,11 +137,9 @@ extern unsigned char _dos_type; /* The file stream implementation and the POSIX I/O functions will use the -** following variables to determine the file type, aux type and creation time -** stamp to use. +** following struct to set the date and time stamp on files. This specificially +** applies to the open and fopen functions. */ -extern unsigned char _filetype; /* Default: 6 */ -extern unsigned int _auxtype; /* Default: 0 */ extern struct { struct { unsigned day :5; From f40bb936777ecc223723b6f502e9a94eccd09541 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 12:12:18 -0400 Subject: [PATCH 399/407] Added Variables section comment per convention --- include/apple2_filetype.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h index bdfa93093..be17274fa 100644 --- a/include/apple2_filetype.h +++ b/include/apple2_filetype.h @@ -303,6 +303,14 @@ /* BAS auxiliary types */ #define PRODOS_AUX_T_BAS_PGM_LOAD_ADDR 0x0801 /* Applesoft pgm load addr */ + + +/*****************************************************************************/ +/* Variables */ +/*****************************************************************************/ + + + /* The file stream implementation and the POSIX I/O functions will use the ** following variables to determine the file type and auxiliary type to use. ** This applies specifically to the fopen and open functions. From 80c1c94a87aca1b0b7a4b0521d140493d20ba4b0 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 12:16:55 -0400 Subject: [PATCH 400/407] Corrected comment formatting --- include/apple2_filetype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h index be17274fa..83a44f532 100644 --- a/include/apple2_filetype.h +++ b/include/apple2_filetype.h @@ -316,7 +316,7 @@ ** This applies specifically to the fopen and open functions. */ extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ -extern unsigned int _auxtype; /* Default: 0 */ +extern unsigned int _auxtype; /* Default: 0 */ /* End of apple2_filetype.h */ #endif From 375ee571c235250bebd3ea10af5830b38d870747 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Fri, 28 Jul 2017 19:19:11 +0200 Subject: [PATCH 401/407] Removed 'fire'. --- include/joystick.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/joystick.h b/include/joystick.h index f08dd432a..27c4af81a 100644 --- a/include/joystick.h +++ b/include/joystick.h @@ -61,9 +61,9 @@ #define JOY_LEFT_IDX 2 #define JOY_RIGHT_IDX 3 #define JOY_BTN_1_IDX 4 /* Universally available */ -#define JOY_BTN_2_IDX 5 /* Second fire button if available */ -#define JOY_BTN_3_IDX 6 /* Third fire button if available */ -#define JOY_BTN_4_IDX 7 /* Fourth fire button if available */ +#define JOY_BTN_2_IDX 5 /* Second button if available */ +#define JOY_BTN_3_IDX 6 /* Third button if available */ +#define JOY_BTN_4_IDX 7 /* Fourth button if available */ /* Array of masks used to check the return value of joy_read for a state */ extern const unsigned char joy_masks[8]; From 2c7b757b4caf152e26f9bb0bbb3fb0dba0b69f6c Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Fri, 28 Jul 2017 17:44:13 -0400 Subject: [PATCH 402/407] Documented _filetype and _auxtype --- doc/apple2.sgml | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 3089a04c4..fe5c98767 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -511,6 +511,104 @@ url="ca65.html" name="assembler manual">. </descrip><p> +<sect1>Specifying ProDOS File Types<p> + +<descrip> + + <tag>Problem Explanation</tag> + + ProDOS associates a file type and an auxiliary type with each file. + These type specifications are separate from the file's name, unlike + Windows and UNIX-like systems which use the file name's suffix (a.k.a. + extension) to specify the file type. For example, .exe, .doc, or .bat. + The ProDOS low-level + Machine-Language Interface (MLI) functions for creating and opening + files require these types to be specified. And if they don't match + with the file being opened, the operation may fail. + + In contrast, the ISO C function <tt/fopen()/ and the POSIX function + <tt/open()/ have no parameter to specify either a file type or an + auxiliary type. Therefore, some additional mechanism for specifying + the file types is needed. + + <tag>Solution</tag> + + There are two global variables provided that allow the file type + and auxiliary type to be specified before a call to <tt/fopen()/ + or <tt/open/. They are defined in <tt/apple2_filetype.h/: + + <quote> + <verb> + extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ + extern unsigned int _auxtype; /* Default: 0 */ + </verb> + </quote> + + The header file <tt/apple2_filetype.h/ also defines many values + that can be used to set these variables. It is included in + <tt/apple2.h/, which is in turn included in <tt/apple2enh.h/. + So it + not necessary to include it directly. Just + include one of <tt/apple2.h/ or <tt/apple2enh.h/. + + <tag>Example</tag> + + A text file cannot be created with just the + standard C functions because they default to the binary type + <tt/PRODOS_T_BIN/. The <tt/_filetype/ variable must be set to + <tt/PRODOS_T_TXT/ to create a text file. + + For a text file, + <tt/_auxtype/ specifies the record length. A zero record + length text file is referred to as a sequential text file. + This is equivalent to text files on + other operating systems, except that the line terminator is a + carriage return instead of a new line (Linux/BSD/MacOS) or + carriage return, new line pair (Windows). + + The "sequential" text file terminology is in contrast to a + "random-access" text file which would + have a fixed-length, non-zero record length, so that the + file position of any individual record can be calculated. + + For this example, the + <tt/_auxtype/ does not need to be set because it defaults to + the desired value, which is zero. To be more explicit, + <tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/ + which is defined as zero. + + <quote> + <verb> + #include <stdio.h> + #include <string.h> + #include <errno.h> + #include <apple2.h> + void main() + { + FILE *out; + char *name = "MY.FAVS"; + + _filetype = PRODOS_T_TXT; + _auxtype = PRODOS_AUX_T_TXT_SEQ; + + if ((out = fopen(name, "w")) != NULL) { + fputs("Jorah Mormont\r", out); + fputs("Brienne of Tarth\r", out); + fputs("Daenerys Targaryen\r", out); + fputs("Sandor Clegane\r", out); + if (fclose(out) == EOF) { + fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno)); + } + } + else { + fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno)); + } + } + </verb> + </quote> + +</descrip><p> + <sect>License<p> From 9d89613bb2d5f8817cd38886acdb92fa1f5395c5 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Sat, 29 Jul 2017 01:25:07 -0400 Subject: [PATCH 403/407] Added documentation for setting the file type for fopen. --- doc/apple2.sgml | 27 ++++++++++++++++----------- doc/apple2enh.sgml | 8 ++++++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index fe5c98767..4ed2af48c 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -511,11 +511,11 @@ url="ca65.html" name="assembler manual">. </descrip><p> -<sect1>Specifying ProDOS File Types<p> +<sect1>Specifying file types for fopen<p> <descrip> - <tag>Problem Explanation</tag> + <tag>Explanation of File Types</tag> ProDOS associates a file type and an auxiliary type with each file. These type specifications are separate from the file's name, unlike @@ -531,18 +531,18 @@ url="ca65.html" name="assembler manual">. auxiliary type. Therefore, some additional mechanism for specifying the file types is needed. - <tag>Solution</tag> + <tag>Specifying the File Type and Auxiliary Type</tag> There are two global variables provided that allow the file type and auxiliary type to be specified before a call to <tt/fopen()/ or <tt/open/. They are defined in <tt/apple2_filetype.h/: - <quote> + <tscreen> <verb> extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ extern unsigned int _auxtype; /* Default: 0 */ </verb> - </quote> + </tscreen> The header file <tt/apple2_filetype.h/ also defines many values that can be used to set these variables. It is included in @@ -577,20 +577,25 @@ url="ca65.html" name="assembler manual">. <tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/ which is defined as zero. - <quote> + <tscreen> <verb> - #include <stdio.h> - #include <string.h> - #include <errno.h> - #include <apple2.h> + #include <stdio.h> + #include <string.h> + #include <errno.h> + #include <apple2.h> + void main() { FILE *out; char *name = "MY.FAVS"; + /*-----------------------------*/ + _filetype = PRODOS_T_TXT; _auxtype = PRODOS_AUX_T_TXT_SEQ; + /*-----------------------------*/ + if ((out = fopen(name, "w")) != NULL) { fputs("Jorah Mormont\r", out); fputs("Brienne of Tarth\r", out); @@ -605,7 +610,7 @@ url="ca65.html" name="assembler manual">. } } </verb> - </quote> + </tscreen> </descrip><p> diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 5e4626fbc..672f5d6aa 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -517,6 +517,14 @@ url="ca65.html" name="assembler manual">. </descrip><p> +<sect1>Specifying file types for fopen<p> + +See section +<url url="apple2.html#ss9.4" name="Specifying file types for fopen"> +in the apple2 docoumentation. + + + <sect>License<p> From 85e572f4e12e071ef61fb5846b8839b6e2781df8 Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Sun, 30 Jul 2017 19:49:20 -0400 Subject: [PATCH 404/407] Made corrections according to review comments --- doc/apple2.sgml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 4ed2af48c..33a878223 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -519,8 +519,9 @@ url="ca65.html" name="assembler manual">. ProDOS associates a file type and an auxiliary type with each file. These type specifications are separate from the file's name, unlike - Windows and UNIX-like systems which use the file name's suffix (a.k.a. - extension) to specify the file type. For example, .exe, .doc, or .bat. + Windows which uses the file name's suffix (a.k.a. + extension) to specify the file type. For example, <tt/.exe/, + <tt/.doc/, or <tt/.bat/. The ProDOS low-level Machine-Language Interface (MLI) functions for creating and opening files require these types to be specified. And if they don't match @@ -535,7 +536,7 @@ url="ca65.html" name="assembler manual">. There are two global variables provided that allow the file type and auxiliary type to be specified before a call to <tt/fopen()/ - or <tt/open/. They are defined in <tt/apple2_filetype.h/: + or <tt/open()/. They are defined in <tt/apple2_filetype.h/: <tscreen> <verb> @@ -547,8 +548,7 @@ url="ca65.html" name="assembler manual">. The header file <tt/apple2_filetype.h/ also defines many values that can be used to set these variables. It is included in <tt/apple2.h/, which is in turn included in <tt/apple2enh.h/. - So it - not necessary to include it directly. Just + So it isn't necessary to include it directly. Just include one of <tt/apple2.h/ or <tt/apple2enh.h/. <tag>Example</tag> @@ -563,8 +563,8 @@ url="ca65.html" name="assembler manual">. length text file is referred to as a sequential text file. This is equivalent to text files on other operating systems, except that the line terminator is a - carriage return instead of a new line (Linux/BSD/MacOS) or - carriage return, new line pair (Windows). + carriage return instead of a line-feed (Linux/BSD/MacOS) or + carriage return, line-feed pair (Windows). The "sequential" text file terminology is in contrast to a "random-access" text file which would @@ -584,7 +584,7 @@ url="ca65.html" name="assembler manual">. #include <errno.h> #include <apple2.h> - void main() + void main(void) { FILE *out; char *name = "MY.FAVS"; From 0bd5a8a3314b1b6b8047dc31113bd5ead59d706e Mon Sep 17 00:00:00 2001 From: Bill Chatfield <bill_chatfield@yahoo.com> Date: Sun, 30 Jul 2017 19:51:23 -0400 Subject: [PATCH 405/407] Made corrections according to review comments --- doc/apple2enh.sgml | 105 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 672f5d6aa..c7be9b474 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -519,9 +519,108 @@ url="ca65.html" name="assembler manual">. <sect1>Specifying file types for fopen<p> -See section -<url url="apple2.html#ss9.4" name="Specifying file types for fopen"> -in the apple2 docoumentation. +<descrip> + + <tag>Explanation of File Types</tag> + + ProDOS associates a file type and an auxiliary type with each file. + These type specifications are separate from the file's name, unlike + Windows which uses the file name's suffix (a.k.a. + extension) to specify the file type. For example, <tt/.exe/, + <tt/.doc/, or <tt/.bat/. + The ProDOS low-level + Machine-Language Interface (MLI) functions for creating and opening + files require these types to be specified. And if they don't match + with the file being opened, the operation may fail. + + In contrast, the ISO C function <tt/fopen()/ and the POSIX function + <tt/open()/ have no parameter to specify either a file type or an + auxiliary type. Therefore, some additional mechanism for specifying + the file types is needed. + + <tag>Specifying the File Type and Auxiliary Type</tag> + + There are two global variables provided that allow the file type + and auxiliary type to be specified before a call to <tt/fopen()/ + or <tt/open()/. They are defined in <tt/apple2_filetype.h/: + + <tscreen> + <verb> + extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ + extern unsigned int _auxtype; /* Default: 0 */ + </verb> + </tscreen> + + The header file <tt/apple2_filetype.h/ also defines many values + that can be used to set these variables. It is included in + <tt/apple2.h/, which is in turn included in <tt/apple2enh.h/. + So it isn't necessary to include it directly. Just + include one of <tt/apple2.h/ or <tt/apple2enh.h/. + + <tag>Example</tag> + + A text file cannot be created with just the + standard C functions because they default to the binary type + <tt/PRODOS_T_BIN/. The <tt/_filetype/ variable must be set to + <tt/PRODOS_T_TXT/ to create a text file. + + For a text file, + <tt/_auxtype/ specifies the record length. A zero record + length text file is referred to as a sequential text file. + This is equivalent to text files on + other operating systems, except that the line terminator is a + carriage return instead of a line-feed (Linux/BSD/MacOS) or + carriage return, line-feed pair (Windows). + + The "sequential" text file terminology is in contrast to a + "random-access" text file which would + have a fixed-length, non-zero record length, so that the + file position of any individual record can be calculated. + + For this example, the + <tt/_auxtype/ does not need to be set because it defaults to + the desired value, which is zero. To be more explicit, + <tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/ + which is defined as zero. + + <tscreen> + <verb> + #include <stdio.h> + #include <string.h> + #include <errno.h> + #include <apple2.h> + + void main(void) + { + FILE *out; + char *name = "MY.FAVS"; + + /*-----------------------------*/ + + _filetype = PRODOS_T_TXT; + _auxtype = PRODOS_AUX_T_TXT_SEQ; + + /*-----------------------------*/ + + if ((out = fopen(name, "w")) != NULL) { + fputs("Jorah Mormont\r", out); + fputs("Brienne of Tarth\r", out); + fputs("Daenerys Targaryen\r", out); + fputs("Sandor Clegane\r", out); + if (fclose(out) == EOF) { + fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno)); + } + } + else { + fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno)); + } + } + </verb> + </tscreen> + +</descrip><p> + + From 92ff854bff8cd3b93b37acebc4048626b93a83fc Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Mon, 31 Jul 2017 13:50:27 +0200 Subject: [PATCH 406/407] Removed undesirable empty lines. --- doc/apple2enh.sgml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index c7be9b474..4f5202543 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -621,10 +621,6 @@ url="ca65.html" name="assembler manual">. </descrip><p> - - - - <sect>License<p> This software is provided 'as-is', without any expressed or implied From f9c59a0976ff3eb654a7152ef31c4e1af59aa06b Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 2 Aug 2017 23:56:52 +0200 Subject: [PATCH 407/407] atari5200.inc: fix formatting --- asminc/atari5200.inc | 107 +++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/asminc/atari5200.inc b/asminc/atari5200.inc index b67c9a8db..91fae4a9a 100644 --- a/asminc/atari5200.inc +++ b/asminc/atari5200.inc @@ -8,42 +8,42 @@ ; ATASCII CHARACTER DEFS ;------------------------------------------------------------------------- -ATEOL = $9B ;END-OF-LINE, used by CONIO +ATEOL = $9B ; END-OF-LINE, used by CONIO ;------------------------------------------------------------------------- ; Zero Page ;------------------------------------------------------------------------- -POKMSK = $00 ;Mask for Pokey IRQ enable -RTCLOK = $01 ;60 hz. clock +POKMSK = $00 ; Mask for Pokey IRQ enable +RTCLOK = $01 ; 60 hz. clock JUMP = $01 -CRITIC = $03 ;Critical section -ATRACT = $04 ;Attract Mode +CRITIC = $03 ; Critical section +ATRACT = $04 ; Attract Mode -SDLSTL = $05 ;DLISTL Shadow -SDLSTH = $06 ;DLISTH " -SDMCTL = $07 ;DMACTL " +SDLSTL = $05 ; DLISTL Shadow +SDLSTH = $06 ; DLISTH " +SDMCTL = $07 ; DMACTL " -PCOLR0 = $08 ;COLPM0 Shadow -PCOLR1 = $09 ;COLPM1 " -PCOLR2 = $0A ;COLPM2 " -PCOLR3 = $0B ;COLPM3 " +PCOLR0 = $08 ; COLPM0 Shadow +PCOLR1 = $09 ; COLPM1 " +PCOLR2 = $0A ; COLPM2 " +PCOLR3 = $0B ; COLPM3 " -COLOR0 = $0C ;COLPF0 Shadow -COLOR1 = $0D ;COLPF1 " -COLOR2 = $0E ;COLPF2 " -COLOR3 = $0F ;COLPF3 " -COLOR4 = $10 ;COLBK " +COLOR0 = $0C ; COLPF0 Shadow +COLOR1 = $0D ; COLPF1 " +COLOR2 = $0E ; COLPF2 " +COLOR3 = $0F ; COLPF3 " +COLOR4 = $10 ; COLBK " -PADDL0 = $11 ;POT0 Shadow -PADDL1 = $12 ;POT1 " -PADDL2 = $13 ;POT2 " -PADDL3 = $14 ;POT3 " -PADDL4 = $15 ;POT4 " -PADDL5 = $16 ;POT5 " -PADDL6 = $17 ;POT6 " -PADDL7 = $18 ;POT7 " +PADDL0 = $11 ; POT0 Shadow +PADDL1 = $12 ; POT1 " +PADDL2 = $13 ; POT2 " +PADDL3 = $14 ; POT3 " +PADDL4 = $15 ; POT4 " +PADDL5 = $16 ; POT5 " +PADDL6 = $17 ; POT6 " +PADDL7 = $18 ; POT7 " ; cc65 runtime zero page variables @@ -57,26 +57,26 @@ SAVMSC = $1B ; pointer to screen memory (conio) ;Interrupt Vectors -VIMIRQ = $0200 ;Immediate IRQ - ;Preset $FC03 (SYSIRQ) -VVBLKI = $0202 ;Vblank immediate - ;Preset $FCB8 (SYSVBL) -VVBLKD = $0204 ;Vblank deferred - ;Preset $FCB2 (XITVBL) -VDSLST = $0206 ;Display List - ;Preset $FEA1 (OSDLI) -VKYBDI = $0208 ;Keyboard immediate - ;Preset $FD02 (SYSKBD) -VKYBDF = $020A ;Deferred Keyboard - ;Preset $FCB2 (XITVBL) -VTRIGR = $020C ;Soft Trigger -VBRKOP = $020E ;BRK Opcode -VSERIN = $0210 ;Serial in Ready -VSEROR = $0212 ;Serial Out Ready -VSEROC = $0214 ;Serial Output complete -VTIMR1 = $0216 ;Pokey Timer 1 -VTIMR2 = $0218 ;Pokey Timer 2 -VTIMR4 = $021A ;Pokey Timer 4 +VIMIRQ = $0200 ; Immediate IRQ + ; Preset $FC03 (SYSIRQ) +VVBLKI = $0202 ; Vblank immediate + ; Preset $FCB8 (SYSVBL) +VVBLKD = $0204 ; Vblank deferred + ; Preset $FCB2 (XITVBL) +VDSLST = $0206 ; Display List + ; Preset $FEA1 (OSDLI) +VKYBDI = $0208 ; Keyboard immediate + ; Preset $FD02 (SYSKBD) +VKYBDF = $020A ; Deferred Keyboard + ; Preset $FCB2 (XITVBL) +VTRIGR = $020C ; Soft Trigger +VBRKOP = $020E ; BRK Opcode +VSERIN = $0210 ; Serial in Ready +VSEROR = $0212 ; Serial Out Ready +VSEROC = $0214 ; Serial Output complete +VTIMR1 = $0216 ; Pokey Timer 1 +VTIMR2 = $0218 ; Pokey Timer 2 +VTIMR4 = $021A ; Pokey Timer 4 @@ -84,21 +84,21 @@ VTIMR4 = $021A ;Pokey Timer 4 ; CTIA/GTIA Address Equates ;------------------------------------------------------------------------- -GTIA = $C000 ;CTIA/GTIA area +GTIA = $C000 ; CTIA/GTIA area .include "atari_gtia.inc" ;------------------------------------------------------------------------- ; ANTIC Address Equates ;------------------------------------------------------------------------- -ANTIC = $D400 ;ANTIC area +ANTIC = $D400 ; ANTIC area .include "atari_antic.inc" ;------------------------------------------------------------------------- ; POKEY Address Equates ;------------------------------------------------------------------------- -POKEY = $E800 ;POKEY area +POKEY = $E800 ; POKEY area .include "atari_pokey.inc" @@ -106,11 +106,10 @@ POKEY = $E800 ;POKEY area ; Cartridge Parameters ;------------------------------------------------------------------------- -CARTNM = $BFE8 ;Cartridge Name Area -COPYD = $BFFC ;Copyright Decade in Cart -COPYR = $BFFD ;Copyright Year in Cart +CARTNM = $BFE8 ; Cartridge Name Area +COPYD = $BFFC ; Copyright Decade in Cart +COPYR = $BFFD ; Copyright Year in Cart ; $FF=Diagnostic Cart -GOCART = $BFFE ;Cartridge Start Vector +GOCART = $BFFE ; Cartridge Start Vector - -CHRORG = $F800 ;Character Generator Base +CHRORG = $F800 ; Character Generator Base