From de524a6561a86e218225f3b21e3ca5881e4a2861 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Wed, 4 Jun 2025 22:51:17 +0300 Subject: [PATCH 01/18] Initial Agat support --- asminc/agat.inc | 38 ++++++++++++++ cfg/agat.cfg | 44 ++++++++++++++++ include/agat.h | 67 ++++++++++++++++++++++++ libsrc/Makefile | 3 +- libsrc/agat/break.s | 113 ++++++++++++++++++++++++++++++++++++++++ libsrc/agat/cclear.s | 17 ++++++ libsrc/agat/cgetc.s | 23 ++++++++ libsrc/agat/clrscr.s | 10 ++++ libsrc/agat/color.s | 21 ++++++++ libsrc/agat/cout.s | 14 +++++ libsrc/agat/cputc.s | 45 ++++++++++++++++ libsrc/agat/crt0.s | 25 +++++++++ libsrc/agat/exehdr.s | 40 ++++++++++++++ libsrc/agat/gotoxy.s | 28 ++++++++++ libsrc/agat/gotoy.s | 18 +++++++ libsrc/agat/home.s | 15 ++++++ libsrc/agat/kbhit.s | 19 +++++++ libsrc/agat/randomize.s | 18 +++++++ libsrc/agat/revers.s | 38 ++++++++++++++ libsrc/agat/vtabz.s | 24 +++++++++ libsrc/agat/wherex.s | 19 +++++++ libsrc/agat/wherey.s | 17 ++++++ libsrc/agat/write.s | 50 ++++++++++++++++++ src/ca65/main.c | 4 ++ src/cc65/main.c | 4 ++ src/common/target.c | 22 +++++++- src/common/target.h | 1 + 27 files changed, 735 insertions(+), 2 deletions(-) create mode 100644 asminc/agat.inc create mode 100644 cfg/agat.cfg create mode 100644 include/agat.h create mode 100644 libsrc/agat/break.s create mode 100644 libsrc/agat/cclear.s create mode 100644 libsrc/agat/cgetc.s create mode 100644 libsrc/agat/clrscr.s create mode 100644 libsrc/agat/color.s create mode 100644 libsrc/agat/cout.s create mode 100644 libsrc/agat/cputc.s create mode 100644 libsrc/agat/crt0.s create mode 100644 libsrc/agat/exehdr.s create mode 100644 libsrc/agat/gotoxy.s create mode 100644 libsrc/agat/gotoy.s create mode 100644 libsrc/agat/home.s create mode 100644 libsrc/agat/kbhit.s create mode 100644 libsrc/agat/randomize.s create mode 100644 libsrc/agat/revers.s create mode 100644 libsrc/agat/vtabz.s create mode 100644 libsrc/agat/wherex.s create mode 100644 libsrc/agat/wherey.s create mode 100644 libsrc/agat/write.s diff --git a/asminc/agat.inc b/asminc/agat.inc new file mode 100644 index 000000000..84d21dbc2 --- /dev/null +++ b/asminc/agat.inc @@ -0,0 +1,38 @@ + +;----------------------------------------------------------------------------- +; Zero page stuff + +WNDLFT := $20 ; Text window left +WNDWDTH := $21 ; Text window width +WNDTOP := $22 ; Text window top +WNDBTM := $23 ; Text window bottom+1 +CH := $24 ; Cursor horizontal position +CV := $25 ; Cursor vertical position +BASL := $28 ; Text base address low +BASH := $29 ; Text base address high +CURSOR := $2D ; Cursor character +TATTR := $32 ; Text attributes +PROMPT := $33 ; Used by GETLN +VCOUT := $36 ; COUT Subroutine Vector +VCIN := $38 ; CIN Subroutine Vector +RNDL := $4E ; Random counter low +RNDH := $4F ; Random counter high +HIMEM := $73 ; Highest available memory address+1 + +;----------------------------------------------------------------------------- +; Vectors + +BRKVec := $03F0 ; Break vector +SOFTEV := $03F2 ; Vector for warm start +PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1 + +;----------------------------------------------------------------------------- +; Hardware + +; Keyboard input +KBD := $C000 ; Read keyboard +KBDSTRB := $C010 ; Clear keyboard strobe + +; Game controller +BUTN0 := $C061 ; Open-Apple Key +BUTN1 := $C062 ; Closed-Apple Key diff --git a/cfg/agat.cfg b/cfg/agat.cfg new file mode 100644 index 000000000..1a740cfc7 --- /dev/null +++ b/cfg/agat.cfg @@ -0,0 +1,44 @@ +# Default configuration + +FEATURES { + STARTADDRESS: default = $1903; +} +SYMBOLS { + __EXEHDR__: type = import; + __FILETYPE__: type = weak, value = $0006; # file type + __STACKSIZE__: type = weak, value = $0400; # 1k stack + __HIMEM__: type = weak, value = $C000; # Presumed RAM end +} +MEMORY { + ZP: file = "", define = yes, start = $0080, size = $001A; + HEADER: file = %O, start = %S - $003A, size = $003A; + MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S; + BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro, optional = yes; + STARTUP: 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, optional = yes; + ONCE: load = MAIN, type = ro, define = 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/agat.h b/include/agat.h new file mode 100644 index 000000000..a8ed98bb0 --- /dev/null +++ b/include/agat.h @@ -0,0 +1,67 @@ +#ifndef _AGAT_H +#define _AGAT_H + +/* Check for errors */ +#if !defined(__AGAT__) +# error This module may only be used when compiling for the Agat! +#endif + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +/* Color defines */ +#define COLOR_BLACK 0x00 +#define COLOR_RED 0x01 +#define COLOR_GREEN 0x02 +#define COLOR_YELLOW 0x03 +#define COLOR_BLUE 0x04 +#define COLOR_MAGENTA 0x05 +#define COLOR_CYAN 0x06 +#define COLOR_WHITE 0x07 + +/* Characters codes */ +#define CH_ENTER 0x0D +#define CH_ESC 0x1B +#define CH_CURS_LEFT 0x08 +#define CH_CURS_RIGHT 0x15 + + +/* Masks for joy_read */ +#define JOY_UP_MASK 0x10 +#define JOY_DOWN_MASK 0x20 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x40 +#define JOY_BTN_2_MASK 0x80 + +/* Return codes for get_ostype */ +#define AGAT_UNKNOWN 0x00 +#define AGAT_7 0x10 /* Agat 7 */ +#define AGAT_9 0x20 /* Agat 9 */ + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + +unsigned char get_ostype (void); +/* Get the machine type. Returns one of the AGAT_xxx codes. */ + +void rebootafterexit (void); +/* Reboot machine after program termination has completed. */ + +/* 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 _bgcolor(color) COLOR_BLACK +#define _bordercolor(color) COLOR_BLACK + +/* End of agat.h */ + + +#endif //_AGAT_H diff --git a/libsrc/Makefile b/libsrc/Makefile index 8a4f11414..2f1b604d7 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -15,7 +15,8 @@ CBMS = c128 \ GEOS = geos-apple \ geos-cbm -TARGETS = apple2 \ +TARGETS = agat \ + apple2 \ apple2enh \ atari \ atarixl \ diff --git a/libsrc/agat/break.s b/libsrc/agat/break.s new file mode 100644 index 000000000..d46679ba2 --- /dev/null +++ b/libsrc/agat/break.s @@ -0,0 +1,113 @@ +; +; Ullrich von Bassewitz, 27.09.1998 +; Oleg A. Odintsov, Moscow, 2024 +; +; void __fastcall__ set_brk (unsigned Addr); +; void reset_brk (void); +; + + .export _set_brk, _reset_brk + .destructor _reset_brk + + ; Be sure to export the following variables absolute + .export _brk_a: abs, _brk_x: abs, _brk_y: abs + .export _brk_sr: abs, _brk_pc: abs + + .include "agat.inc" + +_brk_a = $45 +_brk_x = $46 +_brk_y = $47 +_brk_sr = $48 +_brk_sp = $49 +_brk_pc = $3A + +.bss +oldvec: .res 2 ; Old vector + + +.data +uservec: jmp $FFFF ; Patched at runtime + + +.code + +; Set the break vector +.proc _set_brk + + sta uservec+1 + stx uservec+2 ; Set the user vector + + lda oldvec + ora oldvec+1 ; Did we save the vector already? + bne L1 ; Jump if we installed the handler already + + lda BRKVec + sta oldvec + lda BRKVec+1 + sta oldvec+1 ; Save the old vector + +L1: lda #brk_handler + sta BRKVec + stx BRKVec+1 + rts + +.endproc + + +; Reset the break vector +.proc _reset_brk + + lda oldvec + ldx oldvec+1 + beq @L9 ; Jump if vector not installed + sta BRKVec + stx BRKVec+1 + lda #$00 + sta oldvec ; Clear the old vector + stx oldvec+1 +@L9: rts + +.endproc + + + +; Break handler, called if a break occurs + +.proc brk_handler + + sec + lda _brk_pc + sbc #$02 ; Point to start of brk + sta _brk_pc + lda _brk_pc+1 + sbc #$00 + sta _brk_pc+1 + + clc + lda _brk_sp + adc #$04 ; Adjust stack pointer + sta _brk_sp + + lda _brk_sr ; Clear brk + and #$EF + sta _brk_sr + + jsr uservec ; Call the user's routine + + lda _brk_pc+1 + pha + lda _brk_pc + pha + lda _brk_sr + pha + + ldx _brk_x + ldy _brk_y + lda _brk_a + + rti ; Jump back... + +.endproc + diff --git a/libsrc/agat/cclear.s b/libsrc/agat/cclear.s new file mode 100644 index 000000000..65ae10049 --- /dev/null +++ b/libsrc/agat/cclear.s @@ -0,0 +1,17 @@ +; +; Oleg A. Odintsov, Moscow, 2024 +; +; void __fastcall__ cclear (unsigned char length); +; + + .export _cclear + .import COUT + .include "zeropage.inc" + +_cclear: + sta ptr1 + lda #$A0 +next: jsr COUT + dec ptr1 + bne next + rts diff --git a/libsrc/agat/cgetc.s b/libsrc/agat/cgetc.s new file mode 100644 index 000000000..a4b1389d2 --- /dev/null +++ b/libsrc/agat/cgetc.s @@ -0,0 +1,23 @@ +; +; Oleg A. Odintsov, Moscow, 2024 +; +; char cgetc (void); +; + + .export _cgetc + .import cursor + .include "agat.inc" + +_cgetc: + lda #$DF ; _ + bit cursor + bne hascur + lda #$00 +hascur: sta CURSOR + jsr j1 + cmp #$A0 + bpl :+ + and #$7F +: rts +j1: jmp (VCIN) + diff --git a/libsrc/agat/clrscr.s b/libsrc/agat/clrscr.s new file mode 100644 index 000000000..2fe54607a --- /dev/null +++ b/libsrc/agat/clrscr.s @@ -0,0 +1,10 @@ +; +; Kevin Ruland +; +; void clrscr (void); +; + + .export _clrscr + .import HOME + +_clrscr := HOME diff --git a/libsrc/agat/color.s b/libsrc/agat/color.s new file mode 100644 index 000000000..c68b6c3f6 --- /dev/null +++ b/libsrc/agat/color.s @@ -0,0 +1,21 @@ +; +; Oleg A. Odintsov, Moscow, 2024 +; +; unsigned char __fastcall__ textcolor (unsigned char color); +; + + + .export _textcolor + .include "agat.inc" + + +_textcolor: + ldx TATTR + eor TATTR + and #$07 + eor TATTR + sta TATTR + txa + and #$0F + rts + diff --git a/libsrc/agat/cout.s b/libsrc/agat/cout.s new file mode 100644 index 000000000..30b054b7e --- /dev/null +++ b/libsrc/agat/cout.s @@ -0,0 +1,14 @@ +; +; Oleg A. Odintsov, Moscow, 2024 +; +; COUT routine +; + + .export COUT + .include "agat.inc" + +COUT: + cmp #$10 + bpl out + ora #$80 +out: jmp (VCOUT) diff --git a/libsrc/agat/cputc.s b/libsrc/agat/cputc.s new file mode 100644 index 000000000..b30b6c45c --- /dev/null +++ b/libsrc/agat/cputc.s @@ -0,0 +1,45 @@ +; +; Oleg A. Odintsov, Moscow, 2024 +; +; void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c); +; void __fastcall__ cputc (char c); +; + + .import COUT + .export _cputcxy, _cputc + .import gotoxy, VTABZ + .include "agat.inc" + +_cputcxy: + pha + jsr gotoxy + pla +_cputc: + cmp #$0D + bne notleft + ldy #$00 + sty CH + rts +notleft:cmp #$0A + beq newline +putchar: + ldy CH + sta (BASL),Y + iny + lda TATTR + bmi wch + sta (BASL),Y + iny +wch: sty CH + cpy WNDWDTH + bcc noend + ldy #$00 + sty CH +newline:inc CV + lda CV + cmp WNDBTM + bcc :+ + lda WNDTOP + sta CV +: jmp VTABZ +noend: rts diff --git a/libsrc/agat/crt0.s b/libsrc/agat/crt0.s new file mode 100644 index 000000000..d678a79c8 --- /dev/null +++ b/libsrc/agat/crt0.s @@ -0,0 +1,25 @@ +; +; Startup code for cc65 (Agat version) +; + + .export __STARTUP__ : absolute = 1 ; Mark as startup + + .import initlib, donelib + .import zerobss, callmain + .import __ONCE_LOAD__, __ONCE_SIZE__ ; Linker generated + + .include "zeropage.inc" + .include "agat.inc" + +; ------------------------------------------------------------------------ + + .segment "STARTUP" + lda HIMEM + ldx HIMEM+1 + sta sp + stx sp+1 + jsr initlib + jsr zerobss + jsr callmain + jsr donelib + rts diff --git a/libsrc/agat/exehdr.s b/libsrc/agat/exehdr.s new file mode 100644 index 000000000..72ea390e9 --- /dev/null +++ b/libsrc/agat/exehdr.s @@ -0,0 +1,40 @@ +; +; Oliver Schmidt, 2012-06-10 +; +; This module supplies an AppleSingle version 2 file header + entry with +; ID 11 according to https://tools.ietf.org/rfc/rfc1740.txt Appendix A. +; + + .export __EXEHDR__ : absolute = 1 ; Linker referenced + .import __FILETYPE__ ; Linker generated + .import __MAIN_START__, __MAIN_LAST__ ; Linker generated + +; ------------------------------------------------------------------------ + +; Data Fork +ID01_LENGTH = __MAIN_LAST__ - __MAIN_START__ +ID01_OFFSET = ID01 - START + +; ProDOS File Info +ID11_LENGTH = ID01 - ID11 +ID11_OFFSET = ID11 - START + +; ------------------------------------------------------------------------ + + .segment "EXEHDR" + +START: .byte $00, $05, $16, $00 ; Magic number + .byte $00, $02, $00, $00 ; Version number + .res 16 ; Filler + .byte 0, 2 ; Number of entries + .byte 0, 0, 0, 1 ; Entry ID 1 - Data Fork + .byte 0, 0, >ID01_OFFSET, ID01_LENGTH, ID11_OFFSET, ID11_LENGTH, __FILETYPE__, <__FILETYPE__ ; File Type + .byte 0, 0 ; Auxiliary Type high + .byte >__MAIN_START__, <__MAIN_START__ ; Auxiliary Type low +ID01: diff --git a/libsrc/agat/gotoxy.s b/libsrc/agat/gotoxy.s new file mode 100644 index 000000000..2f9580c91 --- /dev/null +++ b/libsrc/agat/gotoxy.s @@ -0,0 +1,28 @@ +; +; Ullrich von Bassewitz, 06.08.1998 +; Oleg A. Odintsov, Moscow, 2024 +; +; void __fastcall__ gotoxy (unsigned char x, unsigned char y); +; void __fastcall__ gotox (unsigned char x); +; + + .export gotoxy, _gotoxy, _gotox + .import popa, VTABZ + + .include "agat.inc" + +gotoxy: + jsr popa ; Get Y +_gotoxy: + clc + adc WNDTOP + sta CV ; Store Y + jsr VTABZ + jsr popa ; Get X +_gotox: + bit TATTR + bmi t64 + asl +t64: + sta CH ; Store X + rts diff --git a/libsrc/agat/gotoy.s b/libsrc/agat/gotoy.s new file mode 100644 index 000000000..f4a8a4c4e --- /dev/null +++ b/libsrc/agat/gotoy.s @@ -0,0 +1,18 @@ +; +; Ullrich von Bassewitz, 06.08.1998 +; Oleg A. Odintsov, Moscow, 2024 +; +; void __fastcall__ gotoy (unsigned char y); +; + + .import VTABZ + .export _gotoy + .include "agat.inc" + +_gotoy: + clc + adc WNDTOP + sta CV + jmp VTABZ + + diff --git a/libsrc/agat/home.s b/libsrc/agat/home.s new file mode 100644 index 000000000..d3f000d25 --- /dev/null +++ b/libsrc/agat/home.s @@ -0,0 +1,15 @@ +; +; Oleg A. Odintsov, Moscow, 2024 +; +; HOME routine +; + + .export HOME + .import COUT + + .include "agat.inc" + +HOME: + lda #$8C + jsr COUT + rts diff --git a/libsrc/agat/kbhit.s b/libsrc/agat/kbhit.s new file mode 100644 index 000000000..f2bc4fc9f --- /dev/null +++ b/libsrc/agat/kbhit.s @@ -0,0 +1,19 @@ +; +; Kevin Ruland +; Ullrich von Bassewitz, 2005-03-25 +; Oleg A. Odintsov, Moscow, 2024 +; +; unsigned char kbhit (void); +; + + .export _kbhit + + .include "agat.inc" + +_kbhit: + lda KBD ; Reading KBD checks for keypress + rol ; if high bit is set, key was pressed + lda #$00 + tax + rol + rts diff --git a/libsrc/agat/randomize.s b/libsrc/agat/randomize.s new file mode 100644 index 000000000..914f40634 --- /dev/null +++ b/libsrc/agat/randomize.s @@ -0,0 +1,18 @@ +; +; Ullrich von Bassewitz, 07.11.2002 +; Oleg A. Odintsov, Moscow, 2024 +; +; void _randomize (void); +; /* Initialize the random number generator */ +; + + .export __randomize + .import _srand + + .include "apple2.inc" + +__randomize: + ldx RNDH ; Use random value supplied by ROM + lda RNDL + jmp _srand ; Initialize generator + diff --git a/libsrc/agat/revers.s b/libsrc/agat/revers.s new file mode 100644 index 000000000..ceca7cf5b --- /dev/null +++ b/libsrc/agat/revers.s @@ -0,0 +1,38 @@ +; +; Ullrich von Bassewitz, 2005-03-28 +; Oleg A. Odintsov, Moscow, 2024 +; +; unsigned char __fastcall__ revers (unsigned char onoff) +; unsigned char __fastcall__ flash (unsigned char onoff) +; + + .export _revers, _flash + + .include "agat.inc" + +_revers: + tax + beq noinv + lda TATTR + and #$D7 + sta TATTR + rts +noinv: + lda TATTR + ora #$20 + sta TATTR + rts + +_flash: + tax + beq noflash + lda TATTR + and #$DF + ora #$08 + sta TATTR + rts +noflash: + lda TATTR + ora #$20 + sta TATTR + rts diff --git a/libsrc/agat/vtabz.s b/libsrc/agat/vtabz.s new file mode 100644 index 000000000..a711a87c9 --- /dev/null +++ b/libsrc/agat/vtabz.s @@ -0,0 +1,24 @@ +; +; Oleg A. Odintsov, Moscow, 2024 +; +; VTABZ routine +; + + .export VTABZ + .include "agat.inc" + +VTABZ: + lda CV + ror + ror + ror + and #$C0 + sta BASL + lda CV + lsr + lsr + eor BASH + and #$07 + eor BASH + sta BASH + rts diff --git a/libsrc/agat/wherex.s b/libsrc/agat/wherex.s new file mode 100644 index 000000000..b6d277680 --- /dev/null +++ b/libsrc/agat/wherex.s @@ -0,0 +1,19 @@ +; +; Kevin Ruland +; Oleg A. Odintsov, Moscow, 2024 +; +; unsigned char wherex (void); +; + + .export _wherex + + .include "agat.inc" + +_wherex: + lda CH + bit TATTR + bmi t64 + lsr +t64: + ldx #$00 + rts diff --git a/libsrc/agat/wherey.s b/libsrc/agat/wherey.s new file mode 100644 index 000000000..4660a55f9 --- /dev/null +++ b/libsrc/agat/wherey.s @@ -0,0 +1,17 @@ +; +; Kevin Ruland +; Oleg A. Odintsov, Moscow, 2024 +; +; unsigned char wherey (void); +; + + .export _wherey + + .include "agat.inc" + +_wherey: + lda CV + sec + sbc WNDTOP + ldx #$00 + rts diff --git a/libsrc/agat/write.s b/libsrc/agat/write.s new file mode 100644 index 000000000..6ac28f32c --- /dev/null +++ b/libsrc/agat/write.s @@ -0,0 +1,50 @@ +; +; Oleg A. Odintsov, Moscow, 2024 +; +; int __fastcall__ write (int fd, const void* buf, unsigned count); +; + + .export _write + .import popax, popptr1 + .import COUT + + .include "zeropage.inc" + +_write: + sta ptr2 + stx ptr2+1 + jsr popptr1 + jsr popax + + ; Check for zero count + ora ptr2 + beq done + + ; Get char from buf +next: ldy #$00 + lda (ptr1),y + + ; Replace '\n' with '\r' + cmp #$0A + bne output + lda #$8D + + ; Set hi bit and write to device +output: + jsr COUT ; Preserves X and Y + + ; Increment pointer + inc ptr1 + bne :+ + inc ptr1+1 + + ; Decrement count +: dec ptr2 + bne next + dec ptr2+1 + bpl next + + ; Return success +done: lda #$00 + rts + diff --git a/src/ca65/main.c b/src/ca65/main.c index f3100162a..c99ce06c6 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -350,6 +350,10 @@ static void SetSys (const char* Sys) NewSymbol ("__RP6502__", 1); break; + case TGT_AGAT: + NewSymbol ("__AGAT__", 1); + break; + default: AbEnd ("Invalid target name: '%s'", Sys); diff --git a/src/cc65/main.c b/src/cc65/main.c index 47435757c..baf6f2f17 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -306,6 +306,10 @@ static void SetSys (const char* Sys) case TGT_RP6502: DefineNumericMacro ("__RP6502__", 1); break; + + case TGT_AGAT: + DefineNumericMacro ("__AGAT__", 1); + break; default: AbEnd ("Unknown target system '%s'", Sys); diff --git a/src/common/target.c b/src/common/target.c index b50478e16..761f7c3fd 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -129,7 +129,25 @@ static const unsigned char CTPET[256] = { 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, }; - +/* Translation table KOI8-R -> Agat-9 */ +static unsigned char CTAgat[256] = { + 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, + 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, + 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, + 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F, + 0x1B,0x5C,0x10,0x12,0x1D,0x1F,0x13,0x1C,0x11,0x1E,0x14,0x8B,0x8C,0x8D,0x8E,0x8F, + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, + 0xA0,0xA1,0xA2,0x0F,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, + 0xB0,0xB1,0xB2,0x9F,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, + 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, + 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F, + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, +}; /* One entry in the target map */ typedef struct TargetEntry TargetEntry; @@ -142,6 +160,7 @@ struct TargetEntry { ** Allows multiple entries for one target ID (target name aliases). */ static const TargetEntry TargetMap[] = { + { "agat", TGT_AGAT }, { "apple2", TGT_APPLE2 }, { "apple2enh", TGT_APPLE2ENH }, { "atari", TGT_ATARI }, @@ -223,6 +242,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sym1", CPU_6502, BINFMT_BINARY, CTNone }, { "kim1", CPU_6502, BINFMT_BINARY, CTNone }, { "rp6502", CPU_65C02, BINFMT_BINARY, CTNone }, + { "agat", CPU_6502, BINFMT_BINARY, CTAgat }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 730b8211e..d6c9fc35b 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -89,6 +89,7 @@ typedef enum { TGT_SYM1, TGT_KIM1, TGT_RP6502, + TGT_AGAT, TGT_COUNT /* Number of target systems */ } target_t; From 5ff18c1ebc7179002b9be74262ea536d968ffaea Mon Sep 17 00:00:00 2001 From: Konstantin Date: Wed, 4 Jun 2025 23:11:13 +0300 Subject: [PATCH 02/18] Updates --- asminc/agat.inc | 1 + include/agat.h | 12 ++++++---- libsrc/agat/crt0.s | 57 ++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/asminc/agat.inc b/asminc/agat.inc index 84d21dbc2..b96d31834 100644 --- a/asminc/agat.inc +++ b/asminc/agat.inc @@ -22,6 +22,7 @@ HIMEM := $73 ; Highest available memory address+1 ;----------------------------------------------------------------------------- ; Vectors +DOSWARM := $03D0 ; DOS warmstart vector BRKVec := $03F0 ; Break vector SOFTEV := $03F2 ; Vector for warm start PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1 diff --git a/include/agat.h b/include/agat.h index a8ed98bb0..6333170c7 100644 --- a/include/agat.h +++ b/include/agat.h @@ -24,10 +24,14 @@ #define COLOR_WHITE 0x07 /* Characters codes */ -#define CH_ENTER 0x0D -#define CH_ESC 0x1B -#define CH_CURS_LEFT 0x08 -#define CH_CURS_RIGHT 0x15 +#define CH_CTRL_C 0x03 +#define CH_ENTER 0x0D +#define CH_ESC 0x1B +#define CH_CURS_LEFT 0x08 +#define CH_CURS_RIGHT 0x15 +#define CH_CURS_UP 0x19 +#define CH_CURS_DOWN 0x1A +#define CH_ESC 0x1B /* Masks for joy_read */ diff --git a/libsrc/agat/crt0.s b/libsrc/agat/crt0.s index d678a79c8..9f8993332 100644 --- a/libsrc/agat/crt0.s +++ b/libsrc/agat/crt0.s @@ -3,6 +3,7 @@ ; .export __STARTUP__ : absolute = 1 ; Mark as startup + .export _exit .import initlib, donelib .import zerobss, callmain @@ -14,12 +15,60 @@ ; ------------------------------------------------------------------------ .segment "STARTUP" + jsr init + jsr zerobss + jsr callmain +_exit: ldx #exit + jsr reset + jsr donelib +exit: ldx #$02 +: lda rvsave,x + sta SOFTEV,x + dex + bpl :- + ldx #zpspace-1 +: lda zpsave,x + sta sp,x + dex + bpl :- + ldx #$FF + txs + jmp DOSWARM + + + + .segment "ONCE" + +init: ldx #zpspace-1 +: lda sp,x + sta zpsave,x + dex + bpl :- + + ldx #$02 +: lda SOFTEV,x + sta rvsave,x + dex + bpl :- + lda HIMEM ldx HIMEM+1 sta sp stx sp+1 - jsr initlib - jsr zerobss - jsr callmain - jsr donelib + ldx #<_exit + lda #>_exit + jsr reset + jmp initlib + + .code + +reset: stx SOFTEV + sta SOFTEV+1 + eor #$A5 + sta PWREDUP rts + + .segment "INIT" +zpsave: .res zpspace +rvsave: .res 3 From 1a109c0b3438928e1dce045799ae678a576584d0 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 7 Jun 2025 12:36:49 +0300 Subject: [PATCH 03/18] Fix codestyle --- include/agat.h | 50 +++++++++++----------- libsrc/agat/cclear.s | 18 ++++---- libsrc/agat/cgetc.s | 29 +++++++------ libsrc/agat/clrscr.s | 4 +- libsrc/agat/color.s | 21 +++++----- libsrc/agat/cout.s | 12 +++--- libsrc/agat/cputc.s | 68 +++++++++++++++--------------- libsrc/agat/crt0.s | 98 ++++++++++++++++++++++---------------------- libsrc/agat/gotoxy.s | 22 +++++----- libsrc/agat/gotoy.s | 16 ++++---- libsrc/agat/home.s | 6 +-- libsrc/agat/revers.s | 46 ++++++++++----------- libsrc/agat/vtabz.s | 32 +++++++-------- libsrc/agat/wherex.s | 12 +++--- 14 files changed, 215 insertions(+), 219 deletions(-) diff --git a/include/agat.h b/include/agat.h index 6333170c7..2cdf24ae6 100644 --- a/include/agat.h +++ b/include/agat.h @@ -14,38 +14,38 @@ /* Color defines */ -#define COLOR_BLACK 0x00 -#define COLOR_RED 0x01 -#define COLOR_GREEN 0x02 -#define COLOR_YELLOW 0x03 -#define COLOR_BLUE 0x04 -#define COLOR_MAGENTA 0x05 -#define COLOR_CYAN 0x06 -#define COLOR_WHITE 0x07 +#define COLOR_BLACK 0x00 +#define COLOR_RED 0x01 +#define COLOR_GREEN 0x02 +#define COLOR_YELLOW 0x03 +#define COLOR_BLUE 0x04 +#define COLOR_MAGENTA 0x05 +#define COLOR_CYAN 0x06 +#define COLOR_WHITE 0x07 /* Characters codes */ -#define CH_CTRL_C 0x03 -#define CH_ENTER 0x0D -#define CH_ESC 0x1B -#define CH_CURS_LEFT 0x08 -#define CH_CURS_RIGHT 0x15 -#define CH_CURS_UP 0x19 -#define CH_CURS_DOWN 0x1A -#define CH_ESC 0x1B +#define CH_CTRL_C 0x03 +#define CH_ENTER 0x0D +#define CH_ESC 0x1B +#define CH_CURS_LEFT 0x08 +#define CH_CURS_RIGHT 0x15 +#define CH_CURS_UP 0x19 +#define CH_CURS_DOWN 0x1A +#define CH_ESC 0x1B /* Masks for joy_read */ -#define JOY_UP_MASK 0x10 -#define JOY_DOWN_MASK 0x20 -#define JOY_LEFT_MASK 0x04 -#define JOY_RIGHT_MASK 0x08 -#define JOY_BTN_1_MASK 0x40 -#define JOY_BTN_2_MASK 0x80 +#define JOY_UP_MASK 0x10 +#define JOY_DOWN_MASK 0x20 +#define JOY_LEFT_MASK 0x04 +#define JOY_RIGHT_MASK 0x08 +#define JOY_BTN_1_MASK 0x40 +#define JOY_BTN_2_MASK 0x80 /* Return codes for get_ostype */ -#define AGAT_UNKNOWN 0x00 -#define AGAT_7 0x10 /* Agat 7 */ -#define AGAT_9 0x20 /* Agat 9 */ +#define AGAT_UNKNOWN 0x00 +#define AGAT_7 0x10 /* Agat 7 */ +#define AGAT_9 0x20 /* Agat 9 */ /*****************************************************************************/ diff --git a/libsrc/agat/cclear.s b/libsrc/agat/cclear.s index 65ae10049..dcc5834ad 100644 --- a/libsrc/agat/cclear.s +++ b/libsrc/agat/cclear.s @@ -4,14 +4,14 @@ ; void __fastcall__ cclear (unsigned char length); ; - .export _cclear - .import COUT - .include "zeropage.inc" + .export _cclear + .import COUT + .include "zeropage.inc" _cclear: - sta ptr1 - lda #$A0 -next: jsr COUT - dec ptr1 - bne next - rts + sta ptr1 + lda #$A0 +next: jsr COUT + dec ptr1 + bne next + rts diff --git a/libsrc/agat/cgetc.s b/libsrc/agat/cgetc.s index a4b1389d2..18bba2fd8 100644 --- a/libsrc/agat/cgetc.s +++ b/libsrc/agat/cgetc.s @@ -4,20 +4,19 @@ ; char cgetc (void); ; - .export _cgetc - .import cursor - .include "agat.inc" + .export _cgetc + .import cursor + .include "agat.inc" _cgetc: - lda #$DF ; _ - bit cursor - bne hascur - lda #$00 -hascur: sta CURSOR - jsr j1 - cmp #$A0 - bpl :+ - and #$7F -: rts -j1: jmp (VCIN) - + lda #$DF ; _ + bit cursor + bne hascur + lda #$00 +hascur: sta CURSOR + jsr j1 + cmp #$A0 + bpl :+ + and #$7F +: rts +j1: jmp (VCIN) diff --git a/libsrc/agat/clrscr.s b/libsrc/agat/clrscr.s index 2fe54607a..8b2d7100b 100644 --- a/libsrc/agat/clrscr.s +++ b/libsrc/agat/clrscr.s @@ -4,7 +4,7 @@ ; void clrscr (void); ; - .export _clrscr - .import HOME + .export _clrscr + .import HOME _clrscr := HOME diff --git a/libsrc/agat/color.s b/libsrc/agat/color.s index c68b6c3f6..0992bb860 100644 --- a/libsrc/agat/color.s +++ b/libsrc/agat/color.s @@ -5,17 +5,16 @@ ; - .export _textcolor - .include "agat.inc" + .export _textcolor + .include "agat.inc" _textcolor: - ldx TATTR - eor TATTR - and #$07 - eor TATTR - sta TATTR - txa - and #$0F - rts - + ldx TATTR + eor TATTR + and #$07 + eor TATTR + sta TATTR + txa + and #$0F + rts diff --git a/libsrc/agat/cout.s b/libsrc/agat/cout.s index 30b054b7e..ae9d8a177 100644 --- a/libsrc/agat/cout.s +++ b/libsrc/agat/cout.s @@ -4,11 +4,11 @@ ; COUT routine ; - .export COUT - .include "agat.inc" + .export COUT + .include "agat.inc" COUT: - cmp #$10 - bpl out - ora #$80 -out: jmp (VCOUT) + cmp #$10 + bpl out + ora #$80 +out: jmp (VCOUT) diff --git a/libsrc/agat/cputc.s b/libsrc/agat/cputc.s index b30b6c45c..6bf9b604f 100644 --- a/libsrc/agat/cputc.s +++ b/libsrc/agat/cputc.s @@ -5,41 +5,41 @@ ; void __fastcall__ cputc (char c); ; - .import COUT - .export _cputcxy, _cputc - .import gotoxy, VTABZ - .include "agat.inc" + .import COUT + .export _cputcxy, _cputc + .import gotoxy, VTABZ + .include "agat.inc" _cputcxy: - pha - jsr gotoxy - pla + pha + jsr gotoxy + pla _cputc: - cmp #$0D - bne notleft - ldy #$00 - sty CH - rts -notleft:cmp #$0A - beq newline + cmp #$0D + bne notleft + ldy #$00 + sty CH + rts +notleft:cmp #$0A + beq newline putchar: - ldy CH - sta (BASL),Y - iny - lda TATTR - bmi wch - sta (BASL),Y - iny -wch: sty CH - cpy WNDWDTH - bcc noend - ldy #$00 - sty CH -newline:inc CV - lda CV - cmp WNDBTM - bcc :+ - lda WNDTOP - sta CV -: jmp VTABZ -noend: rts + ldy CH + sta (BASL),Y + iny + lda TATTR + bmi wch + sta (BASL),Y + iny +wch:sty CH + cpy WNDWDTH + bcc noend + ldy #$00 + sty CH +newline:inc CV + lda CV + cmp WNDBTM + bcc :+ + lda WNDTOP + sta CV +: jmp VTABZ +noend: rts diff --git a/libsrc/agat/crt0.s b/libsrc/agat/crt0.s index 9f8993332..78fef06bc 100644 --- a/libsrc/agat/crt0.s +++ b/libsrc/agat/crt0.s @@ -14,61 +14,61 @@ ; ------------------------------------------------------------------------ - .segment "STARTUP" - jsr init - jsr zerobss - jsr callmain -_exit: ldx #exit - jsr reset - jsr donelib -exit: ldx #$02 -: lda rvsave,x - sta SOFTEV,x - dex - bpl :- - ldx #zpspace-1 -: lda zpsave,x - sta sp,x - dex - bpl :- - ldx #$FF - txs - jmp DOSWARM + .segment "STARTUP" + jsr init + jsr zerobss + jsr callmain +_exit: ldx #exit + jsr reset + jsr donelib +exit: ldx #$02 +: lda rvsave,x + sta SOFTEV,x + dex + bpl :- + ldx #zpspace-1 +: lda zpsave,x + sta sp,x + dex + bpl :- + ldx #$FF + txs + jmp DOSWARM - .segment "ONCE" + .segment "ONCE" -init: ldx #zpspace-1 -: lda sp,x - sta zpsave,x - dex - bpl :- +init: ldx #zpspace-1 +: lda sp,x + sta zpsave,x + dex + bpl :- - ldx #$02 -: lda SOFTEV,x - sta rvsave,x - dex - bpl :- + ldx #$02 +: lda SOFTEV,x + sta rvsave,x + dex + bpl :- - lda HIMEM - ldx HIMEM+1 - sta sp - stx sp+1 - ldx #<_exit - lda #>_exit - jsr reset - jmp initlib + lda HIMEM + ldx HIMEM+1 + sta sp + stx sp+1 + ldx #<_exit + lda #>_exit + jsr reset + jmp initlib - .code + .code -reset: stx SOFTEV - sta SOFTEV+1 - eor #$A5 - sta PWREDUP - rts +reset: stx SOFTEV + sta SOFTEV+1 + eor #$A5 + sta PWREDUP + rts - .segment "INIT" -zpsave: .res zpspace -rvsave: .res 3 + .segment "INIT" +zpsave: .res zpspace +rvsave: .res 3 diff --git a/libsrc/agat/gotoxy.s b/libsrc/agat/gotoxy.s index 2f9580c91..13e7cb747 100644 --- a/libsrc/agat/gotoxy.s +++ b/libsrc/agat/gotoxy.s @@ -12,17 +12,17 @@ .include "agat.inc" gotoxy: - jsr popa ; Get Y + jsr popa ; Get Y _gotoxy: - clc - adc WNDTOP - sta CV ; Store Y - jsr VTABZ - jsr popa ; Get X + clc + adc WNDTOP + sta CV ; Store Y + jsr VTABZ + jsr popa ; Get X _gotox: - bit TATTR - bmi t64 - asl + bit TATTR + bmi t64 + asl t64: - sta CH ; Store X - rts + sta CH ; Store X + rts diff --git a/libsrc/agat/gotoy.s b/libsrc/agat/gotoy.s index f4a8a4c4e..ea0eadbf2 100644 --- a/libsrc/agat/gotoy.s +++ b/libsrc/agat/gotoy.s @@ -5,14 +5,12 @@ ; void __fastcall__ gotoy (unsigned char y); ; - .import VTABZ - .export _gotoy - .include "agat.inc" + .import VTABZ + .export _gotoy + .include "agat.inc" _gotoy: - clc - adc WNDTOP - sta CV - jmp VTABZ - - + clc + adc WNDTOP + sta CV + jmp VTABZ diff --git a/libsrc/agat/home.s b/libsrc/agat/home.s index d3f000d25..5067a782a 100644 --- a/libsrc/agat/home.s +++ b/libsrc/agat/home.s @@ -10,6 +10,6 @@ .include "agat.inc" HOME: - lda #$8C - jsr COUT - rts + lda #$8C + jsr COUT + rts diff --git a/libsrc/agat/revers.s b/libsrc/agat/revers.s index ceca7cf5b..20c1b9bdb 100644 --- a/libsrc/agat/revers.s +++ b/libsrc/agat/revers.s @@ -6,33 +6,33 @@ ; unsigned char __fastcall__ flash (unsigned char onoff) ; - .export _revers, _flash + .export _revers, _flash - .include "agat.inc" + .include "agat.inc" _revers: - tax - beq noinv - lda TATTR - and #$D7 - sta TATTR - rts + tax + beq noinv + lda TATTR + and #$D7 + sta TATTR + rts noinv: - lda TATTR - ora #$20 - sta TATTR - rts + lda TATTR + ora #$20 + sta TATTR + rts _flash: - tax - beq noflash - lda TATTR - and #$DF - ora #$08 - sta TATTR - rts + tax + beq noflash + lda TATTR + and #$DF + ora #$08 + sta TATTR + rts noflash: - lda TATTR - ora #$20 - sta TATTR - rts + lda TATTR + ora #$20 + sta TATTR + rts diff --git a/libsrc/agat/vtabz.s b/libsrc/agat/vtabz.s index a711a87c9..88166eb35 100644 --- a/libsrc/agat/vtabz.s +++ b/libsrc/agat/vtabz.s @@ -4,21 +4,21 @@ ; VTABZ routine ; - .export VTABZ - .include "agat.inc" + .export VTABZ + .include "agat.inc" VTABZ: - lda CV - ror - ror - ror - and #$C0 - sta BASL - lda CV - lsr - lsr - eor BASH - and #$07 - eor BASH - sta BASH - rts + lda CV + ror + ror + ror + and #$C0 + sta BASL + lda CV + lsr + lsr + eor BASH + and #$07 + eor BASH + sta BASH + rts diff --git a/libsrc/agat/wherex.s b/libsrc/agat/wherex.s index b6d277680..a83f7cd75 100644 --- a/libsrc/agat/wherex.s +++ b/libsrc/agat/wherex.s @@ -10,10 +10,10 @@ .include "agat.inc" _wherex: - lda CH - bit TATTR - bmi t64 - lsr + lda CH + bit TATTR + bmi t64 + lsr t64: - ldx #$00 - rts + ldx #$00 + rts From cbf1b1d5a7857e7e3248787f61cf9d9058a784f5 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 7 Jun 2025 14:00:10 +0300 Subject: [PATCH 04/18] Updated translation table --- src/common/target.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/target.c b/src/common/target.c index 761f7c3fd..fc1a9df25 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -138,11 +138,11 @@ static unsigned char CTAgat[256] = { 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, - 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F, - 0x1B,0x5C,0x10,0x12,0x1D,0x1F,0x13,0x1C,0x11,0x1E,0x14,0x8B,0x8C,0x8D,0x8E,0x8F, - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, - 0xA0,0xA1,0xA2,0x0F,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, - 0xB0,0xB1,0xB2,0x9F,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, + 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0xA0, + 0x1B,0x5C,0x10,0x12,0x1D,0x1F,0x13,0x1C,0x11,0x1E,0x14,0xA0,0x02,0x5F,0xA0,0xA0, + 0xA0,0xA0,0xA0,0xA0,0xA0,0x9E,0x04,0xA0,0x3C,0x3E,0xA0,0xA0,0x30,0x32,0xA0,0x2F, + 0xA0,0xA0,0xA0,0x0F,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0, + 0xA0,0xA0,0xA0,0x9F,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0, 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F, 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, From 34daf33d932eaf4f0ea832b7656b591b4b47ee21 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 7 Jun 2025 14:10:50 +0300 Subject: [PATCH 05/18] Remove dangling spaces --- src/ca65/main.c | 2 +- src/cc65/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index c99ce06c6..682e9be7f 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -353,7 +353,7 @@ static void SetSys (const char* Sys) case TGT_AGAT: NewSymbol ("__AGAT__", 1); break; - + default: AbEnd ("Invalid target name: '%s'", Sys); diff --git a/src/cc65/main.c b/src/cc65/main.c index baf6f2f17..f56974361 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -306,7 +306,7 @@ static void SetSys (const char* Sys) case TGT_RP6502: DefineNumericMacro ("__RP6502__", 1); break; - + case TGT_AGAT: DefineNumericMacro ("__AGAT__", 1); break; From 41a82f7165030ec0e0cddf225c720398aab813ec Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 8 Jun 2025 23:20:21 +0300 Subject: [PATCH 06/18] fix codestyle --- libsrc/agat/_scrsize.s | 17 +++++++++++++++++ libsrc/agat/cclear.s | 3 ++- libsrc/agat/cgetc.s | 3 ++- libsrc/agat/cputc.s | 12 ++++++++---- libsrc/agat/crt0.s | 12 ++++++++---- libsrc/agat/randomize.s | 2 +- 6 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 libsrc/agat/_scrsize.s diff --git a/libsrc/agat/_scrsize.s b/libsrc/agat/_scrsize.s new file mode 100644 index 000000000..f9d7c3785 --- /dev/null +++ b/libsrc/agat/_scrsize.s @@ -0,0 +1,17 @@ +; +; Ullrich von Bassewitz, 26.10.2000 +; +; Screen size variables +; + + .export screensize + + .include "agat.inc" + +screensize: + ldx WNDWDTH + lda WNDBTM + sec + sbc WNDTOP + tay + rts diff --git a/libsrc/agat/cclear.s b/libsrc/agat/cclear.s index dcc5834ad..93a561ef4 100644 --- a/libsrc/agat/cclear.s +++ b/libsrc/agat/cclear.s @@ -11,7 +11,8 @@ _cclear: sta ptr1 lda #$A0 -next: jsr COUT +next: + jsr COUT dec ptr1 bne next rts diff --git a/libsrc/agat/cgetc.s b/libsrc/agat/cgetc.s index 18bba2fd8..839e4314a 100644 --- a/libsrc/agat/cgetc.s +++ b/libsrc/agat/cgetc.s @@ -13,7 +13,8 @@ _cgetc: bit cursor bne hascur lda #$00 -hascur: sta CURSOR +hascur: + sta CURSOR jsr j1 cmp #$A0 bpl :+ diff --git a/libsrc/agat/cputc.s b/libsrc/agat/cputc.s index 6bf9b604f..b8d99aaea 100644 --- a/libsrc/agat/cputc.s +++ b/libsrc/agat/cputc.s @@ -20,7 +20,8 @@ _cputc: ldy #$00 sty CH rts -notleft:cmp #$0A +notleft: + cmp #$0A beq newline putchar: ldy CH @@ -30,16 +31,19 @@ putchar: bmi wch sta (BASL),Y iny -wch:sty CH +wch: + sty CH cpy WNDWDTH bcc noend ldy #$00 sty CH -newline:inc CV +newline: + inc CV lda CV cmp WNDBTM bcc :+ lda WNDTOP sta CV : jmp VTABZ -noend: rts +noend: + rts diff --git a/libsrc/agat/crt0.s b/libsrc/agat/crt0.s index 78fef06bc..41f03b24d 100644 --- a/libsrc/agat/crt0.s +++ b/libsrc/agat/crt0.s @@ -18,11 +18,13 @@ jsr init jsr zerobss jsr callmain -_exit: ldx #exit jsr reset jsr donelib -exit: ldx #$02 +exit: + ldx #$02 : lda rvsave,x sta SOFTEV,x dex @@ -40,7 +42,8 @@ exit: ldx #$02 .segment "ONCE" -init: ldx #zpspace-1 +init: + ldx #zpspace-1 : lda sp,x sta zpsave,x dex @@ -63,7 +66,8 @@ init: ldx #zpspace-1 .code -reset: stx SOFTEV +reset: + stx SOFTEV sta SOFTEV+1 eor #$A5 sta PWREDUP diff --git a/libsrc/agat/randomize.s b/libsrc/agat/randomize.s index 914f40634..9eef16f05 100644 --- a/libsrc/agat/randomize.s +++ b/libsrc/agat/randomize.s @@ -9,7 +9,7 @@ .export __randomize .import _srand - .include "apple2.inc" + .include "agat.inc" __randomize: ldx RNDH ; Use random value supplied by ROM From 4d5a290135950b5f5c97e9d6b9a5a25f992ba98e Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 8 Jun 2025 23:30:34 +0300 Subject: [PATCH 07/18] add docs and readme.md --- README.md | 1 + doc/agat.sgml | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ doc/index.sgml | 3 ++ 3 files changed, 83 insertions(+) create mode 100644 doc/agat.sgml diff --git a/README.md b/README.md index e3f1ab30f..4c1003179 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ the [cc65 web site](https://cc65.github.io): | Dr. Jozo Dujmović | Picocomputer (RP6502) | | Watara | Watura/QuickShot Supervision | | Synertek | SYM-1 | +| USSR | Agat 7/9 | A generic configuration to adapt cc65 to new targets is also around. diff --git a/doc/agat.sgml b/doc/agat.sgml new file mode 100644 index 000000000..1238dd394 --- /dev/null +++ b/doc/agat.sgml @@ -0,0 +1,79 @@ + + +
+Agat-7/9 - specific information for cc65 + +<author><url url="https://sourceforge.net/u/olegodintsov/profile/" name="Oleg A. Odintsov">,<newline> +<url url="mailto:sintechs@gmail.com" name="Konstantin Fedorov"> + +<abstract> +An overview over the Agat-7 and Agat-9 and theirs interfaces to the cc65 C +compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview + +<p>The Agat was a series of 8-bit computers produced in the Soviet Union from 1983 to 1993. +It was based on Apple II architecture with all electronic components made in the Soviet Union except for 6502 microprocessors supplied by UMC (UM6502A). +<p>If compared to Apple II, Agat had many improvements such as color text mode, additional graphic modes and flexible memory controller. +Agat-7 had an Apple II compatibility card called "Module 121", while Agat-9 had a built-in Apple II+ mode activated by soft-switch. +<p>All mass-produced Agat models were disk-based systems, 2K ROM contained only basic machine language monitor and disassembler. +Agat-7 had 140K floppy-drive based on Apple DISK II, while Agat-9 was supplied with 840K drive having its own sector format and controller. + +<sect>Binary format<p> + +The standard binary file format generated by the linker for the Agat target is +an AppleSingle file to be compatible with AppleCommander <url url="https://applecommander.github.io/">. +The default load address is $1903. + + + +<sect>Platform-specific header files<p> + +Programs containing Agat-specific code may use the <tt/agat.h/ or +<tt/agat.inc/ include files. + +<sect>Usefull info<p> + +<sect1>Emulation<p> + +<enum> +<item> Oleg Odintsov's Agat Emulator - <url url="https://agatemulator.sourceforge.net/english.html"> +<item> MAME - <url url="https://www.mamedev.org/"> +</enum> + +<sect1>Links<p> +<enum> +<item> Most informative source on Agat (in russian) - <url url="https://agatcomp.ru"> +<item> Wikipedia - <url url="https://en.wikipedia.org/wiki/Agat_(computer)"> +<item> Controversial article on Agat from <url name="BYTE Magazine November 1984 Vol. 9, No. 12" url="https://archive.org/details/byte-magazine-1984-11/page/n135/mode/2up?view=theater">. +The author reviewed custom-build mockup Agat bearing little relation to even the early Agat systems. +</enum> + + +<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/index.sgml b/doc/index.sgml index 92df5e018..e39fd11b4 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -109,6 +109,9 @@ <descrip> + <tag><htmlurl url="agat.html" name="agat.html"></tag> + Topics specific to the Agat machines. + <tag><htmlurl url="apple2.html" name="apple2.html"></tag> Topics specific to the Apple ][. From fb421d7a81e3cc89f17f26e50621a3382864626f Mon Sep 17 00:00:00 2001 From: Konstantin <sintechs@gmail.com> Date: Sun, 8 Jun 2025 23:44:51 +0300 Subject: [PATCH 08/18] Remove dangling spaces --- doc/agat.sgml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/agat.sgml b/doc/agat.sgml index 1238dd394..ca5338c5f 100644 --- a/doc/agat.sgml +++ b/doc/agat.sgml @@ -18,16 +18,16 @@ compiler. <sect>Overview -<p>The Agat was a series of 8-bit computers produced in the Soviet Union from 1983 to 1993. +<p>The Agat was a series of 8-bit computers produced in the Soviet Union from 1983 to 1993. It was based on Apple II architecture with all electronic components made in the Soviet Union except for 6502 microprocessors supplied by UMC (UM6502A). -<p>If compared to Apple II, Agat had many improvements such as color text mode, additional graphic modes and flexible memory controller. +<p>If compared to Apple II, Agat had many improvements such as color text mode, additional graphic modes and flexible memory controller. Agat-7 had an Apple II compatibility card called "Module 121", while Agat-9 had a built-in Apple II+ mode activated by soft-switch. -<p>All mass-produced Agat models were disk-based systems, 2K ROM contained only basic machine language monitor and disassembler. +<p>All mass-produced Agat models were disk-based systems, 2K ROM contained only basic machine language monitor and disassembler. Agat-7 had 140K floppy-drive based on Apple DISK II, while Agat-9 was supplied with 840K drive having its own sector format and controller. <sect>Binary format<p> -The standard binary file format generated by the linker for the Agat target is +The standard binary file format generated by the linker for the Agat target is an AppleSingle file to be compatible with AppleCommander <url url="https://applecommander.github.io/">. The default load address is $1903. From d368f3d0ea3e93ddd7933831932f3f068926fb7f Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 9 Jun 2025 18:26:41 +0200 Subject: [PATCH 09/18] simple script(s) to check if bsearch tables are sorted correctly --- .github/checks/Makefile | 12 +++- .github/checks/sorted.sh | 117 +++++++++++++++++++++++++++++++ .github/checks/sorted_codeopt.sh | 42 +++++++++++ Makefile | 1 + 4 files changed, 170 insertions(+), 2 deletions(-) create mode 100755 .github/checks/sorted.sh create mode 100755 .github/checks/sorted_codeopt.sh diff --git a/.github/checks/Makefile b/.github/checks/Makefile index 93eeddd19..8245958c1 100644 --- a/.github/checks/Makefile +++ b/.github/checks/Makefile @@ -5,14 +5,18 @@ endif ifdef CMD_EXE -.PHONY: checkstyle +.PHONY: checkstyle sorted checkstyle: $(info INFO: style checks require bash.) +sorted: + $(info INFO: table checks require bash.) else -.PHONY: checkstyle lineendings tabs lastline spaces noexec +.PHONY: checkstyle lineendings tabs lastline spaces noexec sorted + +all: checkstyle sorted checkstyle: lineendings tabs lastline spaces noexec @@ -31,4 +35,8 @@ spaces: spaces.sh noexec: noexec.sh @./noexec.sh +sorted: sorted.sh sorted_codeopt.sh + @./sorted.sh + @./sorted_codeopt.sh + endif diff --git a/.github/checks/sorted.sh b/.github/checks/sorted.sh new file mode 100755 index 000000000..4311225cd --- /dev/null +++ b/.github/checks/sorted.sh @@ -0,0 +1,117 @@ +#! /bin/bash +OLDCWD=`pwd` +SCRIPT_PATH=`dirname $0` + +SORT_OPT=-u + +function checkarray_quoted_name +{ + CHECK_FILE="$1" + + awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \ + sed -e 's:.*\"\(.*\)\".*:\1:g' | \ + sed '/^\s*$/d' > .a.tmp + + if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then + echo "error: "$2" table is empty" + exit -1 + fi + + LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp + + if cmp --silent -- .a.tmp .b.tmp; then + echo ""$2" definitions OK" + else + echo "error: "$2" definitions are not sorted." + diff -y .a.tmp .b.tmp + exit -1 + fi + rm -rf .a.tmp .b.tmp +} + +function checkinstr_quoted_name +{ + CHECK_FILE="$1" + + awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \ + sed -e 's:^ *{$::g' | \ + sed -e 's:^ *}$::g' | \ + sed -e 's:.*\"\(.*\)\".*:\1:g' | \ + sed '/^\s*$/d' > .a.tmp + + if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then + echo "error: "$2" table is empty" + exit -1 + fi + + LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp + + if cmp --silent -- .a.tmp .b.tmp; then + echo ""$2" definitions OK" + else + echo "error: "$2" definitions are not sorted." + diff -y .a.tmp .b.tmp + exit -1 + fi + rm -rf .a.tmp .b.tmp +} + +function checkopcodes_quoted_name +{ + CHECK_FILE="$1" + + awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \ + grep "^ *\".*\"," | \ + sed '/^\s*$/d' > .a.tmp + + if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then + echo "error: "$2" table is empty" + exit -1 + fi + + LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp + + if cmp --silent -- .a.tmp .b.tmp; then + echo ""$2" definitions OK" + else + echo "error: "$2" definitions are not sorted." + diff -y .a.tmp .b.tmp + exit -1 + fi + rm -rf .a.tmp .b.tmp +} + +checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502\.Ins\) \/ sizeof \(InsTab6502\.Ins\[0\]\)," +checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502X\.Ins\) \/ sizeof \(InsTab6502X\.Ins\[0\]\)," +checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502DTV\.Ins\) \/ sizeof \(InsTab6502DTV\.Ins\[0\]\)," +checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab65C02\.Ins\) \/ sizeof \(InsTab65C02\.Ins\[0\]\)," +checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab4510\.Ins\) \/ sizeof \(InsTab4510\.Ins\[0\]\)," +checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab65816\.Ins\) \/ sizeof \(InsTab65816\.Ins\[0\]\)," +checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTabSweet16\.Ins\) \/ sizeof \(InsTabSweet16\.Ins\[0\]\)," +checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTabHuC6280\.Ins\) \/ sizeof \(InsTabHuC6280\.Ins\[0\]\)," + +checkarray_quoted_name ../../src/ca65/scanner.c "} DotKeywords \[\] = {" + +checkarray_quoted_name ../../src/cc65/codeinfo.c "static const FuncInfo FuncInfoTable\[\]" +checkarray_quoted_name ../../src/cc65/codeinfo.c "static const ZPInfo ZPInfoTable\[\]" +checkarray_quoted_name ../../src/cc65/codeoptutil.c "static const char\* const Tab\[\]" + +checkarray_quoted_name ../../src/cc65/coptstop.c "static const OptFuncDesc FuncTable\[\]" +checkarray_quoted_name ../../src/cc65/coptstop.c "static const OptFuncDesc FuncRegATable\[\]" + +checkopcodes_quoted_name ../../src/cc65/opcodes.c "const OPCDesc OPCTable\[OP65_COUNT\] = {" +checkarray_quoted_name ../../src/cc65/pragma.c "} Pragmas\[\] = {" +checkarray_quoted_name ../../src/cc65/preproc.c "} PPDTypes\[\] = {" +checkarray_quoted_name ../../src/cc65/scanner.c "} Keywords \[\] = {" +checkarray_quoted_name ../../src/cc65/stdfunc.c "} StdFuncs\[\] = {" + +checkarray_quoted_name ../../src/common/filetype.c "static const FileId TypeTable\[\]" +checkarray_quoted_name ../../src/common/target.c "static const TargetEntry TargetMap\[\]" + +checkarray_quoted_name ../../src/dbginfo/dbginfo.c "} KeywordTable\[\] = {" + +checkarray_quoted_name ../../src/sp65/convert.c "static const ConverterMapEntry ConverterMap\[\]" +checkarray_quoted_name ../../src/sp65/input.c "static const FileId FormatTable\[\]" +checkarray_quoted_name ../../src/sp65/output.c "static const FileId FormatTable\[\]" +checkarray_quoted_name ../../src/sp65/palconv.c "static const PaletteMapEntry PaletteMap\[\]" + diff --git a/.github/checks/sorted_codeopt.sh b/.github/checks/sorted_codeopt.sh new file mode 100755 index 000000000..a248ebc07 --- /dev/null +++ b/.github/checks/sorted_codeopt.sh @@ -0,0 +1,42 @@ +#! /bin/bash +OLDCWD=`pwd` +SCRIPT_PATH=`dirname $0` +CHECK_FILE=../../src/cc65/codeopt.c + +SORT_OPT=-u + +grep "^static OptFunc " $CHECK_FILE | \ + sed -e 's:.*"\(.*\)",.*:\1:g' > .a.tmp + +if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then + echo "error: OptFunc table is empty" + exit -1 +fi + +LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp + +if cmp --silent -- .a.tmp .b.tmp; then + echo "static OptFunc definitions OK" +else + echo "error: static OptFunc definitions are not sorted." + diff -y .a.tmp .b.tmp + exit -1 +fi + +awk '/static OptFunc\* OptFuncs\[\] = {/{flag=1;next}/}/{flag=0}flag' $CHECK_FILE | \ + sed -e 's:.*&D\(.*\),:\1:g' > .a.tmp + +if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then + echo "error: OptFuncs table is empty" + exit -1 +fi + +if cmp --silent -- .a.tmp .b.tmp; then + echo "static OptFuncs* OptFuncs[] definitions OK" +else + echo "error: static OptFuncs* OptFuncs[] definitions are not sorted." + diff -y .a.tmp .b.tmp + exit -1 +fi + +rm -rf .a.tmp .b.tmp diff --git a/Makefile b/Makefile index 29fcbbf96..edfd8166c 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,7 @@ test: # GNU "check" target, which runs all tests check: @$(MAKE) -C .github/checks checkstyle --no-print-directory + @$(MAKE) -C .github/checks sorted --no-print-directory @$(MAKE) test @$(MAKE) -C targettest platforms --no-print-directory @$(MAKE) -C samples platforms --no-print-directory From 58ff844d04361332d3d37886eb11e3ceebc6d1a5 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 9 Jun 2025 18:42:52 +0200 Subject: [PATCH 10/18] add to GHA --- .github/workflows/build-on-pull-request.yml | 3 +++ .github/workflows/snapshot-on-push-master.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index 7b762844b..3cb628529 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -24,6 +24,9 @@ jobs: - name: Do some simple style checks shell: bash run: make -j2 checkstyle + - name: Check bsearch tables + shell: bash + run: make -j2 sorted - name: Build the tools. shell: bash run: make -j2 bin USER_CFLAGS=-Werror diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 42794f10b..557ba24af 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -49,6 +49,9 @@ jobs: - name: Do some simple style checks shell: bash run: make -j2 checkstyle + - name: Check bsearch tables + shell: bash + run: make -j2 sorted - name: Build the tools. shell: bash run: | From 717e32ba6aab6f6eecfb87aa0b287efd4cc52dd1 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 9 Jun 2025 18:45:52 +0200 Subject: [PATCH 11/18] add "sorted" target --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index edfd8166c..0a12490fc 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,11 @@ util: # check the code style checkstyle: - @$(MAKE) -C .github/checks --no-print-directory $@ + @$(MAKE) -C .github/checks --no-print-directory $@ + +# check bsearch tables +sorted: + @$(MAKE) -C .github/checks --no-print-directory $@ # runs regression tests, requires libtest target libraries test: From 1e80269c6b22371927a35ae19803f0b30be261e5 Mon Sep 17 00:00:00 2001 From: Konstantin <sintechs@gmail.com> Date: Mon, 9 Jun 2025 21:14:01 +0300 Subject: [PATCH 12/18] Add comment about why AppleSingle header is needed --- libsrc/agat/exehdr.s | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libsrc/agat/exehdr.s b/libsrc/agat/exehdr.s index 72ea390e9..3f3047bf9 100644 --- a/libsrc/agat/exehdr.s +++ b/libsrc/agat/exehdr.s @@ -4,6 +4,9 @@ ; This module supplies an AppleSingle version 2 file header + entry with ; ID 11 according to https://tools.ietf.org/rfc/rfc1740.txt Appendix A. ; +; Agat target uses this header only for compatibility with Apple Commander +; because Agat's 140K disk filesystem is identical to Apple II DOS 3.3 and +; "ac.jar -as" option can be used to import binaries into disk images. .export __EXEHDR__ : absolute = 1 ; Linker referenced .import __FILETYPE__ ; Linker generated From 9afe980124a6ffe349664aa14e7413de1df80166 Mon Sep 17 00:00:00 2001 From: Konstantin <sintechs@gmail.com> Date: Mon, 9 Jun 2025 21:17:47 +0300 Subject: [PATCH 13/18] Add dash for naming consistency --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c1003179..891c31e86 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ the [cc65 web site](https://cc65.github.io): | Dr. Jozo Dujmović | Picocomputer (RP6502) | | Watara | Watura/QuickShot Supervision | | Synertek | SYM-1 | -| USSR | Agat 7/9 | +| USSR | Agat-7/9 | A generic configuration to adapt cc65 to new targets is also around. From aaa1058d32fbb9a67fed7d707fe03fd37304f731 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 9 Jun 2025 21:48:20 +0200 Subject: [PATCH 14/18] use explicit markers (comments) for the bsearch table checking, simplifies the scripts and makes them more robust too :) --- .github/checks/Makefile | 3 +- .github/checks/sorted.sh | 105 +++++-------------------------- .github/checks/sorted_codeopt.sh | 77 ++++++++++++++--------- .github/checks/sorted_opcodes.sh | 42 +++++++++++++ src/ca65/instr.c | 18 ++++++ src/ca65/scanner.c | 2 + src/cc65/codeinfo.c | 4 ++ src/cc65/codeopt.c | 4 ++ src/cc65/codeoptutil.c | 2 + src/cc65/coptstop.c | 4 ++ src/cc65/opcodes.c | 3 + src/cc65/pragma.c | 2 + src/cc65/preproc.c | 2 + src/cc65/scanner.c | 2 + src/cc65/stdfunc.c | 2 + src/common/filetype.c | 3 +- src/common/target.c | 2 + src/dbginfo/dbginfo.c | 2 + src/sp65/convert.c | 2 + src/sp65/input.c | 3 +- src/sp65/output.c | 3 +- src/sp65/palconv.c | 2 + 22 files changed, 165 insertions(+), 124 deletions(-) create mode 100755 .github/checks/sorted_opcodes.sh diff --git a/.github/checks/Makefile b/.github/checks/Makefile index 8245958c1..ee373d53d 100644 --- a/.github/checks/Makefile +++ b/.github/checks/Makefile @@ -35,8 +35,9 @@ spaces: spaces.sh noexec: noexec.sh @./noexec.sh -sorted: sorted.sh sorted_codeopt.sh +sorted: sorted.sh sorted_codeopt.sh sorted_opcodes.sh @./sorted.sh @./sorted_codeopt.sh + @./sorted_opcodes.sh endif diff --git a/.github/checks/sorted.sh b/.github/checks/sorted.sh index 4311225cd..58d82ed67 100755 --- a/.github/checks/sorted.sh +++ b/.github/checks/sorted.sh @@ -2,116 +2,39 @@ OLDCWD=`pwd` SCRIPT_PATH=`dirname $0` +CHECK_DIR=../../src + SORT_OPT=-u function checkarray_quoted_name { CHECK_FILE="$1" + START="\\/\\* BEGIN SORTED.SH \\*\\/" + END="\\/\\* END SORTED.SH \\*\\/" - awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \ - sed -e 's:.*\"\(.*\)\".*:\1:g' | \ - sed '/^\s*$/d' > .a.tmp + awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {print count,"##",$0}' "$CHECK_FILE" | \ + sed -e 's:\(.*\) ##.*\"\(.*\)\".*:\1##\2:g' > .a.tmp if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then - echo "error: "$2" table is empty" + echo "error: "$1" table is empty" + rm -rf .a.tmp exit -1 fi LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp if cmp --silent -- .a.tmp .b.tmp; then - echo ""$2" definitions OK" + echo ""$1" tables OK" else - echo "error: "$2" definitions are not sorted." + echo "error: "$1" tables are not sorted." diff -y .a.tmp .b.tmp + rm -rf .a.tmp .b.tmp exit -1 fi rm -rf .a.tmp .b.tmp } -function checkinstr_quoted_name -{ - CHECK_FILE="$1" - - awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \ - sed -e 's:^ *{$::g' | \ - sed -e 's:^ *}$::g' | \ - sed -e 's:.*\"\(.*\)\".*:\1:g' | \ - sed '/^\s*$/d' > .a.tmp - - if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then - echo "error: "$2" table is empty" - exit -1 - fi - - LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp - - if cmp --silent -- .a.tmp .b.tmp; then - echo ""$2" definitions OK" - else - echo "error: "$2" definitions are not sorted." - diff -y .a.tmp .b.tmp - exit -1 - fi - rm -rf .a.tmp .b.tmp -} - -function checkopcodes_quoted_name -{ - CHECK_FILE="$1" - - awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \ - grep "^ *\".*\"," | \ - sed '/^\s*$/d' > .a.tmp - - if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then - echo "error: "$2" table is empty" - exit -1 - fi - - LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp - - if cmp --silent -- .a.tmp .b.tmp; then - echo ""$2" definitions OK" - else - echo "error: "$2" definitions are not sorted." - diff -y .a.tmp .b.tmp - exit -1 - fi - rm -rf .a.tmp .b.tmp -} - -checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502\.Ins\) \/ sizeof \(InsTab6502\.Ins\[0\]\)," -checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502X\.Ins\) \/ sizeof \(InsTab6502X\.Ins\[0\]\)," -checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502DTV\.Ins\) \/ sizeof \(InsTab6502DTV\.Ins\[0\]\)," -checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab65C02\.Ins\) \/ sizeof \(InsTab65C02\.Ins\[0\]\)," -checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab4510\.Ins\) \/ sizeof \(InsTab4510\.Ins\[0\]\)," -checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab65816\.Ins\) \/ sizeof \(InsTab65816\.Ins\[0\]\)," -checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTabSweet16\.Ins\) \/ sizeof \(InsTabSweet16\.Ins\[0\]\)," -checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTabHuC6280\.Ins\) \/ sizeof \(InsTabHuC6280\.Ins\[0\]\)," - -checkarray_quoted_name ../../src/ca65/scanner.c "} DotKeywords \[\] = {" - -checkarray_quoted_name ../../src/cc65/codeinfo.c "static const FuncInfo FuncInfoTable\[\]" -checkarray_quoted_name ../../src/cc65/codeinfo.c "static const ZPInfo ZPInfoTable\[\]" -checkarray_quoted_name ../../src/cc65/codeoptutil.c "static const char\* const Tab\[\]" - -checkarray_quoted_name ../../src/cc65/coptstop.c "static const OptFuncDesc FuncTable\[\]" -checkarray_quoted_name ../../src/cc65/coptstop.c "static const OptFuncDesc FuncRegATable\[\]" - -checkopcodes_quoted_name ../../src/cc65/opcodes.c "const OPCDesc OPCTable\[OP65_COUNT\] = {" -checkarray_quoted_name ../../src/cc65/pragma.c "} Pragmas\[\] = {" -checkarray_quoted_name ../../src/cc65/preproc.c "} PPDTypes\[\] = {" -checkarray_quoted_name ../../src/cc65/scanner.c "} Keywords \[\] = {" -checkarray_quoted_name ../../src/cc65/stdfunc.c "} StdFuncs\[\] = {" - -checkarray_quoted_name ../../src/common/filetype.c "static const FileId TypeTable\[\]" -checkarray_quoted_name ../../src/common/target.c "static const TargetEntry TargetMap\[\]" - -checkarray_quoted_name ../../src/dbginfo/dbginfo.c "} KeywordTable\[\] = {" - -checkarray_quoted_name ../../src/sp65/convert.c "static const ConverterMapEntry ConverterMap\[\]" -checkarray_quoted_name ../../src/sp65/input.c "static const FileId FormatTable\[\]" -checkarray_quoted_name ../../src/sp65/output.c "static const FileId FormatTable\[\]" -checkarray_quoted_name ../../src/sp65/palconv.c "static const PaletteMapEntry PaletteMap\[\]" +for N in `grep -rl "BEGIN SORTED.SH" "$CHECK_DIR"`; do + checkarray_quoted_name $N +done diff --git a/.github/checks/sorted_codeopt.sh b/.github/checks/sorted_codeopt.sh index a248ebc07..f15295990 100755 --- a/.github/checks/sorted_codeopt.sh +++ b/.github/checks/sorted_codeopt.sh @@ -1,42 +1,61 @@ #! /bin/bash OLDCWD=`pwd` SCRIPT_PATH=`dirname $0` -CHECK_FILE=../../src/cc65/codeopt.c + +CHECK_DIR=../../src SORT_OPT=-u -grep "^static OptFunc " $CHECK_FILE | \ - sed -e 's:.*"\(.*\)",.*:\1:g' > .a.tmp +function checkarray +{ + CHECK_FILE="$1" + START="\\/\\* BEGIN DECL SORTED_CODEOPT.SH \\*\\/" + END="\\/\\* END DECL SORTED_CODEOPT.SH \\*\\/" -if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then - echo "error: OptFunc table is empty" - exit -1 -fi + awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {print count,"##",$0}' "$CHECK_FILE" | \ + sed -e 's:\(.*##\).*"\(.*\)",.*:\1\2:g' > .a.tmp -LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp + if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then + echo "error: "$1" table is empty" + rm -rf .a.tmp + exit -1 + fi -if cmp --silent -- .a.tmp .b.tmp; then - echo "static OptFunc definitions OK" -else - echo "error: static OptFunc definitions are not sorted." - diff -y .a.tmp .b.tmp - exit -1 -fi + LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp -awk '/static OptFunc\* OptFuncs\[\] = {/{flag=1;next}/}/{flag=0}flag' $CHECK_FILE | \ - sed -e 's:.*&D\(.*\),:\1:g' > .a.tmp + if cmp --silent -- .a.tmp .b.tmp; then + echo ""$1" decls OK" + else + echo "error: "$1" decls are not sorted." + diff -y .a.tmp .b.tmp + rm -rf .a.tmp .b.tmp + exit -1 + fi -if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then - echo "error: OptFuncs table is empty" - exit -1 -fi + START="\\/\\* BEGIN SORTED_CODEOPT.SH \\*\\/" + END="\\/\\* END SORTED_CODEOPT.SH \\*\\/" + awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {print count,"##",$0}' "$CHECK_FILE" | \ + sed -e 's:\(.*##\).*&D\(.*\),.*:\1\2:g' > .a.tmp -if cmp --silent -- .a.tmp .b.tmp; then - echo "static OptFuncs* OptFuncs[] definitions OK" -else - echo "error: static OptFuncs* OptFuncs[] definitions are not sorted." - diff -y .a.tmp .b.tmp - exit -1 -fi + if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then + echo "error: "$1" table is empty" + rm -rf .a.tmp + exit -1 + fi -rm -rf .a.tmp .b.tmp + if cmp --silent -- .a.tmp .b.tmp; then + echo ""$1" tables OK" + else + echo "error: "$1" tables are not sorted." + diff -y .a.tmp .b.tmp + rm -rf .a.tmp .b.tmp + exit -1 + fi + + rm -rf .a.tmp .b.tmp +} + + +for N in `grep -rl "BEGIN DECL SORTED_CODEOPT.SH" "$CHECK_DIR"`; do + checkarray $N +done diff --git a/.github/checks/sorted_opcodes.sh b/.github/checks/sorted_opcodes.sh new file mode 100755 index 000000000..a1f8fcbfa --- /dev/null +++ b/.github/checks/sorted_opcodes.sh @@ -0,0 +1,42 @@ +#! /bin/bash +OLDCWD=`pwd` +SCRIPT_PATH=`dirname $0` + +CHECK_DIR=../../src + +SORT_OPT=-u + +function checkarray_quoted_name +{ + CHECK_FILE="$1" + START="\\/\\* BEGIN SORTED_OPCODES.SH \\*\\/" + END="\\/\\* END SORTED_OPCODES.SH \\*\\/" + + awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {print count,"##",$0}' "$CHECK_FILE" | \ + sed 's:/\*.*::g' | \ + grep '".*",' | \ + sed -e 's:\(.*\) ##.*\"\(.*\)\".*:\1##\2:g' > .a.tmp + + if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then + echo "error: "$1" table is empty" + rm -rf .a.tmp + exit -1 + fi + + LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp + + if cmp --silent -- .a.tmp .b.tmp; then + echo ""$1" tables OK" + else + echo "error: "$1" tables are not sorted." + diff -y .a.tmp .b.tmp + rm -rf .a.tmp .b.tmp + exit -1 + fi + rm -rf .a.tmp .b.tmp +} + +for N in `grep -rl "BEGIN SORTED_OPCODES.SH" "$CHECK_DIR"`; do + checkarray_quoted_name $N +done + diff --git a/src/ca65/instr.c b/src/ca65/instr.c index f1d8d706a..c7a68006c 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -172,6 +172,7 @@ static const struct { /* CAUTION: table must be sorted for bsearch */ sizeof (InsTab6502.Ins) / sizeof (InsTab6502.Ins[0]), { +/* BEGIN SORTED.SH */ { "ADC", 0x080A26C, 0x60, 0, PutAll }, { "AND", 0x080A26C, 0x20, 0, PutAll }, { "ASL", 0x000006e, 0x02, 1, PutAll }, @@ -228,6 +229,7 @@ static const struct { { "TXA", 0x0000001, 0x8a, 0, PutAll }, { "TXS", 0x0000001, 0x9a, 0, PutAll }, { "TYA", 0x0000001, 0x98, 0, PutAll } +/* END SORTED.SH */ } }; @@ -239,6 +241,7 @@ static const struct { /* CAUTION: table must be sorted for bsearch */ sizeof (InsTab6502X.Ins) / sizeof (InsTab6502X.Ins[0]), { +/* BEGIN SORTED.SH */ { "ADC", 0x080A26C, 0x60, 0, PutAll }, { "ALR", 0x0800000, 0x4B, 0, PutAll }, /* X */ { "ANC", 0x0800000, 0x0B, 0, PutAll }, /* X */ @@ -314,6 +317,7 @@ static const struct { { "TXA", 0x0000001, 0x8a, 0, PutAll }, { "TXS", 0x0000001, 0x9a, 0, PutAll }, { "TYA", 0x0000001, 0x98, 0, PutAll } +/* END SORTED.SH */ } }; @@ -329,6 +333,7 @@ static const struct { /* CAUTION: table must be sorted for bsearch */ sizeof (InsTab6502DTV.Ins) / sizeof (InsTab6502DTV.Ins[0]), { +/* BEGIN SORTED.SH */ { "ADC", 0x080A26C, 0x60, 0, PutAll }, { "ALR", 0x0800000, 0x4B, 0, PutAll }, /* X */ { "ANC", 0x0800000, 0x0B, 0, PutAll }, /* X */ @@ -400,6 +405,7 @@ static const struct { { "TXA", 0x0000001, 0x8a, 0, PutAll }, { "TXS", 0x0000001, 0x9a, 0, PutAll }, { "TYA", 0x0000001, 0x98, 0, PutAll } +/* END SORTED.SH */ } }; @@ -411,6 +417,7 @@ static const struct { /* CAUTION: table must be sorted for bsearch */ sizeof (InsTab65SC02.Ins) / sizeof (InsTab65SC02.Ins[0]), { +/* BEGIN SORTED.SH */ { "ADC", 0x080A66C, 0x60, 0, PutAll }, { "AND", 0x080A66C, 0x20, 0, PutAll }, { "ASL", 0x000006e, 0x02, 1, PutAll }, @@ -477,6 +484,7 @@ static const struct { { "TXA", 0x0000001, 0x8a, 0, PutAll }, { "TXS", 0x0000001, 0x9a, 0, PutAll }, { "TYA", 0x0000001, 0x98, 0, PutAll } +/* END SORTED.SH */ } }; @@ -488,6 +496,7 @@ static const struct { /* CAUTION: table must be sorted for bsearch */ sizeof (InsTab65C02.Ins) / sizeof (InsTab65C02.Ins[0]), { +/* BEGIN SORTED.SH */ { "ADC", 0x080A66C, 0x60, 0, PutAll }, { "AND", 0x080A66C, 0x20, 0, PutAll }, { "ASL", 0x000006e, 0x02, 1, PutAll }, @@ -588,6 +597,7 @@ static const struct { { "TXS", 0x0000001, 0x9a, 0, PutAll }, { "TYA", 0x0000001, 0x98, 0, PutAll }, { "WAI", 0x0000001, 0xcb, 0, PutAll } +/* END SORTED.SH */ } }; @@ -599,6 +609,7 @@ static const struct { /* CAUTION: table must be sorted for bsearch */ sizeof (InsTab4510.Ins) / sizeof (InsTab4510.Ins[0]), { +/* BEGIN SORTED.SH */ { "ADC", 0x080A66C, 0x60, 0, PutAll }, { "AND", 0x080A66C, 0x20, 0, PutAll }, { "ASL", 0x000006e, 0x02, 1, PutAll }, @@ -732,6 +743,7 @@ static const struct { { "TYA", 0x0000001, 0x98, 0, PutAll }, { "TYS", 0x0000001, 0x2b, 0, PutAll }, { "TZA", 0x0000001, 0x6b, 0, PutAll }, +/* END SORTED.SH */ } }; @@ -743,6 +755,7 @@ static const struct { /* CAUTION: table must be sorted for bsearch */ sizeof (InsTab65816.Ins) / sizeof (InsTab65816.Ins[0]), { +/* BEGIN SORTED.SH */ { "ADC", 0x0b8f6fc, 0x60, 0, PutAll }, { "AND", 0x0b8f6fc, 0x20, 0, PutAll }, { "ASL", 0x000006e, 0x02, 1, PutAll }, @@ -843,6 +856,7 @@ static const struct { { "WDM", 0x0800004, 0x42, 6, PutAll }, { "XBA", 0x0000001, 0xeb, 0, PutAll }, { "XCE", 0x0000001, 0xfb, 0, PutAll } +/* END SORTED.SH */ } }; @@ -854,6 +868,7 @@ static const struct { /* CAUTION: table must be sorted for bsearch */ sizeof (InsTabSweet16.Ins) / sizeof (InsTabSweet16.Ins[0]), { +/* BEGIN SORTED.SH */ { "ADD", AMSW16_REG, 0xA0, 0, PutSweet16 }, { "BC", AMSW16_BRA, 0x03, 0, PutSweet16Branch }, { "BK", AMSW16_IMP, 0x0A, 0, PutSweet16 }, @@ -880,6 +895,7 @@ static const struct { { "STD", AMSW16_IND, 0x70, 0, PutSweet16 }, { "STP", AMSW16_IND, 0x90, 0, PutSweet16 }, { "SUB", AMSW16_REG, 0xB0, 0, PutSweet16 }, +/* END SORTED.SH */ } }; @@ -891,6 +907,7 @@ static const struct { /* CAUTION: table must be sorted for bsearch */ sizeof (InsTabHuC6280.Ins) / sizeof (InsTabHuC6280.Ins[0]), { +/* BEGIN SORTED.SH */ { "ADC", 0x080A66C, 0x60, 0, PutAll }, { "AND", 0x080A66C, 0x20, 0, PutAll }, { "ASL", 0x000006e, 0x02, 1, PutAll }, @@ -1026,6 +1043,7 @@ static const struct { { "TXA", 0x0000001, 0x8a, 0, PutAll }, { "TXS", 0x0000001, 0x9a, 0, PutAll }, { "TYA", 0x0000001, 0x98, 0, PutAll } +/* END SORTED.SH */ } }; diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 11beb4d63..94c84d897 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -136,6 +136,7 @@ struct DotKeyword { const char* Key; /* MUST be first field */ token_t Tok; } DotKeywords [] = { +/* BEGIN SORTED.SH */ { ".A16", TOK_A16 }, { ".A8", TOK_A8 }, { ".ADDR", TOK_ADDR }, @@ -307,6 +308,7 @@ struct DotKeyword { { ".XMATCH", TOK_XMATCH }, { ".XOR", TOK_BOOLXOR }, { ".ZEROPAGE", TOK_ZEROPAGE }, +/* END SORTED.SH */ }; diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index 8396ecfd5..29f18cb78 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -92,6 +92,7 @@ struct FuncInfo { */ /* CAUTION: table must be sorted for bsearch */ static const FuncInfo FuncInfoTable[] = { +/* BEGIN SORTED.SH */ { "addeq0sp", SLV_TOP | REG_AX, PSTATE_ALL | REG_AXY }, { "addeqysp", SLV_IND | REG_AXY, PSTATE_ALL | REG_AXY }, { "addysp", REG_SP | REG_Y, PSTATE_ALL | REG_SP }, @@ -377,12 +378,14 @@ static const FuncInfo FuncInfoTable[] = { { "tosxoreax", SLV_TOP | REG_EAX, PSTATE_ALL | REG_SP | REG_EAXY | REG_TMP1 }, { "tsteax", REG_EAX, PSTATE_ALL | REG_Y }, { "utsteax", REG_EAX, PSTATE_ALL | REG_Y }, +/* END SORTED.SH */ }; #define FuncInfoCount (sizeof(FuncInfoTable) / sizeof(FuncInfoTable[0])) /* Table with names of zero page locations used by the compiler */ /* CAUTION: table must be sorted for bsearch */ static const ZPInfo ZPInfoTable[] = { +/* BEGIN SORTED.SH */ { 0, "ptr1", 2, REG_PTR1_LO, REG_PTR1 }, { 0, "ptr1+1", 1, REG_PTR1_HI, REG_PTR1 }, { 0, "ptr2", 2, REG_PTR2_LO, REG_PTR2 }, @@ -400,6 +403,7 @@ static const ZPInfo ZPInfoTable[] = { { 0, "tmp2", 1, REG_NONE, REG_NONE }, { 0, "tmp3", 1, REG_NONE, REG_NONE }, { 0, "tmp4", 1, REG_NONE, REG_NONE }, +/* END SORTED.SH */ }; #define ZPInfoCount (sizeof(ZPInfoTable) / sizeof(ZPInfoTable[0])) diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index 9de2ab7ba..c8d7d2ce9 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -103,6 +103,7 @@ struct OptFunc { /* A list of all the function descriptions */ /* CAUTION: should be sorted by "name" */ +/* BEGIN DECL SORTED_CODEOPT.SH */ static OptFunc DOpt65C02BitOps = { Opt65C02BitOps, "Opt65C02BitOps", 66, 0, 0, 0, 0, 0 }; static OptFunc DOpt65C02Ind = { Opt65C02Ind, "Opt65C02Ind", 100, 0, 0, 0, 0, 0 }; static OptFunc DOpt65C02Stores = { Opt65C02Stores, "Opt65C02Stores", 100, 0, 0, 0, 0, 0 }; @@ -215,11 +216,13 @@ static OptFunc DOptTransfers3 = { OptTransfers3, "OptTransfers3", 65, 0, static OptFunc DOptTransfers4 = { OptTransfers4, "OptTransfers4", 65, 0, 0, 0, 0, 0 }; static OptFunc DOptUnusedLoads = { OptUnusedLoads, "OptUnusedLoads", 0, 0, 0, 0, 0, 0 }; static OptFunc DOptUnusedStores = { OptUnusedStores, "OptUnusedStores", 0, 0, 0, 0, 0, 0 }; +/* END DECL SORTED_CODEOPT.SH */ /* Table containing all the steps in alphabetical order */ /* CAUTION: table must be sorted for bsearch */ static OptFunc* OptFuncs[] = { +/* BEGIN SORTED_CODEOPT.SH */ &DOpt65C02BitOps, &DOpt65C02Ind, &DOpt65C02Stores, @@ -332,6 +335,7 @@ static OptFunc* OptFuncs[] = { &DOptTransfers4, &DOptUnusedLoads, &DOptUnusedStores, +/* END SORTED_CODEOPT.SH */ }; #define OPTFUNC_COUNT (sizeof(OptFuncs) / sizeof(OptFuncs[0])) diff --git a/src/cc65/codeoptutil.c b/src/cc65/codeoptutil.c index c18ccf18b..7547ef5ba 100644 --- a/src/cc65/codeoptutil.c +++ b/src/cc65/codeoptutil.c @@ -1227,7 +1227,9 @@ static int CmpHarmless (const void* Key, const void* Entry) /* CAUTION: table must be sorted for bsearch */ static const char* const Tab[] = { +/* BEGIN SORTED.SH */ "_abs", +/* END SORTED.SH */ }; int HarmlessCall (const CodeEntry* E, int PushedBytes) diff --git a/src/cc65/coptstop.c b/src/cc65/coptstop.c index 90ab78c50..e5d686d1a 100644 --- a/src/cc65/coptstop.c +++ b/src/cc65/coptstop.c @@ -1466,6 +1466,7 @@ static unsigned Opt_a_tosxor (StackOpData* D) /* CAUTION: table must be sorted for bsearch */ static const OptFuncDesc FuncTable[] = { +/* BEGIN SORTED.SH */ { "___bzero", Opt___bzero, REG_NONE, OP_X_ZERO | OP_A_KNOWN }, { "staspidx", Opt_staspidx, REG_NONE, OP_NONE }, { "staxspidx", Opt_staxspidx, REG_AX, OP_NONE }, @@ -1486,10 +1487,12 @@ static const OptFuncDesc FuncTable[] = { { "tosuleax", Opt_tosuleax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "tosultax", Opt_tosultax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "tosxorax", Opt_tosxorax, REG_NONE, OP_NONE }, +/* END SORTED.SH */ }; /* CAUTION: table must be sorted for bsearch */ static const OptFuncDesc FuncRegATable[] = { +/* BEGIN SORTED.SH */ { "tosandax", Opt_a_tosand, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "toseqax", Opt_a_toseq, REG_NONE, OP_NONE }, { "tosgeax", Opt_a_tosuge, REG_NONE, OP_NONE }, @@ -1505,6 +1508,7 @@ static const OptFuncDesc FuncRegATable[] = { { "tosuleax", Opt_a_tosule, REG_NONE, OP_NONE }, { "tosultax", Opt_a_tosult, REG_NONE, OP_NONE }, { "tosxorax", Opt_a_tosxor, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, +/* END SORTED.SH */ }; #define FUNC_COUNT(Table) (sizeof(Table) / sizeof(Table[0])) diff --git a/src/cc65/opcodes.c b/src/cc65/opcodes.c index c591c4ea3..49363769e 100644 --- a/src/cc65/opcodes.c +++ b/src/cc65/opcodes.c @@ -59,6 +59,8 @@ const OPCDesc OPCTable[OP65_COUNT] = { /* 65XX opcodes */ + +/* BEGIN SORTED_OPCODES.SH */ { OP65_ADC, /* opcode */ "adc", /* mnemonic */ 0, /* size */ @@ -587,6 +589,7 @@ const OPCDesc OPCTable[OP65_COUNT] = { REG_Y, /* use */ REG_A | PSTATE_ZN /* chg */ }, +/* END SORTED_OPCODES.SH */ }; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 5de4c8dfc..c9fdefd9b 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -94,6 +94,7 @@ static const struct Pragma { const char* Key; /* Keyword */ pragma_t Tok; /* Token */ } Pragmas[] = { +/* BEGIN SORTED.SH */ { "align", PRAGMA_ALIGN }, { "allow-eager-inline", PRAGMA_ALLOW_EAGER_INLINE }, { "allow_eager_inline", PRAGMA_ALLOW_EAGER_INLINE }, @@ -128,6 +129,7 @@ static const struct Pragma { { "writable-strings", PRAGMA_WRITABLE_STRINGS }, { "writable_strings", PRAGMA_WRITABLE_STRINGS }, { "zpsym", PRAGMA_ZPSYM }, +/* END SORTED.SH */ }; #define PRAGMA_COUNT (sizeof (Pragmas) / sizeof (Pragmas[0])) diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index d70c28147..96fa565f2 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -221,6 +221,7 @@ static const struct PPDType { const char* Tok; /* Token */ ppdirective_t Type; /* Type */ } PPDTypes[] = { +/* BEGIN SORTED.SH */ { "define", PPD_DEFINE }, { "elif", PPD_ELIF }, { "else", PPD_ELSE }, @@ -234,6 +235,7 @@ static const struct PPDType { { "pragma", PPD_PRAGMA }, { "undef", PPD_UNDEF }, { "warning", PPD_WARNING }, +/* END SORTED.SH */ }; /* Number of preprocessor directive types */ diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 1549b51bd..dda857f07 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -93,6 +93,7 @@ static const struct Keyword { unsigned char Tok; /* The token */ unsigned char Std; /* Token supported in which standards? */ } Keywords [] = { +/* BEGIN SORTED.SH */ { "_Pragma", TOK_PRAGMA, TT_C89 | TT_C99 | TT_CC65 }, /* !! */ { "_Static_assert", TOK_STATIC_ASSERT, TT_CC65 }, /* C11 */ { "__AX__", TOK_AX, TT_C89 | TT_C99 | TT_CC65 }, @@ -146,6 +147,7 @@ static const struct Keyword { { "void", TOK_VOID, TT_C89 | TT_C99 | TT_CC65 }, { "volatile", TOK_VOLATILE, TT_C89 | TT_C99 | TT_CC65 }, { "while", TOK_WHILE, TT_C89 | TT_C99 | TT_CC65 }, +/* END SORTED.SH */ }; #define KEY_COUNT (sizeof (Keywords) / sizeof (Keywords [0])) diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 3bd3f3552..3f33cdcce 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -85,11 +85,13 @@ static struct StdFuncDesc { const char* Name; void (*Handler) (FuncDesc*, ExprDesc*); } StdFuncs[] = { +/* BEGIN SORTED.SH */ { "memcpy", StdFunc_memcpy }, { "memset", StdFunc_memset }, { "strcmp", StdFunc_strcmp }, { "strcpy", StdFunc_strcpy }, { "strlen", StdFunc_strlen }, +/* END SORTED.SH */ }; #define FUNC_COUNT (sizeof (StdFuncs) / sizeof (StdFuncs[0])) diff --git a/src/common/filetype.c b/src/common/filetype.c index 4aececa78..074f8800a 100644 --- a/src/common/filetype.c +++ b/src/common/filetype.c @@ -51,6 +51,7 @@ /* CAUTION: table must be sorted for bsearch */ static const FileId TypeTable[] = { /* Upper case stuff for obsolete operating systems */ +/* BEGIN SORTED.SH */ { "A", FILETYPE_LIB }, { "A65", FILETYPE_ASM }, { "ASM", FILETYPE_ASM }, @@ -66,7 +67,6 @@ static const FileId TypeTable[] = { { "S", FILETYPE_ASM }, { "SER", FILETYPE_O65 }, { "TGI", FILETYPE_O65 }, - { "a", FILETYPE_LIB }, { "a65", FILETYPE_ASM }, { "asm", FILETYPE_ASM }, @@ -82,6 +82,7 @@ static const FileId TypeTable[] = { { "s", FILETYPE_ASM }, { "ser", FILETYPE_O65 }, { "tgi", FILETYPE_O65 }, +/* END SORTED.SH */ }; #define FILETYPE_COUNT (sizeof (TypeTable) / sizeof (TypeTable[0])) diff --git a/src/common/target.c b/src/common/target.c index 18da67b00..24e9f4495 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -143,6 +143,7 @@ struct TargetEntry { ** CAUTION: must be alphabetically for bsearch(). */ static const TargetEntry TargetMap[] = { +/* BEGIN SORTED.SH */ { "apple2", TGT_APPLE2 }, { "apple2enh", TGT_APPLE2ENH }, { "atari", TGT_ATARI }, @@ -181,6 +182,7 @@ static const TargetEntry TargetMap[] = { { "sym1", TGT_SYM1 }, { "telestrat", TGT_TELESTRAT }, { "vic20", TGT_VIC20 }, +/* END SORTED.SH */ }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) diff --git a/src/dbginfo/dbginfo.c b/src/dbginfo/dbginfo.c index 4fe7a37ec..896043cb6 100644 --- a/src/dbginfo/dbginfo.c +++ b/src/dbginfo/dbginfo.c @@ -2531,6 +2531,7 @@ static void NextToken (InputData* D) const char Keyword[12]; Token Tok; } KeywordTable[] = { +/* BEGIN SORTED.SH */ { "abs", TOK_ABSOLUTE }, { "addrsize", TOK_ADDRSIZE }, { "auto", TOK_AUTO }, @@ -2579,6 +2580,7 @@ static void NextToken (InputData* D) { "var", TOK_VAR }, { "version", TOK_VERSION }, { "zp", TOK_ZEROPAGE }, +/* END SORTED.SH */ }; diff --git a/src/sp65/convert.c b/src/sp65/convert.c index 71c9d09a6..3ffdbab7d 100644 --- a/src/sp65/convert.c +++ b/src/sp65/convert.c @@ -64,12 +64,14 @@ struct ConverterMapEntry { /* Converter table */ /* CAUTION: table must be alphabetically sorted for bsearch */ static const ConverterMapEntry ConverterMap[] = { +/* BEGIN SORTED.SH */ { "geos-bitmap", GenGeosBitmap }, { "geos-icon", GenGeosIcon }, { "koala", GenKoala }, { "lynx-sprite", GenLynxSprite }, { "raw", GenRaw }, { "vic2-sprite", GenVic2Sprite }, +/* END SORTED.SH */ }; diff --git a/src/sp65/input.c b/src/sp65/input.c index 22cfb1678..ac3aeaf99 100644 --- a/src/sp65/input.c +++ b/src/sp65/input.c @@ -73,9 +73,10 @@ static InputFormatDesc InputFormatTable[ifCount] = { /* CAUTION: table must be alphabetically sorted for bsearch */ static const FileId FormatTable[] = { /* Upper case stuff for obsolete operating systems */ +/* BEGIN SORTED.SH */ { "PCX", ifPCX }, - { "pcx", ifPCX }, +/* END SORTED.SH */ }; diff --git a/src/sp65/output.c b/src/sp65/output.c index 8b569502b..0c8fa59a7 100644 --- a/src/sp65/output.c +++ b/src/sp65/output.c @@ -82,19 +82,20 @@ static OutputFormatDesc OutputFormatTable[ofCount] = { /* CAUTION: table must be alphabetically sorted for bsearch */ static const FileId FormatTable[] = { /* Upper case stuff for obsolete operating systems */ +/* BEGIN SORTED.SH */ { "A", ofAsm }, { "ASM", ofAsm }, { "BIN", ofBin }, { "C", ofC }, { "INC", ofAsm }, { "S", ofAsm }, - { "a", ofAsm }, { "asm", ofAsm }, { "bin", ofBin }, { "c", ofC }, { "inc", ofAsm }, { "s", ofAsm }, +/* END SORTED.SH */ }; diff --git a/src/sp65/palconv.c b/src/sp65/palconv.c index ff5891b99..42adb1b33 100644 --- a/src/sp65/palconv.c +++ b/src/sp65/palconv.c @@ -59,7 +59,9 @@ struct PaletteMapEntry { /* Converter table */ /* CAUTION: table must be alphabetically sorted for bsearch */ static const PaletteMapEntry PaletteMap[] = { +/* BEGIN SORTED.SH */ { "lynx-palette", GenLynxPalette }, +/* END SORTED.SH */ }; From d1def100ddfebe54eb2dd000b4f239646a805dbd Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 9 Jun 2025 22:28:19 +0200 Subject: [PATCH 15/18] use sort -c --- .github/checks/sorted.sh | 12 +++++------- .github/checks/sorted_codeopt.sh | 31 +++++++++++++++++++------------ .github/checks/sorted_opcodes.sh | 12 +++++------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.github/checks/sorted.sh b/.github/checks/sorted.sh index 58d82ed67..0a4a90db7 100755 --- a/.github/checks/sorted.sh +++ b/.github/checks/sorted.sh @@ -4,8 +4,9 @@ SCRIPT_PATH=`dirname $0` CHECK_DIR=../../src -SORT_OPT=-u +SORT_OPT="-u -c" +# $1: filename function checkarray_quoted_name { CHECK_FILE="$1" @@ -21,17 +22,14 @@ function checkarray_quoted_name exit -1 fi - LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp - - if cmp --silent -- .a.tmp .b.tmp; then + if `LC_COLLATE=C sort $SORT_OPT .a.tmp`; then echo ""$1" tables OK" else echo "error: "$1" tables are not sorted." - diff -y .a.tmp .b.tmp - rm -rf .a.tmp .b.tmp + rm -rf .a.tmp exit -1 fi - rm -rf .a.tmp .b.tmp + rm -rf .a.tmp } diff --git a/.github/checks/sorted_codeopt.sh b/.github/checks/sorted_codeopt.sh index f15295990..e90e32b4a 100755 --- a/.github/checks/sorted_codeopt.sh +++ b/.github/checks/sorted_codeopt.sh @@ -4,8 +4,9 @@ SCRIPT_PATH=`dirname $0` CHECK_DIR=../../src -SORT_OPT=-u +SORT_OPT="-u -c" +# $1: filename function checkarray { CHECK_FILE="$1" @@ -21,32 +22,38 @@ function checkarray exit -1 fi - LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp - - if cmp --silent -- .a.tmp .b.tmp; then - echo ""$1" decls OK" + if `LC_COLLATE=C sort $SORT_OPT .a.tmp`; then + echo ""$1" decls sorted." else echo "error: "$1" decls are not sorted." - diff -y .a.tmp .b.tmp - rm -rf .a.tmp .b.tmp + rm -rf .a.tmp exit -1 fi START="\\/\\* BEGIN SORTED_CODEOPT.SH \\*\\/" END="\\/\\* END SORTED_CODEOPT.SH \\*\\/" - awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {print count,"##",$0}' "$CHECK_FILE" | \ - sed -e 's:\(.*##\).*&D\(.*\),.*:\1\2:g' > .a.tmp - if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then + awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {print count,"##",$0}' "$CHECK_FILE" | \ + sed -e 's:\(.*##\).*&D\(.*\),.*:\1\2:g' > .b.tmp + + if [[ -z $(grep '[^[:space:]]' .b.tmp) ]] ; then echo "error: "$1" table is empty" - rm -rf .a.tmp + rm -rf .a.tmp .b.tmp + exit -1 + fi + + if `LC_COLLATE=C sort $SORT_OPT .b.tmp`; then + echo ""$1" tables sorted." + else + echo "error: "$1" tables are not sorted." + rm -rf .a.tmp .b.tmp exit -1 fi if cmp --silent -- .a.tmp .b.tmp; then echo ""$1" tables OK" else - echo "error: "$1" tables are not sorted." + echo "error: "$1" tables are different." diff -y .a.tmp .b.tmp rm -rf .a.tmp .b.tmp exit -1 diff --git a/.github/checks/sorted_opcodes.sh b/.github/checks/sorted_opcodes.sh index a1f8fcbfa..b18b841c8 100755 --- a/.github/checks/sorted_opcodes.sh +++ b/.github/checks/sorted_opcodes.sh @@ -4,8 +4,9 @@ SCRIPT_PATH=`dirname $0` CHECK_DIR=../../src -SORT_OPT=-u +SORT_OPT="-u -c" +# $1: filename function checkarray_quoted_name { CHECK_FILE="$1" @@ -23,17 +24,14 @@ function checkarray_quoted_name exit -1 fi - LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp - - if cmp --silent -- .a.tmp .b.tmp; then + if `LC_COLLATE=C sort $SORT_OPT .a.tmp`; then echo ""$1" tables OK" else echo "error: "$1" tables are not sorted." - diff -y .a.tmp .b.tmp - rm -rf .a.tmp .b.tmp + rm -rf .a.tmp exit -1 fi - rm -rf .a.tmp .b.tmp + rm -rf .a.tmp } for N in `grep -rl "BEGIN SORTED_OPCODES.SH" "$CHECK_DIR"`; do From c28bafa581b6f3b498b9f02868955bee8b4b7723 Mon Sep 17 00:00:00 2001 From: Konstantin <sintechs@gmail.com> Date: Fri, 13 Jun 2025 12:50:39 +0300 Subject: [PATCH 16/18] add chline, cvline functions --- include/agat.h | 9 +++++++-- libsrc/agat/chline.s | 33 +++++++++++++++++++++++++++++++++ libsrc/agat/cputc.s | 19 +++++++++++++++---- libsrc/agat/cvline.s | 29 +++++++++++++++++++++++++++++ libsrc/agat/home.s | 2 +- 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 libsrc/agat/chline.s create mode 100644 libsrc/agat/cvline.s diff --git a/include/agat.h b/include/agat.h index 2cdf24ae6..04ec16984 100644 --- a/include/agat.h +++ b/include/agat.h @@ -32,7 +32,12 @@ #define CH_CURS_UP 0x19 #define CH_CURS_DOWN 0x1A #define CH_ESC 0x1B - +#define CH_HLINE 0x1B +#define CH_VLINE 0x5C +#define CH_ULCORNER 0x10 +#define CH_URCORNER 0x12 +#define CH_LLCORNER 0x1D +#define CH_LRCORNER 0x1F /* Masks for joy_read */ #define JOY_UP_MASK 0x10 @@ -68,4 +73,4 @@ void rebootafterexit (void); /* End of agat.h */ -#endif //_AGAT_H +#endif diff --git a/libsrc/agat/chline.s b/libsrc/agat/chline.s new file mode 100644 index 000000000..bc95b2a16 --- /dev/null +++ b/libsrc/agat/chline.s @@ -0,0 +1,33 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; Colin Leroy-Mira, 26.05.2025 +; Konstantin Fedorov, 12.06.2025 +; +; void chlinexy (unsigned char x, unsigned char y, unsigned char length); +; void chline (unsigned char length); +; + + .export _chlinexy, _chline, chlinedirect + .import gotoxy, putchar + + .include "zeropage.inc" + +_chlinexy: + pha ; Save the length + jsr gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _chline + +_chline: + ldx #$1B ; horizontal line character + +chlinedirect: + stx tmp1 + cmp #$00 ; Is the length zero? + beq done ; Jump if done + sta tmp2 +: lda tmp1 ; Screen code + jsr putchar ; Direct output + dec tmp2 + bne :- +done: rts + diff --git a/libsrc/agat/cputc.s b/libsrc/agat/cputc.s index b8d99aaea..b82ce22e6 100644 --- a/libsrc/agat/cputc.s +++ b/libsrc/agat/cputc.s @@ -1,12 +1,13 @@ ; ; Oleg A. Odintsov, Moscow, 2024 +; Konstantin Fedorov, 12.06.2025 ; ; void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c); ; void __fastcall__ cputc (char c); ; .import COUT - .export _cputcxy, _cputc + .export _cputcxy, _cputc, newline, putchar,putchardirect .import gotoxy, VTABZ .include "agat.inc" @@ -15,20 +16,21 @@ _cputcxy: jsr gotoxy pla _cputc: - cmp #$0D + cmp #$0D ; Test for \r = carriage return bne notleft ldy #$00 sty CH rts notleft: - cmp #$0A + cmp #$0A ; Test for \n = line feed beq newline + putchar: ldy CH sta (BASL),Y iny lda TATTR - bmi wch + bmi wch ; Skip if t64 sta (BASL),Y iny wch: @@ -47,3 +49,12 @@ newline: : jmp VTABZ noend: rts + +putchardirect: + ldy CH + sta (BASL),Y + lda TATTR + bmi :+ + iny + sta (BASL),Y +: rts diff --git a/libsrc/agat/cvline.s b/libsrc/agat/cvline.s new file mode 100644 index 000000000..63c0d4daf --- /dev/null +++ b/libsrc/agat/cvline.s @@ -0,0 +1,29 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; Colin Leroy-Mira, 26.05.2025 +; Konstantin Fedorov, 12.06.2025 +; +; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); +; void cvline (unsigned char length); +; + + .export _cvlinexy, _cvline + .import gotoxy, putchardirect, newline + + .include "zeropage.inc" + +_cvlinexy: + pha ; Save the length + jsr gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cvline + +_cvline: + cmp #$00 ; Is the length zero? + beq done ; Jump if done + sta tmp2 +: lda #$5C ; vertical line character + jsr putchardirect ; Write, no cursor advance + jsr newline ; Advance cursor to next line + dec tmp2 + bne :- +done: rts diff --git a/libsrc/agat/home.s b/libsrc/agat/home.s index 5067a782a..a0434c9bb 100644 --- a/libsrc/agat/home.s +++ b/libsrc/agat/home.s @@ -11,5 +11,5 @@ HOME: lda #$8C - jsr COUT + jmp COUT rts From 8202b520b262cc0f27a4fa48eddc93e07d6d6042 Mon Sep 17 00:00:00 2001 From: Konstantin <sintechs@gmail.com> Date: Fri, 13 Jun 2025 12:51:41 +0300 Subject: [PATCH 17/18] add Agat to samples --- include/target.h | 2 ++ libsrc/agat/_scrsize.s | 12 +++++++++--- samples/Makefile | 6 ++++++ samples/sieve.c | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/target.h b/include/target.h index 7663a39dd..5f9d8859c 100644 --- a/include/target.h +++ b/include/target.h @@ -37,6 +37,8 @@ # include <apple2enh.h> #elif defined(__APPLE2__) # include <apple2.h> +#elif defined(__AGAT__) +# include <agat.h> #elif defined(__ATARI__) # include <atari.h> #elif defined(__ATARI2600__) diff --git a/libsrc/agat/_scrsize.s b/libsrc/agat/_scrsize.s index f9d7c3785..09d7e879f 100644 --- a/libsrc/agat/_scrsize.s +++ b/libsrc/agat/_scrsize.s @@ -1,5 +1,6 @@ ; ; Ullrich von Bassewitz, 26.10.2000 +; Konstantin Fedorov, 12.06.2025 ; ; Screen size variables ; @@ -9,9 +10,14 @@ .include "agat.inc" screensize: - ldx WNDWDTH - lda WNDBTM + lda WNDWDTH + bit TATTR + bmi t64 + lsr +t64: + tax + lda WNDBTM sec - sbc WNDTOP + sbc WNDTOP tay rts diff --git a/samples/Makefile b/samples/Makefile index 3680f542c..295b6883d 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -158,6 +158,11 @@ DIRLIST = tutorial geos atari2600 atari5200 apple2 gamate lynx supervision sym1 # -------------------------------------------------------------------------- # Lists of executables +EXELIST_agat = \ + ascii \ + checkversion \ + hello \ + sieve EXELIST_apple2 = \ ascii \ @@ -390,6 +395,7 @@ all: # -------------------------------------------------------------------------- # List of every supported platform TARGETS := \ + agat \ apple2 \ apple2enh \ atari \ diff --git a/samples/sieve.c b/samples/sieve.c index 7c3b9cd75..5ffc97b62 100644 --- a/samples/sieve.c +++ b/samples/sieve.c @@ -12,7 +12,7 @@ /* Workaround missing clock stuff */ -#ifdef __APPLE2__ +#if defined(__APPLE2__) || defined(__AGAT__) # define clock() 0 # define CLOCKS_PER_SEC 1 #endif From 215f51a23033f68e5b23d1839fec8d13eb588985 Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira <colin@colino.net> Date: Fri, 13 Jun 2025 13:55:05 +0200 Subject: [PATCH 18/18] Fix temporary filenames again. Outputting temp files in the output directory means we have to distinguish source files in different source directories that happen to have the same name. --- src/common/fname.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/fname.c b/src/common/fname.c index d835ee7a0..7c52869e2 100644 --- a/src/common/fname.c +++ b/src/common/fname.c @@ -156,15 +156,22 @@ char* MakeTmpFilename (const char *Directory, const char *Origin, const char* Ex { char* Out; size_t Len = 0; + static unsigned int Counter = 0; - /* Allocate template */ + /* Allocate enough for the directory, ... */ if (Directory != NULL) { Len = strlen (Directory); } - Len += strlen (Origin) + strlen (".2147483648") + strlen (Ext) + 1; + + /* ... plus the the original name, the maximum length of the PID, the + * maximum length of the counter, the extension, and the terminator. + */ + Len += strlen (Origin) + (strlen (".2147483648") * 2) + strlen (Ext) + 1; Out = xmalloc (Len); - snprintf (Out, Len, "%s%s.%u%s", (Directory != NULL ? Directory : ""), - FindName(Origin), getpid(), Ext); + snprintf (Out, Len, "%s%s.%u%u%s", (Directory != NULL ? Directory : ""), + FindName(Origin), getpid(), Counter, Ext); + Counter++; + return Out; }