├── .gitignore ├── test ├── bench │ ├── empty.bas │ ├── BS.PRG │ ├── CC.PRG │ ├── RF1.PRG │ ├── RF2.PRG │ ├── RF3.PRG │ ├── RF4.PRG │ ├── RF5.PRG │ ├── RF6.PRG │ ├── RF7.PRG │ ├── RF8.PRG │ ├── EMPTY.PRG │ ├── rf1.bas │ ├── rf2.bas │ ├── rf3.bas │ ├── rf4.bas │ ├── rf8.bas │ ├── rf5.bas │ ├── rf6.bas │ ├── rf7.bas │ ├── cc.bas │ └── bs.bas ├── finh-sec-test-1.bas ├── finh-sec-test-2.bas ├── timer.bas ├── finh-sec-test-3.bas ├── fp │ └── README.md ├── date.bas ├── vpeek-vpoke.bas ├── clock.bas └── joystick.bas ├── geos ├── .gitignore ├── kernal │ ├── keyboard │ │ ├── keyboard2.s │ │ ├── keyboard1.s │ │ └── keyboard3.s │ ├── patterns │ │ └── patterns.s │ ├── bitmask │ │ ├── bitmask1.s │ │ ├── bitmask2.s │ │ └── bitmask3.s │ ├── ramexp │ │ ├── ramexp1.s │ │ └── ramexp2.s │ ├── hw │ │ ├── hw2.s │ │ ├── hw3.s │ │ ├── hw1a.s │ │ └── hw1b.s │ ├── init │ │ ├── init3.s │ │ └── init1.s │ ├── mouse │ │ ├── mouseptr.s │ │ ├── mouse3.s │ │ └── mouse1.s │ ├── header │ │ └── header.s │ ├── tobasic │ │ ├── tobasic1.s │ │ └── tobasic2.s │ ├── graph │ │ ├── graph2p.s │ │ ├── clrscr.s │ │ ├── inline.s │ │ ├── graph2l1.s │ │ └── pattern.s │ ├── time │ │ ├── time2.s │ │ └── time1.s │ ├── menu │ │ └── menu2.s │ ├── dlgbox │ │ ├── dlgbox1f.s │ │ └── dlgbox1e1.s │ ├── files │ │ ├── files2.s │ │ ├── files3.s │ │ ├── compat.s │ │ ├── files6b.s │ │ ├── files1a2a.s │ │ └── files7.s │ ├── reu │ │ └── reu.s │ ├── serial │ │ ├── serial1.s │ │ └── serial2.s │ ├── conio │ │ └── conio2.s │ ├── load │ │ ├── load1b.s │ │ ├── load1c.s │ │ └── load4b.s │ ├── memory │ │ └── memory3.s │ ├── math │ │ ├── dec.s │ │ ├── shr.s │ │ ├── shl.s │ │ ├── crc.s │ │ └── random.s │ ├── misc │ │ └── misc.s │ ├── mainloop │ │ └── mainloop.s │ └── rename.s └── inc │ ├── inputdrv.inc │ └── printdrv.inc ├── graphics ├── fonts │ ├── font_internal.inc │ ├── fonts4.s │ ├── fonts.inc │ ├── conio3b.s │ └── fonts4b.s ├── kernal_vectors.inc └── kernal.s ├── scpu-orig.bin ├── basic-orig.bin ├── codex ├── .gitignore ├── examples │ ├── HW.DBG │ ├── HW.DBI │ ├── HW.PRG │ ├── x16skel.dbg │ ├── x16skel.dbi │ ├── x16skel.prg │ ├── x16skel.txt │ └── HW.TXT ├── inc │ ├── kvars.inc │ ├── petsciitoscr.inc │ ├── edit.inc │ ├── decoder_vars.inc │ ├── dispatch_vars.inc │ ├── encode.inc │ ├── encode_vars.inc │ ├── utility.inc │ ├── bank_assy_vars.inc │ ├── fio.inc │ ├── dispatch.inc │ ├── screen_vars.inc │ ├── cx_vars.inc │ ├── meta.inc │ ├── dbgctrl.inc │ ├── meta_i.inc │ ├── cx_vecs.inc │ ├── bank.inc │ └── vera.inc ├── src │ ├── plugin-load.s │ ├── dispatch_vars.s │ ├── devrt0.s │ ├── encode_vars.s │ ├── decoder_vars.s │ ├── kernsup_cx.s │ ├── bank_assy_vars.s │ ├── screen_vars.s │ ├── cx_vecs.s │ ├── cx_vars.s │ └── vera.s └── cfg │ ├── utest.cfg │ ├── cx-dc.cfg │ ├── dev.cfg │ └── cx-plugin.cfg ├── keymap ├── asm │ ├── 405.bin.lzsa │ ├── 406.bin.lzsa │ ├── 407.bin.lzsa │ ├── 40A.bin.lzsa │ ├── 40B.bin.lzsa │ ├── 40C.bin.lzsa │ ├── 40E.bin.lzsa │ ├── 40F.bin.lzsa │ ├── 410.bin.lzsa │ ├── 411.bin.lzsa │ ├── 414.bin.lzsa │ ├── 415.bin.lzsa │ ├── 416.bin.lzsa │ ├── 41A.bin.lzsa │ ├── 41B.bin.lzsa │ ├── 41D.bin.lzsa │ ├── 424.bin.lzsa │ ├── 425.bin.lzsa │ ├── 426.bin.lzsa │ ├── 427.bin.lzsa │ ├── 807.bin.lzsa │ ├── 809.bin.lzsa │ ├── 80C.bin.lzsa │ ├── 816.bin.lzsa │ ├── 1009.bin.lzsa │ ├── 10409.bin.lzsa │ ├── 20409.bin.lzsa │ ├── 99409.bin.lzsa │ ├── 407.s │ ├── 20409.s │ ├── 406.s │ ├── 40A.s │ ├── 414.s │ ├── 809.s │ ├── 40B.s │ ├── 41D.s │ ├── 80C.s │ ├── 40C.s │ ├── 807.s │ ├── 416.s │ ├── 816.s │ ├── 40F.s │ ├── 1009.s │ ├── 410.s │ ├── 405.s │ ├── 425.s │ ├── 40E.s │ ├── 99409.s │ ├── 411.s │ ├── 41A.s │ ├── 424.s │ ├── 41B.s │ ├── 10409.s │ ├── 415.s │ ├── 426.s │ └── 427.s ├── klc │ ├── 807 Swiss German.klcpatch │ ├── 410 Italian.klcpatch │ ├── 41D Swedish.klcpatch │ ├── 416 Portuguese (Brazil ABNT).klcpatch │ ├── 80C Belgian French.klcpatch │ ├── 406 Danish.klcpatch │ ├── 40B Finnish.klcpatch │ ├── 414 Norwegian.klcpatch │ ├── 415 Polish (Programmers).klcpatch │ ├── 40C French.klcpatch │ ├── 40E Hungarian.klcpatch │ ├── 40A Spanish.klcpatch │ └── 409 US.klcpatch └── make_keytab_asm.sh ├── kernal ├── open-roms │ ├── assets │ │ ├── e8da.colour_codes.s │ │ └── fd30.vector_defaults.s │ ├── print │ │ ├── print_space.s │ │ ├── print_return.s │ │ ├── print_kernal_message.s │ │ └── print_hex_byte.s │ ├── screen │ │ ├── cursor_enable.s │ │ ├── chrout_screen_clr.s │ │ ├── chrout_screen_home.s │ │ ├── screen_check_space_ends_line.s │ │ ├── screen_calculate_pnt_user.s │ │ ├── chrout_screen_stop.s │ │ ├── chrout_screen_rvs.s │ │ ├── screen_get_cliped_pntr.s │ │ ├── chrout_screen_gfxtxt.s │ │ ├── chrout_screen_shift_onoff.s │ │ ├── screen.s │ │ ├── e56c.screen_calculate_pointers.s │ │ ├── screen_advance_to_next_line.s │ │ ├── e566.cursor_home.s │ │ ├── chrout_screen_quote.s │ │ ├── screen_code_to_petscii.s │ │ ├── screen_get_logical_line_end_ptr.s │ │ ├── e544.clear_screen.s │ │ ├── chrout_screen_return.s │ │ ├── chrout_screen_tab.s │ │ ├── cursor_show.s │ │ ├── e50a.plot.s │ │ ├── chrout_screen_crsr.s │ │ ├── screen_calculate_pntr_lnmx.s │ │ ├── e8ea.screen_scroll_up.s │ │ └── chrout_screen_control.s │ ├── iostack │ │ ├── f32f.clall.jmp.s │ │ ├── chkinout.s │ │ ├── setmsg.s │ │ ├── settmo.s │ │ ├── f13e.getin.s │ │ ├── findfls.s │ │ ├── setfls.s │ │ ├── setnam.s │ │ ├── f333.clrchn.s │ │ ├── getin_real.s │ │ ├── f5dd.save_prep.s │ │ ├── f49e.load_prep.s │ │ ├── f5ed.save.s │ │ ├── readst.s │ │ ├── clall_real.s │ │ ├── f4a5.load.s │ │ ├── f157.chrin.s │ │ └── f250.ckout.s │ ├── interrupts │ │ ├── ea31.default_irq_handler.s │ │ ├── ea7e.ack_cia1_return_from_interrupt.s │ │ ├── hw_entry_nmi.s │ │ ├── fe66.default_brk_handler.s │ │ ├── ea81.return_from_interrupt.s │ │ └── fe47.default_nmi_handler.s │ ├── init │ │ ├── ff5b.cint.s │ │ ├── e518.cint_legacy.s │ │ └── cint_screen_keyboard.s │ ├── memory │ │ ├── membot.s │ │ ├── fe25.memtop.s │ │ ├── fd15.restor.s │ │ └── vector_real.s │ ├── keyboard │ │ └── f6ed.stop.s │ └── LICENSE ├── drivers │ ├── c64 │ │ ├── sprites.s │ │ ├── rs232.s │ │ ├── mouse.s │ │ └── entropy.s │ └── x16 │ │ ├── beep.s │ │ ├── smc.s │ │ ├── rs232.s │ │ └── entropy.s ├── fonts │ └── font_internal.inc ├── cbm │ ├── nmi.s │ ├── init.s │ ├── channel │ │ ├── messages.s │ │ └── clall.s │ └── util.s └── graph │ ├── console.s │ └── graph.s ├── cfg ├── demo-x16.cfgtpl ├── charset-x16.cfgtpl ├── keymap-x16.cfgtpl ├── dos-x16.cfgtpl ├── graph.cfgtpl ├── basic-x16.cfgtpl ├── monitor-x16.cfgtpl └── codex-x16.cfgtpl ├── dos ├── file.inc ├── zeropage.s ├── fat32 │ ├── sdcard.inc │ ├── text_input.s │ └── text_input.inc ├── functions.inc └── jumptab.s ├── scripts ├── symbolize.sh ├── trace_lst.py ├── c64-create-e000.sh └── checksum.py ├── .travis.yml ├── kernsup ├── kernsup_basic.s └── kernsup_monitor.s ├── inc ├── fb.inc └── regs.inc ├── math ├── exports.s └── math.s ├── monitor └── kernal.i ├── basic └── basic.s └── .github └── workflows └── build.yml /.gitignore: -------------------------------------------------------------------------------- 1 | *.xcworkspace 2 | build 3 | -------------------------------------------------------------------------------- /test/bench/empty.bas: -------------------------------------------------------------------------------- 1 | 800 SYS 65535 2 | -------------------------------------------------------------------------------- /geos/.gitignore: -------------------------------------------------------------------------------- 1 | GEOS64.D64 2 | GEOS128.D64 3 | desktop.cvt 4 | build 5 | -------------------------------------------------------------------------------- /graphics/fonts/font_internal.inc: -------------------------------------------------------------------------------- 1 | .include "../../kernal/fonts/font_internal.inc" -------------------------------------------------------------------------------- /scpu-orig.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/scpu-orig.bin -------------------------------------------------------------------------------- /basic-orig.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/basic-orig.bin -------------------------------------------------------------------------------- /codex/.gitignore: -------------------------------------------------------------------------------- 1 | cx 2 | cx-dc 3 | cx-mii 4 | utest 5 | *.map 6 | *.sym 7 | *.l 8 | *.o 9 | -------------------------------------------------------------------------------- /test/bench/BS.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/BS.PRG -------------------------------------------------------------------------------- /test/bench/CC.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/CC.PRG -------------------------------------------------------------------------------- /test/bench/RF1.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/RF1.PRG -------------------------------------------------------------------------------- /test/bench/RF2.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/RF2.PRG -------------------------------------------------------------------------------- /test/bench/RF3.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/RF3.PRG -------------------------------------------------------------------------------- /test/bench/RF4.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/RF4.PRG -------------------------------------------------------------------------------- /test/bench/RF5.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/RF5.PRG -------------------------------------------------------------------------------- /test/bench/RF6.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/RF6.PRG -------------------------------------------------------------------------------- /test/bench/RF7.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/RF7.PRG -------------------------------------------------------------------------------- /test/bench/RF8.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/RF8.PRG -------------------------------------------------------------------------------- /codex/examples/HW.DBG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/codex/examples/HW.DBG -------------------------------------------------------------------------------- /codex/examples/HW.DBI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/codex/examples/HW.DBI -------------------------------------------------------------------------------- /codex/examples/HW.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/codex/examples/HW.PRG -------------------------------------------------------------------------------- /test/bench/EMPTY.PRG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/test/bench/EMPTY.PRG -------------------------------------------------------------------------------- /keymap/asm/405.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/405.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/406.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/406.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/407.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/407.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/40A.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/40A.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/40B.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/40B.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/40C.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/40C.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/40E.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/40E.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/40F.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/40F.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/410.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/410.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/411.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/411.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/414.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/414.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/415.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/415.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/416.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/416.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/41A.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/41A.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/41B.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/41B.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/41D.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/41D.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/424.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/424.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/425.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/425.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/426.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/426.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/427.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/427.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/807.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/807.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/809.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/809.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/80C.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/80C.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/816.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/816.bin.lzsa -------------------------------------------------------------------------------- /codex/examples/x16skel.dbg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/codex/examples/x16skel.dbg -------------------------------------------------------------------------------- /codex/examples/x16skel.dbi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/codex/examples/x16skel.dbi -------------------------------------------------------------------------------- /codex/examples/x16skel.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/codex/examples/x16skel.prg -------------------------------------------------------------------------------- /keymap/asm/1009.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/1009.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/10409.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/10409.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/20409.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/20409.bin.lzsa -------------------------------------------------------------------------------- /keymap/asm/99409.bin.lzsa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/commanderx16/x16-rom/HEAD/keymap/asm/99409.bin.lzsa -------------------------------------------------------------------------------- /test/bench/rf1.bas: -------------------------------------------------------------------------------- 1 | 300 PRINT"START" 2 | 400 FOR K=1 TO 1000 3 | 500 NEXT K 4 | 700 PRINT"END" 5 | 800 SYS 65535 6 | -------------------------------------------------------------------------------- /test/bench/rf2.bas: -------------------------------------------------------------------------------- 1 | 300 PRINT"START" 2 | 400 K=0 3 | 500 K=K+1 4 | 600 IF K<1000 THEN 500 5 | 700 PRINT"END" 6 | 800 SYS 65535 7 | -------------------------------------------------------------------------------- /test/bench/rf3.bas: -------------------------------------------------------------------------------- 1 | 300 PRINT"START" 2 | 400 K=0 3 | 500 K=K+1 4 | 510 LET A=K/K*K+K-K 5 | 600 IF K<1000 THEN 500 6 | 700 PRINT"END" 7 | 800 SYS 65535 8 | -------------------------------------------------------------------------------- /test/bench/rf4.bas: -------------------------------------------------------------------------------- 1 | 300 PRINT"START" 2 | 400 K=0 3 | 500 K=K+1 4 | 510 LET A=K/2*3+4-5 5 | 600 IF K<1000 THEN 500 6 | 700 PRINT"END" 7 | 800 SYS 65535 8 | -------------------------------------------------------------------------------- /keymap/klc/807 Swiss German.klcpatch: -------------------------------------------------------------------------------- 1 | // ^ -> ← 2 | // ° -> π 3 | 29 OEM_2 0 2190 03c0 -1 -1 // LEFTWARDS ARROW, GREEK SMALL LETTER PI, , 4 | -------------------------------------------------------------------------------- /keymap/klc/410 Italian.klcpatch: -------------------------------------------------------------------------------- 1 | // \ -> ← 2 | // | -> π 3 | 29 OEM_5 0 2190 03c0 -1 -1 -1 // LEFTWARDS ARROW, GREEK SMALL LETTER PI, , , 4 | -------------------------------------------------------------------------------- /keymap/klc/41D Swedish.klcpatch: -------------------------------------------------------------------------------- 1 | // § -> ← 2 | // ½ -> π 3 | 29 OEM_5 0 2190 03c0 -1 -1 -1 // LEFTWARDS ARROW, GREEK SMALL LETTER PI, , , 4 | -------------------------------------------------------------------------------- /keymap/klc/416 Portuguese (Brazil ABNT).klcpatch: -------------------------------------------------------------------------------- 1 | // \ -> ← 2 | // | -> π 3 | 56 OEM_102 0 2190 03c0 -1 -1 // LEFTWARDS ARROW, GREEK SMALL LETTER PI, , 4 | -------------------------------------------------------------------------------- /keymap/klc/80C Belgian French.klcpatch: -------------------------------------------------------------------------------- 1 | // ² -> ← 2 | // ³ -> π 3 | 29 OEM_7 0 2190 03c0 -1 -1 -1 // LEFTWARDS ARROW, GREEK SMALL LETTER PI, , , 4 | -------------------------------------------------------------------------------- /keymap/klc/406 Danish.klcpatch: -------------------------------------------------------------------------------- 1 | // ½ -> ← 2 | // § -> π 3 | 29 OEM_5 0 2190 03c0 001c -1 // LEFTWARDS ARROW, GREEK SMALL LETTER PI, INFORMATION SEPARATOR FOUR, 4 | -------------------------------------------------------------------------------- /keymap/klc/40B Finnish.klcpatch: -------------------------------------------------------------------------------- 1 | // § -> ← 2 | // ½ -> π 3 | 29 OEM_5 0 2190 03c0 001c -1 -1 // SECTION SIGN, VULGAR FRACTION ONE HALF, INFORMATION SEPARATOR FOUR, 4 | -------------------------------------------------------------------------------- /keymap/klc/414 Norwegian.klcpatch: -------------------------------------------------------------------------------- 1 | // | -> ← 2 | // § -> π 3 | 29 OEM_5 0 2190 03c0 001c -1 // LEFTWARDS ARROW, GREEK SMALL LETTER PI, INFORMATION SEPARATOR FOUR, 4 | -------------------------------------------------------------------------------- /test/bench/rf8.bas: -------------------------------------------------------------------------------- 1 | 300 PRINT"S" 2 | 400 K=0 3 | 500 K=K+1 4 | 530 A=K^2 5 | 540 B=LOG(K) 6 | 550 C=SIN(K) 7 | 600 IF K<1000 THEN GOTO 500 8 | 700 PRINT"E" 9 | 800 SYS 65535 10 | -------------------------------------------------------------------------------- /test/finh-sec-test-1.bas: -------------------------------------------------------------------------------- 1 | 100 REM TEST PROGRAM FOR ADDING "SEC" TO FINH 2 | 110 REM JEREMY DILATUSH 11 SEP 2021 3 | 120 : 4 | 200 GET A 5 | 210 IFA<>0THENPRINTA; 6 | 220 GOTO200 7 | -------------------------------------------------------------------------------- /kernal/open-roms/assets/e8da.colour_codes.s: -------------------------------------------------------------------------------- 1 | ; CHR$ codes for the 16 colours 2 | 3 | colour_codes: 4 | .byte 144,5,28,159,156,30,31,158 5 | .byte 129,149,150,151,152,153,154,155 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/bench/rf5.bas: -------------------------------------------------------------------------------- 1 | 300 PRINT"START" 2 | 400 K=0 3 | 500 K=K+1 4 | 510 LET A=K/2*3+4-5 5 | 520 GOSUB 820 6 | 600 IF K<1000 THEN 500 7 | 700 PRINT"END" 8 | 800 SYS 65535 9 | 820 RETURN 10 | -------------------------------------------------------------------------------- /geos/kernal/keyboard/keyboard2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; C64/C128 keyboard driver 5 | 6 | .segment "keyboard2" 7 | -------------------------------------------------------------------------------- /test/finh-sec-test-2.bas: -------------------------------------------------------------------------------- 1 | 100 REM TEST PROGRAM FOR ADDING "SEC" TO FINH 2 | 110 REM JEREMY DILATUSH 11 SEP 2021 3 | 120 : 4 | 200 INPUT A,B 5 | 210 PRINTA,B 6 | 220 IFA=-999THENSTOP 7 | 230 GOTO200 8 | -------------------------------------------------------------------------------- /cfg/demo-x16.cfgtpl: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | #include "x16.cfginc" 3 | 4 | DEMO: start = $1000, size = $4000, fill=yes, fillval=$AA; 5 | } 6 | 7 | SEGMENTS { 8 | DEMO: load = DEMO, type = ro; 9 | } 10 | -------------------------------------------------------------------------------- /geos/kernal/patterns/patterns.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Patterns 5 | 6 | .global PatternTab 7 | 8 | .segment "patterns" 9 | -------------------------------------------------------------------------------- /geos/kernal/bitmask/bitmask1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Common bitmasks 5 | 6 | .include "config.inc" 7 | 8 | .segment "bitmask1" 9 | -------------------------------------------------------------------------------- /geos/kernal/bitmask/bitmask2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Common bitmasks 5 | 6 | .include "config.inc" 7 | 8 | .segment "bitmask2" 9 | -------------------------------------------------------------------------------- /geos/kernal/bitmask/bitmask3.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Common bitmasks 5 | 6 | .include "config.inc" 7 | 8 | .segment "bitmask3" 9 | -------------------------------------------------------------------------------- /dos/file.inc: -------------------------------------------------------------------------------- 1 | .global file_open 2 | .global file_close 3 | .global file_second 4 | .global file_read 5 | .global file_write 6 | .global file_read_block 7 | 8 | .global set_errno_status 9 | .global convert_errno_status 10 | -------------------------------------------------------------------------------- /keymap/klc/415 Polish (Programmers).klcpatch: -------------------------------------------------------------------------------- 1 | // ` -> ← 2 | // ~ -> π 3 | 29 OEM_3 0 2190 03c0 -1 -1 -1 // LEFTWARDS ARROW, GREEK SMALL LETTER PI, , , 4 | // \ -> £ 5 | 2b OEM_5 0 00a3 -1 -1 -1 -1 // POUND SIGN, , 6 | -------------------------------------------------------------------------------- /test/bench/rf6.bas: -------------------------------------------------------------------------------- 1 | 300 PRINT"START" 2 | 400 K=0 3 | 430 DIM M(5) 4 | 500 K=K+1 5 | 510 LET A=K/2*3+4-5 6 | 520 GOSUB 820 7 | 530 FOR L=1 TO 5 8 | 540 NEXT L 9 | 600 IF K<1000 THEN 500 10 | 700 PRINT"END" 11 | 800 SYS 65535 12 | 820 RETURN 13 | -------------------------------------------------------------------------------- /keymap/klc/40C French.klcpatch: -------------------------------------------------------------------------------- 1 | // ² -> ← 2 | // (unassigned) -> π 3 | 29 OEM_7 0 2190 03c0 -1 -1 // LEFTWARDS ARROW, GREEK SMALL LETTER PI, , , 4 | // § -> £ 5 | 35 OEM_8 1 0021 00a3 -1 -1 // EXCLAMATION MARK, POUND SIGN, , 6 | -------------------------------------------------------------------------------- /cfg/charset-x16.cfgtpl: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | #include "x16.cfginc" 3 | 4 | BANK6: start = $C000, size = $4000, fill=yes, fillval=$AA; 5 | } 6 | 7 | SEGMENTS { 8 | CHARSET: load = BANK6, type = ro; 9 | CHARISO: load = BANK6, type = ro; 10 | } 11 | -------------------------------------------------------------------------------- /cfg/keymap-x16.cfgtpl: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | #include "x16.cfginc" 3 | 4 | KEYMAPS: start = $C000, size = $4000, fill=yes, fillval=$AA; 5 | } 6 | 7 | SEGMENTS { 8 | KBDMETA: load = KEYMAPS, type = ro; 9 | KBDTABLES: load = KEYMAPS, type = ro; 10 | } 11 | -------------------------------------------------------------------------------- /test/bench/rf7.bas: -------------------------------------------------------------------------------- 1 | 300 PRINT"START" 2 | 400 K=0 3 | 430 DIM M(5) 4 | 500 K=K+1 5 | 510 LET A=K/2*3+4-5 6 | 520 GOSUB 820 7 | 530 FOR L=1 TO 5 8 | 535 M(L)=A 9 | 540 NEXT L 10 | 600 IF K<1000 THEN 500 11 | 700 PRINT"END" 12 | 800 SYS 65535 13 | 820 RETURN 14 | -------------------------------------------------------------------------------- /codex/inc/kvars.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; VERA interface for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | K_TEXT_COLOR = $376 9 | 10 | -------------------------------------------------------------------------------- /kernal/open-roms/print/print_space.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Print the space character 7 | ; 8 | 9 | print_space: 10 | lda #$20 ; space code 11 | jmp JCHROUT 12 | -------------------------------------------------------------------------------- /kernal/open-roms/print/print_return.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Print the carriage return 7 | ; 8 | 9 | print_return: 10 | lda #$0D ; carriage return code 11 | jmp JCHROUT 12 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/cursor_enable.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Variables used: 7 | ; - BLNSW (cursor blink switch) 8 | ; 9 | 10 | 11 | cursor_enable: 12 | 13 | lda #$00 14 | sta BLNSW 15 | rts 16 | -------------------------------------------------------------------------------- /test/bench/cc.bas: -------------------------------------------------------------------------------- 1 | 10 REM Ahl's Simple Benchmark 2 | 20 FOR N=1 TO 100: A=N 3 | 30 FOR I=1 TO 10 4 | 40 A=SQR(A): R=R+RND(1) 5 | 50 NEXT I 6 | 60 FOR I=1 TO 10 7 | 70 A=A^2: R=R+RND(1) 8 | 80 NEXT I 9 | 90 S=S+A: NEXT N 10 | 100 PRINT ABS(1010-S/5) 11 | 110 PRINT ABS(1000-R) 12 | 120 SYS 65535 13 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_clr.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; CLR key handling within CHROUT 7 | ; 8 | 9 | 10 | chrout_screen_CLR: 11 | 12 | jsr clear_screen 13 | jmp chrout_screen_calc_lptr_done 14 | -------------------------------------------------------------------------------- /graphics/kernal_vectors.inc: -------------------------------------------------------------------------------- 1 | ;--------------------------------------------------------------- 2 | ; This file contains vectors in the Kernal ROM bank used by 3 | ; the graphic and fonts library 4 | ;--------------------------------------------------------------- 5 | 6 | ;Misc 7 | k_bsout = $FFD2 -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_home.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; HOME key handling within CHROUT 7 | ; 8 | 9 | 10 | chrout_screen_HOME: 11 | 12 | jsr cursor_home 13 | jmp chrout_screen_calc_lptr_done 14 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/screen_check_space_ends_line.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | screen_check_space_ends_line: 7 | 8 | jsr screen_get_logical_line_end_ptr 9 | 10 | jsr screen_get_char 11 | cmp #$20 12 | 13 | rts 14 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/f32f.clall.jmp.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | ; Our implementation is longer than the original one, 7 | ; placing it here would cause a collision with CLRCHN 8 | 9 | 10 | CLALL: 11 | jmp clall_real 12 | -------------------------------------------------------------------------------- /geos/kernal/ramexp/ramexp1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; 3 | ; C64 RAM expansion support by Maciej Witkowiak 4 | 5 | .include "const.inc" 6 | .include "geossym.inc" 7 | .include "geosmac.inc" 8 | .include "config.inc" 9 | .include "gkernal.inc" 10 | .include "c64.inc" 11 | 12 | .segment "ramexp1" 13 | 14 | -------------------------------------------------------------------------------- /geos/kernal/ramexp/ramexp2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; 3 | ; C64 RAM expansion support by Maciej Witkowiak 4 | 5 | .include "const.inc" 6 | .include "geossym.inc" 7 | .include "geosmac.inc" 8 | .include "config.inc" 9 | .include "gkernal.inc" 10 | .include "c64.inc" 11 | 12 | .segment "ramexp2" 13 | 14 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/screen_calculate_pnt_user.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Set pointers PNT and USER to current screen line 7 | ; 8 | 9 | 10 | screen_calculate_PNT_USER: 11 | 12 | ldx TBLX 13 | jmp screen_set_position 14 | -------------------------------------------------------------------------------- /keymap/klc/40E Hungarian.klcpatch: -------------------------------------------------------------------------------- 1 | // \ -> ← 2 | 10 Q 1 q Q -1 2190 // LATIN SMALL LETTER Q, LATIN CAPITAL LETTER Q, , LEFTWARDS ARROW 3 | // | -> π 4 | 11 W 1 w W -1 03c0 // LATIN SMALL LETTER W, LATIN CAPITAL LETTER W, , GREEK SMALL LETTER PI 5 | // § -> £ 6 | 29 0 0 0 00a3 -1 -1 // DIGIT ZERO, POUND SIGN, , 7 | -------------------------------------------------------------------------------- /geos/kernal/hw/hw2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Set CBM KERNAL vectors 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .segment "hw2" 14 | -------------------------------------------------------------------------------- /geos/kernal/hw/hw3.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; VIC initialization 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .segment "hw3" 14 | -------------------------------------------------------------------------------- /codex/inc/petsciitoscr.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; PETSCII utilities for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_PETSCII__ 9 | __X16_PETSCII__=1 10 | 11 | .import petscii_to_scr 12 | 13 | .endif 14 | -------------------------------------------------------------------------------- /geos/kernal/init/init3.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Machine initialization 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .segment "init3" 14 | -------------------------------------------------------------------------------- /codex/inc/edit.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Code block manipulation routines for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_EDIT__ 9 | __X16_EDIT__=1 10 | 11 | .import edit_insert, edit_delete 12 | 13 | .endif 14 | -------------------------------------------------------------------------------- /geos/kernal/mouse/mouseptr.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Mouse pointer image 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .segment "mouseptr" 14 | 15 | -------------------------------------------------------------------------------- /geos/kernal/header/header.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; KERNAL header and reboot from BASIC 5 | 6 | .include "const.inc" 7 | .include "config.inc" 8 | .include "geossym.inc" 9 | .include "geosmac.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .segment "header" 14 | 15 | -------------------------------------------------------------------------------- /geos/kernal/tobasic/tobasic1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; C64: Start a program in BASIC mode 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .segment "tobasic1" 14 | -------------------------------------------------------------------------------- /geos/kernal/graph/graph2p.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Graphics library: 480px width helper 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .segment "graph2p" 14 | 15 | -------------------------------------------------------------------------------- /test/timer.bas: -------------------------------------------------------------------------------- 1 | 0 REM--------------------------------------------------------------- 2 | 1 REM UNIT TEST FOR BASIC: 3 | 2 REM * TI ASSIGNMENT 4 | 3 REM * TI OVERFLOW 5 | 4 REM * TI PRINTING 6 | 6 REM--------------------------------------------------------------- 7 | 7 REM (C)2020 Michael Steil, License: 2-clause BSD 8 | 9 | 10 TI=16777210 10 | 20 PRINTTI;:GOTO20 11 | -------------------------------------------------------------------------------- /codex/inc/decoder_vars.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Assembly decoder vars for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_DECODER_VARS__ 9 | __X16_DECODER_VARS__=1 10 | 11 | .import decoded_str_next, code_buffer 12 | 13 | .endif 14 | -------------------------------------------------------------------------------- /kernal/open-roms/interrupts/ea31.default_irq_handler.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | default_irq_handler: 7 | 8 | jsr cursor_blink 9 | jsr JSCNKEY 10 | jsr JUDTIM ; update jiffy clock 11 | 12 | ; Acknowledge CIA interrupt and return 13 | jmp clear_cia1_interrupt_flag_and_return_from_interrupt 14 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_stop.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; STOP key handling within CHROUT 7 | ; 8 | 9 | 10 | .if CONFIG_EDIT_STOPQUOTE 11 | 12 | 13 | chrout_screen_STOP: 14 | 15 | lda #$00 16 | sta QTSW 17 | sta INSRT 18 | jmp chrout_screen_done 19 | 20 | 21 | .endif 22 | -------------------------------------------------------------------------------- /geos/kernal/time/time2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; C64/CIA clock driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global pingTab 14 | .global pingTabEnd 15 | 16 | .segment "time2" 17 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_rvs.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; RVS ON/OFF handling within CHROUT 7 | ; 8 | 9 | 10 | chrout_screen_RVS_ON: 11 | 12 | lda #$80 13 | bne l7 ; branch always 14 | 15 | chrout_screen_RVS_OFF: 16 | 17 | lda #$00 18 | l7: 19 | sta RVS 20 | jmp chrout_screen_done 21 | -------------------------------------------------------------------------------- /keymap/klc/40A Spanish.klcpatch: -------------------------------------------------------------------------------- 1 | // | -> π 2 | 02 1 0 1 0021 -1 03c0 // DIGIT ONE, EXCLAMATION MARK, , GREEK SMALL LETTER PI 3 | // \ -> ← 4 | 29 OEM_5 0 00ba 00aa -1 2190 // MASCULINE ORDINAL INDICATOR, FEMININE ORDINAL INDICATOR, , LEFTWARDS ARROW 5 | // (unassigned) -> £ 6 | 56 OEM_102 0 003c 003e 001c 00a3 // LESS-THAN SIGN, GREATER-THAN SIGN, INFORMATION SEPARATOR FOUR, POUND SIGN 7 | -------------------------------------------------------------------------------- /scripts/symbolize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "uint16_t addresses_bank$1[] = {" 4 | for i in $(cat $2 | sort | uniq | grep "^.....[ABCDEF]" | cut -c 6-9); do 5 | echo -n "0x$i, " 6 | done 7 | echo 8 | echo "};" 9 | 10 | echo "char *labels_bank$1[] = {" 11 | for i in $(cat $2 | sort | uniq | grep "^.....[ABCDEF]" | cut -c 12-); do 12 | echo -n "\"$i\", " 13 | done 14 | echo 15 | echo "};" 16 | -------------------------------------------------------------------------------- /codex/inc/dispatch_vars.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Dispatch module varss for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_DISPATCH_VARS__ 9 | __X16_DISPATCH_VARS__=1 10 | 11 | .import dispatch_vector, dispatch_current_table 12 | 13 | .endif 14 | 15 | -------------------------------------------------------------------------------- /codex/inc/encode.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Single line assemblers for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_ENCODE__ 9 | __X16_ENCODE__=1 10 | 11 | .import encode_string 12 | .import encode_parse_expression, encode_get_entry 13 | 14 | .endif 15 | -------------------------------------------------------------------------------- /geos/kernal/hw/hw1a.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; VIC initialization table 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global VIC_IniTbl 14 | .global VIC_IniTbl_end 15 | 16 | .segment "hw1a" 17 | -------------------------------------------------------------------------------- /kernal/open-roms/print/print_kernal_message.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Print one of the standard Kernal messages, index in .X 7 | ; 8 | 9 | l1: 10 | jsr JCHROUT 11 | inx 12 | 13 | print_kernal_message: 14 | 15 | lda __msg_kernal_first, x 16 | bpl l1 ; 0 marks end of string 17 | and #$7F 18 | jmp JCHROUT 19 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/screen_get_cliped_pntr.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Get PNTR value clipped to 0-39 range in .Y, sets flags to compare with 0, can trash .A 7 | ; 8 | 9 | screen_get_clipped_PNTR: 10 | 11 | ldy PNTR 12 | cpy llen 13 | bcc :+ 14 | tya 15 | sbc llen 16 | tay 17 | : 18 | cpy #$00 19 | rts 20 | -------------------------------------------------------------------------------- /kernal/drivers/c64/sprites.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; VIC-II Sprites Driver 3 | ;---------------------------------------------------------------------- 4 | ; (C)2020 Michael Steil, License: 2-clause BSD 5 | 6 | .export sprite_set_image, sprite_set_position 7 | 8 | .segment "SPRITES" 9 | 10 | sprite_set_image: 11 | sprite_set_position: 12 | brk ; XXX TODO 13 | 14 | -------------------------------------------------------------------------------- /geos/inc/inputdrv.inc: -------------------------------------------------------------------------------- 1 | ; GEOS Input Driver Jump Tab 2 | ; reassembled by Maciej 'YTM/Alliance' Witkowiak 3 | 4 | ; for C64 5 | ;MouseInit = $fe80 6 | ;SlowMouse = $fe83 7 | ;UpdateMouse = $fe86 8 | ;SetMouse = $fe89 9 | 10 | ; for C128 11 | MouseInit_128 = $fd00 12 | SlowMouse_128 = $fd03 13 | UpdateMouse_128 = $fd06 14 | SetMouse_128 = $fd09 15 | -------------------------------------------------------------------------------- /codex/inc/encode_vars.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Encoder vars for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_ENCODE_VARS__ 9 | __X16_ENCODE_VARS__=1 10 | 11 | .import encode_pc, encode_buffer_size, encode_dry_run, encode_buffer 12 | .importzp ENCODE_BUFFER_MAX 13 | 14 | .endif 15 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_gfxtxt.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; GFX/TXT mode switch handling within CHROUT 7 | ; 8 | 9 | 10 | chrout_screen_GFX: 11 | lda #2 12 | bne chrout_screen_set_charset 13 | 14 | chrout_screen_TXT: 15 | lda #3 16 | chrout_screen_set_charset: 17 | jsr screen_set_charset 18 | jmp chrout_screen_done 19 | -------------------------------------------------------------------------------- /codex/src/plugin-load.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Load address for plugin files 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .psc02 ; Enable 65c02 instructions 9 | .feature labels_without_colons 10 | 11 | .import main_entry 12 | 13 | .org $a000 14 | 15 | .segment "PLUGIN" 16 | .word * 17 | 18 | jmp main_entry 19 | 20 | -------------------------------------------------------------------------------- /kernal/open-roms/init/ff5b.cint.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 280 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 242 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): none 12 | ; 13 | 14 | CINT: 15 | 16 | jmp cint_legacy 17 | -------------------------------------------------------------------------------- /geos/kernal/menu/menu2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Menus: string fault 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global MenuStringFault 14 | 15 | .segment "menu2" 16 | 17 | MenuStringFault: 18 | MoveW mouseRight, r11 19 | rts 20 | 21 | -------------------------------------------------------------------------------- /keymap/make_keytab_asm.sh: -------------------------------------------------------------------------------- 1 | layouts="99409 20409 809 41D 407 406 410 415 414 40E 40A 40B 416 405 411 40C 807 10409 425 80C 1009 40F 816 41A 41B 424 426 427 " 2 | 3 | for layout in $layouts; do 4 | filename=$(ls klc/${layout}\ *.klc) 5 | echo $filename 6 | python3 klc_to_asm.py "$filename" asm/$layout.s asm/$layout.bin asm/$layout.bin.lzsa 7 | lzsa -f 2 -r --prefer-ratio asm/$layout.bin asm/$layout.bin.lzsa 8 | rm asm/$layout.bin 9 | done 10 | -------------------------------------------------------------------------------- /kernal/drivers/c64/rs232.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; Placeholder RS232 Driver 3 | ;---------------------------------------------------------------------- 4 | ; (C)2020 Michael Steil, License: 2-clause BSD 5 | 6 | .export bsi232, bso232, cki232, cko232, cls232, opn232 7 | 8 | .segment "RS232" 9 | 10 | bsi232: 11 | bso232: 12 | cki232: 13 | cko232: 14 | cls232: 15 | opn232: 16 | rts ; XXX 17 | 18 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/chkinout.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Common part of CHKIN and CKOUT 7 | ; 8 | 9 | 10 | chkinout_device_not_present: 11 | 12 | ply_trash_a 13 | pla 14 | jsr kernalstatus_DEVICE_NOT_FOUND 15 | jmp kernalerror_DEVICE_NOT_FOUND 16 | 17 | chkinout_file_not_open: 18 | 19 | ply_trash_a 20 | pla 21 | jmp kernalerror_FILE_NOT_OPEN 22 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/setmsg.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 298 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 239 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y 12 | ; 13 | 14 | SETMSG: 15 | 16 | sta MSGFLG 17 | rts 18 | -------------------------------------------------------------------------------- /geos/kernal/tobasic/tobasic2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; C64/C128: Start a program in BASIC mode 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global _ToBASIC 14 | 15 | .segment "tobasic2" 16 | 17 | _ToBASIC: 18 | ;XXX TODO X16 19 | brk 20 | 21 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/settmo.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 300 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 239 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y 12 | ; 13 | 14 | 15 | SETTMO: 16 | 17 | ;sta TIMOUT 18 | rts 19 | -------------------------------------------------------------------------------- /codex/inc/utility.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Utility routines for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_UTILITY__ 9 | __X16_UTILITY__=1 10 | 11 | .import util_trim_string, util_strcpy, util_strcmp, util_parse_hex 12 | .import util_ends_with, util_split_string, util_str_contains, util_strlen 13 | 14 | .endif 15 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/f13e.getin.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 283 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 227/228 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): for RS-232: .X, .Y 12 | ; 13 | 14 | 15 | GETIN: 16 | jmp getin_real 17 | -------------------------------------------------------------------------------- /codex/inc/bank_assy_vars.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Bank indicator variables for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __BANK_ASSY_VARS__ 9 | __BANK_ASSY_VARS__=1 10 | 11 | .import bank_max, bank_assy, bank_scr1, bank_scr2, bank_meta_l, bank_meta_i, bank_rom_orig, bank_plugin, bank_scrollback 12 | 13 | .endif 14 | -------------------------------------------------------------------------------- /geos/inc/printdrv.inc: -------------------------------------------------------------------------------- 1 | ; GEOS Printer Driver Jump Table 2 | ; reassembled by Maciej 'YTM/Alliance' Witkowiak 3 | 4 | ; jump table 5 | InitForPrint = $7900 6 | StartPrint = $7903 7 | PrintBuffer = $7906 8 | StopPrint = $7909 9 | GetDimensions = $790c 10 | PrinsASCII = $790f 11 | StartASCII = $7912 12 | SetNLQ = $7915 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: bionic 2 | sudo: required 3 | language: c 4 | 5 | matrix: 6 | include: 7 | - name: Linux 8 | os: linux 9 | addons: 10 | apt: 11 | packages: 12 | - cc65 13 | compiler: gcc 14 | script: make clean all 15 | - name: macOS 16 | os: osx 17 | osx_image: xcode11 18 | addons: 19 | homebrew: 20 | packages: 21 | - cc65 22 | script: make clean all 23 | -------------------------------------------------------------------------------- /cfg/dos-x16.cfgtpl: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | #include "x16.cfginc" 3 | 4 | DOS: start = $C000, size = $3FFE, fill=yes, fillval=$AA; 5 | IRQB: start = $FFFE, size = $0002, fill=yes, fillval=$AA; 6 | } 7 | 8 | SEGMENTS { 9 | ZPDOS: load = ZPDOS, type = zp; 10 | 11 | dos_jmptab: load = DOS, type = ro; 12 | CODE: load = DOS, type = ro; 13 | IRQB: load = IRQB, type = ro; 14 | 15 | BSS: load = DOSDAT, type = bss; 16 | } 17 | -------------------------------------------------------------------------------- /kernal/open-roms/print/print_hex_byte.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Print the hex value in .A as two digits 7 | ; 8 | 9 | print_hex_byte: 10 | 11 | ; Idea by Haubitze 12 | 13 | sed 14 | pha 15 | lsr 16 | lsr 17 | lsr 18 | lsr 19 | cmp #$0A 20 | adc #$30 21 | cld 22 | jsr JCHROUT 23 | sed 24 | pla 25 | and #$0F 26 | cmp #$0A 27 | adc #$30 28 | cld 29 | jmp JCHROUT 30 | -------------------------------------------------------------------------------- /codex/inc/fio.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Code block manipulation routines for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_FILE_IO__ 9 | __X16_FILE_IO__=1 10 | 11 | .import file_open,file_open_seq_read_str,file_open_seq_write_str,file_set_error,file_replace_ext 12 | .import file_load_bank_a000, file_save_bank_a000 13 | 14 | .endif 15 | -------------------------------------------------------------------------------- /kernal/open-roms/memory/membot.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Official Kernal routine, described in: 3 | ; 4 | ; - [RG64] C64 Programmers Reference Guide - page 287/288 5 | ; - [CM64] Computes Mapping the Commodore 64 - page 240 6 | ; 7 | ; CPU registers that has to be preserved (see [RG64]): .A 8 | ; 9 | 10 | MEMBOT: 11 | 12 | bcc membot_set 13 | 14 | ldy MEMSTR+1 15 | ldx MEMSTR+0 16 | 17 | ; FALLTROUGH 18 | 19 | membot_set: 20 | 21 | sty MEMSTR+1 22 | stx MEMSTR+0 23 | 24 | rts 25 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_shift_onoff.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; SHIFT ON/OFF handling within CHROUT 7 | ; 8 | 9 | 10 | chrout_screen_SHIFT_ON: 11 | 12 | lda #$00 ; enable SHIFT+VENDOR combination 13 | l4: 14 | sta MODE 15 | jmp chrout_screen_done 16 | 17 | chrout_screen_SHIFT_OFF: 18 | 19 | lda #$80 ; disable SHIFT+VENDOR combination 20 | bne l4 ; branch always 21 | -------------------------------------------------------------------------------- /geos/kernal/dlgbox/dlgbox1f.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Dialog box: sysopv 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import DBStringFaultVec 14 | 15 | .global DBDoSYSOPV 16 | 17 | .segment "dlgbox1f" 18 | 19 | DBDoSYSOPV: 20 | LoadW otherPressVec, DBStringFaultVec 21 | rts 22 | 23 | -------------------------------------------------------------------------------- /test/bench/bs.bas: -------------------------------------------------------------------------------- 1 | REM ERATOSTHENES SIEVE PRIME NUMBER PROGRAM IN BASIC 2 | 1 SIZE = 7190 3 | 2 DIM FLAGS(7191) 4 | 3 PRINT "ONLY 1 ITERATION" 5 | 5 COUNT = 0 6 | 6 FOR I = 0 TO SIZE 7 | 7 FLAGS (I) = 1 8 | 8 NEXT I 9 | 9 FOR I = 0 TO SIZE 10 | 10 IF FLAGS (I) = 0 THEN 18 11 | 11 PRIME = I+I + 3 12 | 12 K = I + PRIME 13 | 13 IF K > SIZE THEN 17 14 | 14 FLAGS (K) = 0 15 | 15 K = K + PRIME 16 | 16 GOTO 13 17 | 17 COUNT = COUNT + 1 18 | 18 NEXT I 19 | 19 PRINT COUNT," PRIMES" 20 | 20 SYS 65535 21 | -------------------------------------------------------------------------------- /codex/inc/dispatch.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; UI keypress routine dispatcher for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_DISPATCH__ 9 | __X16_DISPATCH__=1 10 | 11 | .import get_and_dispatch, fn_dispatch 12 | 13 | .macro setDispatchTable t 14 | LoadW dispatch_current_table, t 15 | .endmacro 16 | 17 | .include "dispatch_vars.inc" 18 | 19 | .endif 20 | -------------------------------------------------------------------------------- /codex/src/dispatch_vars.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Dispatch module varss for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .psc02 ; Enable 65c02 instructions 9 | .feature labels_without_colons 10 | 11 | .data 12 | 13 | .export dispatch_vector, dispatch_current_table 14 | 15 | dispatch_vector .word 0 16 | dispatch_current_table .word 0 17 | 18 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/screen.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmer's Reference Guide - page 295 9 | ; - [CM64] Compute's Mapping the Commodore 64 - page 215 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .A 12 | ; 13 | 14 | 15 | SCREEN: 16 | 17 | ldx llen ; rows 18 | ldy nlinesm1 19 | iny ; columns 20 | 21 | rts 22 | -------------------------------------------------------------------------------- /test/finh-sec-test-3.bas: -------------------------------------------------------------------------------- 1 | 100 REM TEST PROGRAM FOR ADDING "SEC" TO FINH 2 | 110 REM JEREMY DILATUSH 11 SEP 2021 3 | 120 : 4 | 200 DIMD$(99) 5 | 210 I=0 6 | 220 READD$(I) 7 | 230 IFD$(I)<>"END"THENI=I+1:GOTO220 8 | 240 RESTORE:I=I-1 9 | 250 FORJ=0TOI 10 | 260 READA 11 | 270 PRINTD$(J);"=>";A 12 | 280 NEXT 13 | 290 END 14 | 300 : 15 | 400 DATA1,$23,%111001000,0,.1,2.3,-45,.006E7 16 | 410 DATA, 17 | 420 DATAE 18 | 430 DATA1E2:REM HOW DOES IT HANDLE A COLON 19 | 440 DATA+,-,%,$,. 20 | 900 DATA"END" 21 | -------------------------------------------------------------------------------- /dos/zeropage.s: -------------------------------------------------------------------------------- 1 | .global krn_ptr1, bank_save 2 | .global fat32_bufptr, fat32_lfn_bufptr, fat32_ptr, fat32_ptr2 3 | 4 | .segment "ZPDOS" : zeropage 5 | 6 | ; DOS 7 | krn_ptr1: 8 | .res 2 9 | bank_save: 10 | .res 1 11 | 12 | ; FAT 32 13 | fat32_bufptr: 14 | .res 2 ; word - Internally used by FAT32 code 15 | fat32_lfn_bufptr: 16 | .res 2 ; word - Internally used by FAT32 code 17 | fat32_ptr: 18 | .res 2 ; word - Buffer pointer to various functions 19 | fat32_ptr2: 20 | .res 2 ; word - Buffer pointer to various functions 21 | -------------------------------------------------------------------------------- /codex/inc/screen_vars.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Screen control vars for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_SCREEN_VARS__ 9 | __X16_SCREEN_VARS__=1 10 | 11 | .import orig_color, input_string_length, input_string, input_string_cursor 12 | .import screen_width, screen_height, screen_row_prompt, screen_row_data_count, screen_last_row 13 | .import print_to_file 14 | 15 | .endif 16 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/e56c.screen_calculate_pointers.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Set pointer (PNT) to current screen line , described in: 7 | ; 8 | ; - [CM64] Computes Mapping the Commodore 64 - page 216 9 | ; - http:;sta.c64.org/cbm64scrfunc.html 10 | ; 11 | 12 | ; XXX find out what the original ROM really recalculate 13 | 14 | 15 | screen_calculate_pointers: 16 | 17 | jsr screen_calculate_PNT_USER 18 | jmp screen_calculate_PNTR_LNMX 19 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/screen_advance_to_next_line.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | screen_advance_to_next_line: 7 | 8 | ; Check if we are at the bottom of the screen 9 | ldy TBLX 10 | cpy nlinesm1 11 | bne :+ 12 | 13 | ; We need to scroll the screen up 14 | jsr screen_scroll_up 15 | : 16 | inc TBLX 17 | 18 | ; Set PNTR to 0 (for continued line will be fixed later) 19 | lda #$00 20 | sta PNTR 21 | 22 | jmp chrout_screen_calc_lptr_done 23 | -------------------------------------------------------------------------------- /graphics/fonts/fonts4.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 KERNAL 2 | ; based on GEOS by Berkeley Softworks; reversed by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Font library: drawing 5 | 6 | FntShJump: 7 | sta fontTemp1 8 | .ifdef bsw128 9 | bbsf BOLD_BIT, currentMode, @X 10 | rts 11 | @X: 12 | .else 13 | bbrf BOLD_BIT, currentMode, noop 14 | .endif 15 | clc 16 | php 17 | ldy #$ff 18 | @5: 19 | iny 20 | lda fontTemp1,y 21 | plp 22 | ror 23 | ora fontTemp1,y 24 | sta fontTemp1,y 25 | php 26 | cpy r8L 27 | bne @5 28 | pla 29 | noop: rts 30 | -------------------------------------------------------------------------------- /kernsup/kernsup_basic.s: -------------------------------------------------------------------------------- 1 | .include "banks.inc" 2 | 3 | .import bjsrfar 4 | 5 | .macro bridge symbol 6 | .local address 7 | .segment "KSUP_VEC" 8 | address = * 9 | .segment "KSUP_CODE" 10 | symbol: 11 | jsr bjsrfar 12 | .word address 13 | .byte BANK_KERNAL 14 | rts 15 | .segment "KSUP_VEC" 16 | jmp symbol 17 | .endmacro 18 | 19 | .segment "KSUP_VEC" 20 | 21 | xjsrfar = bjsrfar 22 | .include "kernsup.inc" 23 | 24 | .byte 0, 0, 0, 0 ; signature 25 | 26 | .word $ffff ; nmi 27 | .word $ffff ; reset 28 | .word banked_irq 29 | -------------------------------------------------------------------------------- /codex/inc/cx_vars.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; $A000 definitionsVariables for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020-2021 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __BANK_CX_ASSY__ 9 | __BANK_CX_ASSY__=1 10 | 11 | .import assy_selected_instruction, assy_last_disp_instruction, assy_selected_row, original_sp 12 | .import mem_last_addr, mem_last_bank, input_hex_bank_set, input_hex_bank, input_hex_value, run_break_shim 13 | 14 | .endif 15 | 16 | -------------------------------------------------------------------------------- /inc/fb.inc: -------------------------------------------------------------------------------- 1 | ; 2 | ; framebuffer driver 3 | ; 4 | FB_init = $fef6 5 | FB_get_info = $fef9 6 | FB_set_palette = $fefc 7 | FB_cursor_position = $feff 8 | FB_cursor_next_line = $ff02 9 | FB_get_pixel = $ff05 10 | FB_get_pixels = $ff08 11 | FB_set_pixel = $ff0b 12 | FB_set_pixels = $ff0e 13 | FB_set_8_pixels = $ff11 14 | FB_set_8_pixels_opaque = $ff14 15 | FB_fill_pixels = $ff17 16 | FB_filter_pixels = $ff1a 17 | FB_move_pixels = $ff1d 18 | 19 | -------------------------------------------------------------------------------- /dos/fat32/sdcard.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; sdcard.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Functions 8 | ;----------------------------------------------------------------------------- 9 | .global sdcard_init 10 | .global sdcard_check_alive 11 | .global sdcard_read_sector 12 | .global sdcard_write_sector 13 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/findfls.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; Just a helper routine 6 | 7 | ; Find the LAT / SAT / FAT entry index where LAT corresponds to A, returns index in Y 8 | ; Carry flag set means not found 9 | 10 | find_fls: 11 | 12 | ldy LDTND 13 | : 14 | dey 15 | bmi find_fls_not_found ; no more entries 16 | cmp LAT, y 17 | bne :- ; does not match, try the next one 18 | 19 | clc 20 | rts 21 | 22 | find_fls_not_found: 23 | 24 | sec 25 | rts 26 | -------------------------------------------------------------------------------- /geos/kernal/files/files2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; BAM/VLIR filesystem driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .segment "files2" 14 | 15 | .global DkNmTabH 16 | .global DkNmTabL 17 | 18 | .define DkNmTab DrACurDkNm, DrBCurDkNm, DrCCurDkNm, DrDCurDkNm 19 | DkNmTabL: 20 | .lobytes DkNmTab 21 | DkNmTabH: 22 | .hibytes DkNmTab 23 | 24 | -------------------------------------------------------------------------------- /geos/kernal/reu/reu.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; C64/REU driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | ; syscalls 14 | .global _DoRAMOp 15 | .global _FetchRAM 16 | .global _StashRAM 17 | .global _SwapRAM 18 | .global _VerifyRAM 19 | 20 | .segment "reu" 21 | 22 | _DoRAMOp: 23 | _FetchRAM: 24 | _StashRAM: 25 | _SwapRAM: 26 | _VerifyRAM: 27 | brk 28 | -------------------------------------------------------------------------------- /cfg/graph.cfgtpl: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | #include "x16.cfginc" 3 | 4 | GRVARSB0: start = $af00, size = $0100; 5 | GRAPH: start = $C000, size = $3FFA, fill=yes, fillval=$AA; 6 | VECTORS: start = $FFFA, size = $0006, fill=yes, fillval=$AA; 7 | } 8 | 9 | SEGMENTS { 10 | GRAPHVAR: load = GRAPHVAR, type = bss; 11 | GRAPH: load = GRAPH, type = ro; 12 | KVARSB0: load = GRVARSB0, type = bss, define=yes; 13 | CONSOLE: load = GRAPH, type = ro; 14 | VECTORS: load = VECTORS, type = ro; 15 | GDRVVEC: load = GDRVVEC, type = bss; 16 | } 17 | -------------------------------------------------------------------------------- /codex/inc/meta.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Label meta data for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_META_L__ 9 | __X16_META_L__=1 10 | 11 | .import meta_find_label, meta_delete_label, meta_relocate_labels, meta_find_label, meta_lookup_label 12 | .import meta_clear_watches, meta_clear_meta_data, meta_add_label, meta_print_banked_label 13 | .import meta_get_region, meta_get_label, meta_tag_version 14 | 15 | .endif 16 | -------------------------------------------------------------------------------- /codex/src/devrt0.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; BASIC bootstrap Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .psc02 ; Enable 65c02 instructions 9 | .feature labels_without_colons 10 | 11 | .import main_entry 12 | 13 | .org $801 14 | 15 | .segment "BOOTSTRAP" 16 | .word * 17 | 18 | basic_loader: 19 | .byte $0B,$08,$01,$00,$9E,$32,$30,$36,$31,$00,$00,$00 ; Adds BASIC line: 1 SYS 2061 20 | 21 | jmp main_entry 22 | 23 | -------------------------------------------------------------------------------- /geos/kernal/files/files3.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; BAM/VLIR filesystem driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import DkNmTabH 14 | .import DkNmTabL 15 | 16 | .global _GetPtrCurDkNm 17 | 18 | .segment "files3" 19 | 20 | _GetPtrCurDkNm: 21 | ldy curDrive 22 | lda DkNmTabL-8,Y 23 | sta zpage,x 24 | lda DkNmTabH-8,Y 25 | sta zpage+1,x 26 | rts 27 | 28 | -------------------------------------------------------------------------------- /codex/src/encode_vars.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Encoder vars for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .psc02 ; Enable 65c02 instructions 9 | .feature labels_without_colons 10 | 11 | .data 12 | 13 | .export encode_pc, encode_buffer_size, encode_dry_run 14 | .exportzp ENCODE_BUFFER_MAX 15 | 16 | ENCODE_BUFFER_MAX = 32 17 | 18 | encode_pc .word 0 19 | encode_dry_run .byte 0 20 | encode_buffer_size .byte 0 21 | -------------------------------------------------------------------------------- /kernal/fonts/font_internal.inc: -------------------------------------------------------------------------------- 1 | ; This exposes some font symbols from KERNAL to GEOS. 2 | ; No other code should use these symbols. 3 | 4 | k_curIndexTable = $8e 5 | k_baselineOffset = $0295 6 | k_curSetWidth = $0296 7 | k_curHeight = $0298 8 | k_cardDataPntr = $0299 9 | k_currentMode = $029b 10 | k_windowTop = $029c 11 | k_windowBottom = $029e 12 | k_leftMargin = $02a0 13 | k_rightMargin = $02a2 14 | 15 | k_fontTemp1 = $02a4 16 | k_fontTemp2 = $02ac 17 | k_PrvCharWidth = $02b5 18 | k_FontTVar1 = $02b6 19 | k_FontTVar2 = $02b7 20 | k_FontTVar3 = $02b9 21 | k_FontTVar4 = $02ba 22 | 23 | -------------------------------------------------------------------------------- /codex/inc/dbgctrl.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Control logic for debug methods, stepping, set breaks, etc. 3 | ;;; Uses the banked_variables, break_1, break_2, etc. 4 | ;;; For the Commander 16 Assembly Language Environment 5 | ;;; 6 | ;;; Copyright 2020 Michael J. Allison 7 | ;;; License, 2-clause BSD, see license.txt in source package. 8 | ;;; 9 | 10 | .ifndef __X16_DBGCTRL__ 11 | __X16_DBGCTRL__=1 12 | 13 | .import step_apply, step_suspend, debug_get_brk_adjustment 14 | .import registers_save, registers_restore 15 | 16 | .importzp JMP_INSTRUCTION, BRK_INSTRUCTION 17 | 18 | 19 | .endif 20 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/e566.cursor_home.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Home the cursor, described in: 7 | ; 8 | ; - [CM64] Computes Mapping the Commodore 64 - page 216 9 | ; 10 | 11 | 12 | cursor_home: 13 | 14 | lda #$00 15 | sta PNTR ; current column (logical) 16 | sta TBLX ; current row 17 | 18 | ; FALLTROUGH to the next routine 19 | 20 | .assert * = screen_calculate_pointers, error, "cursor_home must fall through to screen_calculate_pointers" 21 | -------------------------------------------------------------------------------- /geos/kernal/files/compat.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Check app compatibility 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global CheckAppCompat 14 | 15 | .segment "compat" 16 | 17 | CheckAppCompat: 18 | bbsf 7, graphMode, @2 ; 80 col 19 | bit fileHeader+O_128_FLAGS 20 | bpl @3 ; ok 21 | @1: ldx #INCOMPATIBLE 22 | rts 23 | @2: bbrf 6, fileHeader+O_128_FLAGS, @1 24 | @3: ldx #0 25 | rts 26 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/setfls.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 297 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 238 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y 12 | ; 13 | 14 | SETFLS: 15 | 16 | ; There are 6 sane ways to implement this routine, 17 | ; I hope this one will not cause similarity to CBM code 18 | 19 | sta LA 20 | sty SA 21 | stx FA 22 | 23 | rts 24 | -------------------------------------------------------------------------------- /kernal/drivers/c64/mouse.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; SID Mouse Driver 3 | ;---------------------------------------------------------------------- 4 | ; (C)2020 Michael Steil, License: 2-clause BSD 5 | 6 | .export mouse_config, mouse_get, mouse_scan 7 | 8 | .segment "PS2MOUSE" ; XXX rename 9 | 10 | mouse_config: 11 | rts ; XXX 12 | 13 | mouse_scan: 14 | rts ; XXX 15 | 16 | mouse_get: 17 | lda #0 ; x lo 18 | sta 0,x 19 | lda #0 ; x hi 20 | sta 1,x 21 | lda #0 ; x lo 22 | sta 2,x 23 | lda #0 ; x hi 24 | sta 3,x 25 | lda #0 ; buttons 26 | rts 27 | 28 | -------------------------------------------------------------------------------- /kernal/open-roms/interrupts/ea7e.ack_cia1_return_from_interrupt.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | ; https:;csdb.dk/forums/index.php?roomid=11&topicid=5776 7 | ; Clear the CIA1 interrupt flag, and then fall through to 8 | ; the return from interrupt routine 9 | 10 | clear_cia1_interrupt_flag_and_return_from_interrupt: 11 | 12 | jsr irq_ack 13 | 14 | ; FALL THROUGH to $EA81 15 | 16 | .assert * = return_from_interrupt, error, "clear_cia1_interrupt_flag_and_return_from_interrupt must fall through to return_from_interrupt" 17 | 18 | 19 | -------------------------------------------------------------------------------- /math/exports.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; Floating Point Library for 6502: Exports 3 | ;---------------------------------------------------------------------- 4 | 5 | ; data 6 | .export zero, fone 7 | 8 | ; zero page 9 | .export degree, polypt, fbufpt, tempf3, fdecpt, tenexp, deccnt, index2, tempf1, tempf2, index, index1, resho, resmoh, resmo, reslo, argexp, argho, argmoh, argmo, arglo, argsgn, arisgn, fac, facexp, facho, facmoh, facmo, faclo, facsgn, facov 10 | 11 | ; vars 12 | .export bits, rndx, tansgn, integr 13 | 14 | ; constant 15 | .export addprc 16 | 17 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/setnam.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 298/299 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 238 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y 12 | ; 13 | 14 | SETNAM: 15 | 16 | ; There are 6 sane ways to implement this routine, 17 | ; I hope this one will not cause similarity to CBM code 18 | 19 | sta FNLEN 20 | sty FNADDR + 1 21 | stx FNADDR + 0 22 | 23 | rts 24 | -------------------------------------------------------------------------------- /codex/src/decoder_vars.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Assembly decoder vars for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .psc02 ; Enable 65c02 instructions 9 | .feature labels_without_colons 10 | 11 | .data 12 | 13 | .export decoded_str_next, code_buffer 14 | 15 | decoded_str_next .byte 0 16 | 17 | ;; code_buffer is shared between the encoder and decoder 18 | ;; Since both operate at different times, there should be no conflict 19 | code_buffer .res 32,0 20 | 21 | -------------------------------------------------------------------------------- /test/fp/README.md: -------------------------------------------------------------------------------- 1 | # Performance measurements of floating point subroutines 2 | 3 | | Test | Original | Optimized | Speedup (%) | 4 | | ------------------------ | -------- | --------- | ----------- | 5 | | simple for loop | 106 | 97 | 8.5 | 6 | | counter | 333 | 315 | 5.4 | 7 | | cos calculation | 225 | 168 | 25.3 | 8 | | multiplication | 464 | 417 | 10.1 | 9 | | multiplication underflow | 555 | 386 | 30.5 | 10 | | sqr | 402 | 77 | 80.8 | 11 | 12 | -------------------------------------------------------------------------------- /codex/inc/meta_i.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Instruction meta data for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_META_I__ 9 | __X16_META_I__=1 10 | 11 | .importzp META_FN_NONE, META_FN_HI_BYTE, META_FN_LO_BYTE 12 | .importzp META_DATA_BYTE, META_DATA_WORD, META_DATA_PSTR, META_DATA_CSTR 13 | 14 | .importzp META_FN_ADDR_MASK, META_FN_DATA_MASK, META_FN_MASK, META_I_RECORD_SIZE 15 | 16 | .import meta_delete_expr, meta_relocate_expr, meta_save_expr, meta_find_expr, meta_expr_iter_next 17 | 18 | .endif 19 | -------------------------------------------------------------------------------- /dos/fat32/text_input.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; text_input.s 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | .include "text_input.inc" 7 | 8 | .code 9 | 10 | ;----------------------------------------------------------------------------- 11 | ; to_lower 12 | ;----------------------------------------------------------------------------- 13 | to_lower: 14 | ; Lower case character? 15 | cmp #'A' 16 | bcc @done 17 | cmp #'Z'+1 18 | bcs @done 19 | 20 | ; Make lowercase 21 | ora #$20 22 | @done: rts 23 | -------------------------------------------------------------------------------- /geos/kernal/files/files6b.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; BAM/VLIR filesystem driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global GetStartHAddr 14 | .global SetBufTSVector 15 | .global SetFHeadVector 16 | 17 | .segment "files6b" 18 | 19 | SetBufTSVector: 20 | LoadW r6, fileTrScTab 21 | rts 22 | 23 | GetStartHAddr: 24 | MoveW fileHeader + O_GHST_ADDR, r7 25 | rts 26 | 27 | SetFHeadVector: 28 | LoadW r4, fileHeader 29 | rts 30 | 31 | -------------------------------------------------------------------------------- /kernal/open-roms/memory/fe25.memtop.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 288 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 240 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .A 12 | ; 13 | 14 | MEMTOP: 15 | 16 | bcc memtop_set 17 | 18 | ldy MEMSIZK+1 19 | ldx MEMSIZK+0 20 | 21 | ; FALLTROUGH 22 | 23 | memtop_set: ; for compatibility reasons this has to start at $FE2D 24 | 25 | sty MEMSIZK+1 26 | stx MEMSIZK+0 27 | 28 | rts 29 | -------------------------------------------------------------------------------- /graphics/fonts/fonts.inc: -------------------------------------------------------------------------------- 1 | ; values of currentMode 2 | ; bit numbers 3 | UNDERLINE_BIT = 7 4 | BOLD_BIT = 6 5 | REVERSE_BIT = 5 6 | ITALIC_BIT = 4 7 | OUTLINE_BIT = 3 8 | ; bit 0 means "OPAQUE"; it is passed by GEOS, 9 | ; and will always draw explicit background pixels 10 | 11 | ; masks 12 | SET_UNDERLINE = %10000000 13 | SET_BOLD = %01000000 14 | SET_REVERSE = %00100000 15 | SET_ITALIC = %00010000 16 | SET_OUTLINE = %00001000 17 | SET_PLAINTEXT = %00000000 18 | -------------------------------------------------------------------------------- /math/math.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; Floating Point Library for 6502 3 | ;---------------------------------------------------------------------- 4 | 5 | .feature labels_without_colons, pc_assignment 6 | 7 | .include "declare.s" 8 | .include "exports.s" 9 | 10 | .include "jumptab.s" 11 | 12 | .segment "MATH" 13 | 14 | .include "code18.s" 15 | .include "code19.s" 16 | .include "code20.s" 17 | .include "code21.s" 18 | .include "code22.s" 19 | .include "code23.s" 20 | .include "code24.s" 21 | .include "code25.s" 22 | .include "trig.s" 23 | .include "fadd.s" 24 | .include "fmult.s" 25 | .include "fsqr.s" 26 | -------------------------------------------------------------------------------- /kernal/open-roms/interrupts/hw_entry_nmi.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | hw_entry_nmi: 7 | 8 | sei ; do not allow IRQ to interfere, see https:;www.c64-wiki.com/wiki/Interrupt 9 | 10 | .if CONFIG_CPU_MOS_6502 && CONFIG_BCD_SAFE_INTERRUPTS 11 | cld ; clear decimal flag to allow using it without disabling interrupts 12 | .endif 13 | 14 | ; Call interrupt routine (only if initialised) 15 | pha 16 | lda NMINV 17 | ora NMINV+1 18 | beq :+ 19 | pla 20 | jmp (NMINV) 21 | : 22 | ; Vector not initialized - call default interrupt routine 23 | pla 24 | jmp default_nmi_handler 25 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_quote.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; CHROUT routine - screen support, control codes in quote mode 7 | ; 8 | 9 | 10 | chrout_screen_quote: 11 | 12 | ; Low control codes are just +$80 13 | clc 14 | adc #$80 15 | 16 | ; If it overflowed, then it is a high control code, 17 | ; so we need to make it be $80 + $40 + char 18 | ; as we will have flipped back to just $00 + char, we should 19 | ; now add $c0 if C is set from overflow 20 | bcc :+ 21 | adc #$BF ; C=1, so adding $BF + C = add $C0 22 | : 23 | jmp chrout_screen_literal 24 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/screen_code_to_petscii.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | screen_code_to_petscii: 7 | cmp #$1B 8 | bcc s2p_adc_40 9 | 10 | s2p_not_alpha: 11 | cmp #$40 12 | bcc s2p_end 13 | 14 | ; FALLTROUGH 15 | 16 | s2p_not_punctuation: 17 | cmp #$5B 18 | bcs s2p_not_shifted 19 | 20 | ; carry already clear here 21 | adc #$80 22 | 23 | rts 24 | 25 | s2p_not_shifted: 26 | 27 | cmp #$80 28 | bcs s2p_end ; not vendor 29 | 30 | ; $60-$7F -> $A0-$BF 31 | 32 | s2p_adc_40: 33 | 34 | clc 35 | adc #$40 36 | 37 | ; FALLTROUGH 38 | 39 | s2p_end: 40 | rts 41 | -------------------------------------------------------------------------------- /monitor/kernal.i: -------------------------------------------------------------------------------- 1 | ; ---------------------------------------------------------------- 2 | ; KERNAL Symbols 3 | ; ---------------------------------------------------------------- 4 | 5 | .include "kernal.inc" 6 | .include "banks.inc" 7 | .include "io.inc" 8 | 9 | cbinv := $0316 ; BRK vector 10 | 11 | ; PETSCII 12 | CR := $0D 13 | CSR_DOWN := $11 14 | CSR_HOME := $13 15 | CSR_RIGHT := $1D 16 | CSR_UP := $91 17 | KEY_STOP := $03 18 | KEY_F3 := $86 19 | KEY_F5 := $87 20 | KEY_F7 := $88 21 | 22 | ; monitor and irq 23 | pntr = $1111 ; XXX 24 | 25 | BUF := $0200 ; system input buffer 26 | -------------------------------------------------------------------------------- /keymap/asm/407.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: German 5 | ; Locale: de-DE 6 | ; KLID: 407 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "DE-DE", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_407 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_407: 16 | .incbin "asm/407.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; --none-- 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~§°²³´µÄÖÜßäöüẞ€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '´ẞ' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¢£¥Šš©ª«¬­®¯±Ž¶·ž¹º»ŒœŸ¿ÃÅÆÇËÏÐÑÕרÞãåæçëïðñõ÷øþ' 31 | 32 | -------------------------------------------------------------------------------- /codex/inc/cx_vecs.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Codex vectors, for use by plugins. 3 | ;;; 4 | ;;; Copyright 2020-2021 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __CX_VECTORS__ 9 | __CX_VECTORS__=1 10 | 11 | vec_meta_get_region = $FAE2 12 | vec_meta_add_label = $FAE5 13 | vec_meta_delete_label = $FAE8 14 | vec_meta_get_label = $FAEB 15 | vec_meta_find_label = $FAEE 16 | vec_meta_expr_iter_next = $FAF1 17 | vec_meta_print_banked_label = $FAF4 18 | vec_decode_next_instruction = $FAF7 19 | vec_decode_next_argument = $FAFA 20 | vec_decode_get_byte_count = $FAFD 21 | 22 | .endif 23 | -------------------------------------------------------------------------------- /geos/kernal/files/files1a2a.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; BAM/VLIR filesystem driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global Add2 14 | .global Add2_return 15 | 16 | .segment "files1a2a" 17 | 18 | Add2: 19 | .ifdef wheels_size_and_speed ; optimized 20 | clc 21 | lda #2 22 | adc r6L 23 | sta r6L 24 | bcc @1 25 | inc r6H 26 | @1: rts 27 | .else 28 | AddVW 2, r6 29 | Add2_return: 30 | rts 31 | .endif 32 | 33 | -------------------------------------------------------------------------------- /geos/kernal/hw/hw1b.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Hardware initialization 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import ResetMseRegion 14 | .import Init_KRNLVec 15 | .import KbdQueTail 16 | .import KbdQueHead 17 | .import KbdQueFlag 18 | .import InitVDC 19 | 20 | .import SetColorMode 21 | 22 | .global _DoFirstInitIO 23 | 24 | .segment "hw1b" 25 | 26 | _DoFirstInitIO: 27 | ldx #$ff 28 | stx KbdQueFlag 29 | inx 30 | stx KbdQueHead 31 | stx KbdQueTail 32 | jmp ResetMseRegion 33 | 34 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/f333.clrchn.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 282 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 230 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .Y 12 | ; 13 | 14 | 15 | CLRCHN: 16 | 17 | jsr clrchn_iec 18 | 19 | ; FALLTROUGH 20 | 21 | clrchn_reset: ; entry needed by setup_vicii 22 | 23 | ; Set input device number to keyboard 24 | lda #$00 25 | sta DFLTN 26 | 27 | ; Set output device number to screen 28 | lda #$03 29 | sta DFLTO 30 | 31 | rts 32 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/getin_real.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 283 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 227/228 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): for RS-232: .X, .Y 12 | ; 13 | 14 | 15 | getin_real: 16 | 17 | ; Determine the device number 18 | lda DFLTN 19 | 20 | ; Try $00 - keyboard 21 | beq_16 kbdbuf_get 22 | 23 | .if HAS_RS232 24 | 25 | ; Try $02 - RS-232 26 | cmp #$02 27 | beq_16 getin_rs232 28 | 29 | .endif ; HAS_RS232 30 | 31 | jmp chrin_getin 32 | -------------------------------------------------------------------------------- /keymap/asm/20409.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: United States-International 5 | ; Locale: en-US 6 | ; KLID: 20409 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "EN-US/INT", 0, 0, 0, 0, 0 11 | .word kbtab_20409 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_20409: 16 | .incbin "asm/20409.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; --none-- 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¡¢¤¥¦§¨©«¬®°²³´µ¶¹»¼½¾¿ÁÄÅÆÇÉÍÐÑÓÖרÚÜÞßáäåæçéíðñóö÷øúüþ‘’€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¤¦¨´¼½¾‘’' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' Ššª­¯±Ž·žºŒœŸ' 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/406.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Danish 5 | ; Locale: da-DK 6 | ; KLID: 406 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "DA-DK", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_406 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_406: 16 | .incbin "asm/406.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¤§¨´µ½ÅÆØåæø€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¤¨´½' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¢¥Šš©ª«¬­®¯°±²³Ž¶·ž¹º»ŒœŸ¿ÇÐ×Þßçð÷þ' 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/40A.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Spanish 5 | ; Locale: es-ES 6 | ; KLID: 40a 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "ES-ES", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_40a 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_40a: 16 | .incbin "asm/40A.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¡¨ª¬´·º¿ÇÑçñ€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¨´' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¢£¥Š§š©«­®¯°±²³Žµ¶ž¹»ŒœŸÅÆÐרÞßåæð÷øþ' 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/414.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Norwegian 5 | ; Locale: nb-NO 6 | ; KLID: 414 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "NB-NO", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_414 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_414: 16 | .incbin "asm/414.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¤§¨´µÅÆØåæø€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¤¨´' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¢¥Šš©ª«¬­®¯°±²³Ž¶·ž¹º»ŒœŸ¿ÇÐ×Þßçð÷þ' 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/809.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: United Kingdom 5 | ; Locale: en-GB 6 | ; KLID: 809 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "EN-GB", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_809 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_809: 16 | .incbin "asm/809.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; --none-- 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¦¬ÁÉÍÓÚáéíóú€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¦' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¢¥Š§š©ª«­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÂÃÄÅÆÇÈÊËÌÎÏÐÑÒÔÕÖרÙÛÜÝÞßàâãäåæçèêëìîïðñòôõö÷øùûüýþ' 31 | 32 | -------------------------------------------------------------------------------- /inc/regs.inc: -------------------------------------------------------------------------------- 1 | r0 = $02 2 | r0L = $02 3 | r0H = $03 4 | r1 = $04 5 | r1L = $04 6 | r1H = $05 7 | r2 = $06 8 | r2L = $06 9 | r2H = $07 10 | r3 = $08 11 | r3L = $08 12 | r3H = $09 13 | r4 = $0a 14 | r4L = $0a 15 | r4H = $0b 16 | r5 = $0c 17 | r5L = $0c 18 | r5H = $0d 19 | r6 = $0e 20 | r6L = $0e 21 | r6H = $0f 22 | r7 = $10 23 | r7L = $10 24 | r7H = $11 25 | r8 = $12 26 | r8L = $12 27 | r8H = $13 28 | r9 = $14 29 | r9L = $14 30 | r9H = $15 31 | r10 = $16 32 | r10L = $16 33 | r10H = $17 34 | r11 = $18 35 | r11L = $18 36 | r11H = $19 37 | r12 = $1a 38 | r12L = $1a 39 | r12H = $1b 40 | r13 = $1c 41 | r13L = $1c 42 | r13H = $1d 43 | r14 = $1e 44 | r14L = $1e 45 | r14H = $1f 46 | r15 = $20 47 | r15L = $20 48 | r15H = $21 49 | 50 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/screen_get_logical_line_end_ptr.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | screen_get_logical_line_end_ptr: 7 | 8 | ldy TBLX 9 | cpy nlinesm1 10 | bcs screen_get_logical_line_end_39 ; last line of the screen 11 | 12 | lda LDTBL+0, y 13 | bpl screen_get_logical_line_end_39 ; current line continues previous one 14 | 15 | lda LDTBL+1, y 16 | bmi screen_get_logical_line_end_39 ; current line is not continued 17 | 18 | ; FALLTROUGH 19 | 20 | screen_get_logical_line_end_79: 21 | 22 | lda llen 23 | asl 24 | tay 25 | dey 26 | rts 27 | 28 | screen_get_logical_line_end_39: 29 | 30 | ldy llen 31 | dey 32 | rts 33 | -------------------------------------------------------------------------------- /keymap/asm/40B.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Finnish 5 | ; Locale: fi-FI 6 | ; KLID: 40b 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "FI-FI", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_40b 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_40b: 16 | .incbin "asm/40B.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¤§¨´µ½ÄÅÖäåö€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¤¨´½' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¢¥Šš©ª«¬­®¯°±²³Ž¶·ž¹º»ŒœŸ¿ÆÇÐרÞßæçð÷øþ' 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/41D.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Swedish 5 | ; Locale: sv-SE 6 | ; KLID: 41d 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "SV-SE", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_41d 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_41d: 16 | .incbin "asm/41D.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¤§¨´µ½ÄÅÖäåö€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¤¨´½' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¢¥Šš©ª«¬­®¯°±²³Ž¶·ž¹º»ŒœŸ¿ÆÇÐרÞßæçð÷øþ' 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/80C.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Belgian French 5 | ; Locale: fr-BE 6 | ; KLID: 80c 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "FR-BE", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_80c 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_80c: 16 | .incbin "asm/80C.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~§¨°²³´µàçèéù€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¨´' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¢¥Šš©ª«¬­®¯±Ž¶·ž¹º»ŒœŸ¿ÅÆÇÐרÞßåæð÷øþ' 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/40C.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: French 5 | ; Locale: fr-FR 6 | ; KLID: 40c 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "FR-FR", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_40c 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_40c: 16 | .incbin "asm/40C.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¤§¨°²µàçèéù€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¤¨' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¢¥Šš©ª«¬­®¯±³Ž¶·ž¹º»ŒœŸ¿ÁÅÆÇÉÍÐÓרÚÝÞßáåæíðó÷øúýþ' 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/807.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Swiss German 5 | ; Locale: de-CH 6 | ; KLID: 807 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "DE-CH", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_807 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_807: 16 | .incbin "asm/807.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¢¦§¨¬°´àäçèéöü€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¦¨´' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¥Šš©ª«­®¯±²³Žµ¶·ž¹º»ŒœŸ¿ÅÆÇÐרÞßåæð÷øþ' 31 | 32 | -------------------------------------------------------------------------------- /geos/kernal/serial/serial1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Serial number 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global SerialNumber 14 | 15 | .segment "serial1" 16 | 17 | SerialNumber: 18 | .ifdef wheels 19 | .word $DF96 20 | .else 21 | .ifdef bsw128 22 | ; This matches the serial in the cbmfiles.com GEOS128.D64 23 | .word $FD8D 24 | .else 25 | ; This matches the serial in the cbmfiles.com GEOS64.D64 26 | .word $58B5 27 | .endif 28 | .endif 29 | 30 | .ifndef wheels_size 31 | .byte $FF ; ??? 32 | .endif 33 | 34 | -------------------------------------------------------------------------------- /keymap/asm/416.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Portuguese (Brazil ABNT) 5 | ; Locale: pt-BR 6 | ; KLID: 416 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "PT-BR", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_416 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_416: 16 | .incbin "asm/416.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¢§¨ª¬°²³´¹ºÇç₢' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¨´₢' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡€¥Šš©«­®¯±Žµ¶·ž»ŒœŸ¿ÅÆÐרÞßåæð÷øþ' 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/816.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Portuguese 5 | ; Locale: pt-PT 6 | ; KLID: 816 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "PT-PT", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_816 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_816: 16 | .incbin "asm/816.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; chars: 'π←' 22 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 23 | ; Keys outside of PETSCII: 24 | ; '\_{|}~§¨ª«´º»Çç€' 25 | 26 | ; ISO 27 | ; ~~~ 28 | ; Keys outside of ISO-8859-15: 29 | ; '¨´' 30 | ; Non-reachable ISO-8859-15: 31 | ; ' ¡¢¥Šš©¬­®¯°±²³Žµ¶·ž¹ŒœŸ¿ÅÆÐרÞßåæð÷øþ' 32 | 33 | -------------------------------------------------------------------------------- /codex/inc/bank.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; RAM bank control for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_BANK__ 9 | __X16_BANK__=1 10 | 11 | .importzp BANK_CTRL_ROM, BANK_CTRL_RAM 12 | .import bank_initialize, bank_pop, bank_push, set_dirty 13 | 14 | .macro pushBankVar b 15 | lda b 16 | jsr bank_push 17 | .endmacro 18 | 19 | .macro pushBankX 20 | txa 21 | jsr bank_push 22 | .endmacro 23 | 24 | .macro switchBankVar b 25 | lda b 26 | sta BANK_CTRL_RAM 27 | .endmacro 28 | 29 | .macro popBank 30 | jsr bank_pop 31 | .endmacro 32 | 33 | .endif 34 | -------------------------------------------------------------------------------- /kernal/cbm/nmi.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; NMI 3 | ;---------------------------------------------------------------------- 4 | ; (C)1983 Commodore Business Machines (CBM) 5 | ; additions: (C)2020 Michael Steil, License: 2-clause BSD 6 | 7 | .feature labels_without_colons 8 | 9 | monitor = $fecc 10 | .import enter_basic, cint, ioinit, restor, nminv 11 | 12 | .export nmi, nnmi, timb 13 | 14 | .segment "NMI" 15 | 16 | nmi jmp (nminv) 17 | nnmi 18 | ; 19 | ; timb - where system goes on a brk instruction 20 | ; 21 | timb jsr restor ;restore system indirects 22 | jsr ioinit ;restore i/o for basic 23 | jsr cint ;restore screen for basic 24 | clc 25 | jmp monitor 26 | 27 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/f5dd.save_prep.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; SAVE preparation routine 7 | ; 8 | 9 | ; 10 | ; Input (according to http:;sta.c64.org/cbm64krnfunc.html) 11 | ; .A - address of zero page register holding start address of memory area to save 12 | ; .X and .Y - end address of memory area plus 1 13 | ; 14 | 15 | ; 16 | ; Note: Experimenting can easily confirm that SAVE preparation routine does similar 17 | ; actions as LOAD preparation routine. 18 | ; 19 | 20 | SAVE_PREP: 21 | 22 | sty EAL+1 23 | stx EAL+0 24 | 25 | tax 26 | 27 | lda $01, x 28 | sta STAL+1 29 | lda $00, x 30 | sta STAL+0 31 | 32 | jmp (ISAVE) 33 | -------------------------------------------------------------------------------- /keymap/asm/40F.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Icelandic 5 | ; Locale: is-IS 6 | ; KLID: 40f 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "IS-IS", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_40f 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_40f: 16 | .incbin "asm/40F.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; chars: '£π←' 22 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 23 | ; Keys outside of PETSCII: 24 | ; '\_{|}~¨°´µÆÐÖÞæðöþ€' 25 | 26 | ; ISO 27 | ; ~~~ 28 | ; Keys outside of ISO-8859-15: 29 | ; '¨´' 30 | ; Non-reachable ISO-8859-15: 31 | ; ' ¡¢£¥Š§š©ª«¬­®¯±²³Ž¶·ž¹º»ŒœŸ¿ÃÇÑÕרßãçñõ÷ø' 32 | 33 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/f49e.load_prep.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; LOAD preparation routine 7 | ; 8 | 9 | ; 10 | ; Input (according to http:;sta.c64.org/cbm64krnfunc.html) 11 | ; .A - 0 for load, non-0 for verify 12 | ; .X and .Y - load address (if secondary address is 0) 13 | ; 14 | 15 | ; 16 | ; Note: Although the vector at $330 points to $F4A5, the Kernal jump table points to $F49E 17 | ; (see also Mapping the C64, page 76). By experimenting I have discovered that $F49E performs 18 | ; indirect jump via ($0330) vector, after setting MEMUSS. 19 | ; 20 | 21 | 22 | LOAD_PREP: 23 | 24 | sty MEMUSS+1 25 | stx MEMUSS+0 26 | jmp (ILOAD) 27 | -------------------------------------------------------------------------------- /kernal/open-roms/memory/fd15.restor.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 293 (RESTOR), 304 (VECTOR) 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 237 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): none 12 | ; 13 | 14 | RESTOR: 15 | 16 | clc ; clear carry - for writing to system table 17 | ldy #>vector_defaults 18 | ldx #psg_address 15 | sta VERA_ADDR_M 16 | lda #$10 | ^psg_address 17 | sta VERA_ADDR_H 18 | 19 | lda #frequency 22 | sta VERA_DATA0 23 | lda #%11111111 ; max volume, output left & right 24 | sta VERA_DATA0 25 | lda #%00111111 ; pulse, max width 26 | sta VERA_DATA0 27 | 28 | lda #4 29 | ldy #0 30 | ldx #0 31 | : dex 32 | bne :- 33 | dey 34 | bne :- 35 | dec 36 | bne :- 37 | 38 | lda #= 'C': 11 | addr = int(line[2:6], 16) 12 | asm = line[24:].rstrip() 13 | asm = asm.replace('"', '\\"') 14 | if asm != '' and asm != ';': 15 | if addr in map: 16 | map[addr] += '\\n'+asm 17 | else: 18 | map[addr] = asm 19 | #print(str(addr) + '|' + asm) 20 | 21 | print('char *lst_bank' + bank + '[] = {') 22 | for addr in range(0xc000, 0x10000): 23 | prefix = "/* ${:X} */ ".format(addr) 24 | if addr in map: 25 | print(prefix + '\"' + map[addr] + '\",') 26 | else: 27 | print(prefix + 'NULL,') 28 | print('};') 29 | -------------------------------------------------------------------------------- /keymap/asm/99409.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: ABC - Extended (X16) 5 | ; Locale: en-US 6 | ; KLID: us_ext 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "ABC/X16", 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_us_ext 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_us_ext: 16 | .incbin "asm/99409.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; --none-- 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~¡¢¥§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¿ÆÐØÞßæð÷øþŒœƒʔʼˀˆˇˍ˘˙˚˜˝̵̨̛̣̦̰̱̀́̂̃̇̉̋̌̏̑–‘’‚“”„†‡•…‰‸‹›⁄€№™≠≤≥' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; '¨´¸ƒʔʼˀˆˇˍ˘˙˚˜˝̵̨̛̣̦̰̱̀́̂̃̇̉̋̌̏̑–‘’‚“”„†‡•…‰‸‹›⁄№™≠≤≥' 29 | ; Non-reachable ISO-8859-15: 30 | ; --none-- 31 | 32 | -------------------------------------------------------------------------------- /keymap/asm/411.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Japanese 5 | ; Locale: ja-JP 6 | ; KLID: 411 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "JA-JP", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_411 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_411: 16 | .incbin "asm/411.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; chars: '£π←' 22 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 23 | ; Keys outside of PETSCII: 24 | ; '\_{|}~' 25 | 26 | ; ISO 27 | ; ~~~ 28 | ; Keys outside of ISO-8859-15: 29 | ; --none-- 30 | ; Non-reachable ISO-8859-15: 31 | ; ' ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ' 32 | 33 | -------------------------------------------------------------------------------- /keymap/asm/41A.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Croatian 5 | ; Locale: hr-HR 6 | ; KLID: 41a 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "HR-HR", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_41a 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_41a: 16 | .incbin "asm/41A.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; chars: '£π←' 22 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 23 | ; Keys outside of PETSCII: 24 | ; '\_{|}~¤§¨°´¸×ß÷ĆćČčĐđŁłŠšŽžˇ˘˙˛˝€' 25 | 26 | ; ISO 27 | ; ~~~ 28 | ; Keys outside of ISO-8859-15: 29 | ; '¤¨´¸ĆćČčĐ𣳡˘˙˛˝' 30 | ; Non-reachable ISO-8859-15: 31 | ; ' ¡¢£¥©ª«¬­®¯±²³µ¶·¹º»ŒœŸ¿ÀÃÅÆÈÊÌÏÐÑÒÕØÙÛÞàãåæèêìïðñòõøùûþ' 32 | 33 | -------------------------------------------------------------------------------- /keymap/asm/424.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Slovenian 5 | ; Locale: sl-SI 6 | ; KLID: 424 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "SL-SI", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_424 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_424: 16 | .incbin "asm/424.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; chars: '£π←' 22 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 23 | ; Keys outside of PETSCII: 24 | ; '\_{|}~¤§¨°´¸×ß÷ĆćČčĐđŁłŠšŽžˇ˘˙˛˝€' 25 | 26 | ; ISO 27 | ; ~~~ 28 | ; Keys outside of ISO-8859-15: 29 | ; '¤¨´¸ĆćČčĐ𣳡˘˙˛˝' 30 | ; Non-reachable ISO-8859-15: 31 | ; ' ¡¢£¥©ª«¬­®¯±²³µ¶·¹º»ŒœŸ¿ÀÃÅÆÈÊÌÏÐÑÒÕØÙÛÞàãåæèêìïðñòõøùûþ' 32 | 33 | -------------------------------------------------------------------------------- /keymap/asm/41B.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Slovak 5 | ; Locale: sk-SK 6 | ; KLID: 41b 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "SK-SK", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_41b 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_41b: 16 | .incbin "asm/41B.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; chars: '£π←' 22 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 23 | ; Keys outside of PETSCII: 24 | ; '\_{|}~¤§¨°´¸×ßáäéíô÷úýčĐ𾣳ňšťžˇ˘˙˛˝€' 25 | 26 | ; ISO 27 | ; ~~~ 28 | ; Keys outside of ISO-8859-15: 29 | ; '¤¨´¸čĐ𾣳ňťˇ˘˙˛˝' 30 | ; Non-reachable ISO-8859-15: 31 | ; ' ¡¢£¥©ª«¬­®¯±²³µ¶¹º»ŒœŸ¿ÀÃÅÆÈÊËÌÏÐÑÒÕØÙÛÞàãåæèêëìïðñòõøùûþ' 32 | 33 | -------------------------------------------------------------------------------- /geos/kernal/files/files7.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; BAM/VLIR filesystem driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global SerialHiCompare 14 | 15 | .segment "files7" 16 | 17 | .ifdef trap1 18 | SerialHiCompare: 19 | .ifdef cbmfiles 20 | ; This should be initialized to 0, and will 21 | ; be changed at runtime. 22 | ; The cbmfiles version was created by dumping 23 | ; KERNAL from memory after it had been running, 24 | ; so it has a pre-filled value here. 25 | .byte $58 26 | .elseif .defined(bsw128) 27 | .byte $fd 28 | .else 29 | .byte 0 30 | .endif 31 | .endif 32 | 33 | -------------------------------------------------------------------------------- /geos/kernal/keyboard/keyboard1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; C64/C128 keyboard driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | .include "banks.inc" 13 | 14 | .global _DoKeyboardScan 15 | 16 | .import KbdScanHelp2 17 | 18 | .segment "keyboard1" 19 | 20 | _DoKeyboardScan: 21 | .import gjsrfar 22 | jsr gjsrfar 23 | .word $FF9F ; kbd_scan 24 | .byte BANK_KERNAL 25 | 26 | jsr gjsrfar 27 | .word $FFE4 ; getin 28 | .byte BANK_KERNAL 29 | 30 | cmp #0 31 | bne :+ 32 | rts 33 | 34 | : cmp #20; PETSCII delete 35 | bne :+ 36 | lda #8 ; ASCII backspace 37 | 38 | : jmp KbdScanHelp2 39 | -------------------------------------------------------------------------------- /kernal/cbm/init.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; Init 3 | ;---------------------------------------------------------------------- 4 | ; (C)1983 Commodore Business Machines (CBM) 5 | ; additions: (C)2020 Michael Steil, License: 2-clause BSD 6 | 7 | .feature labels_without_colons 8 | 9 | .import cint, ramtas, ioinit, enter_basic, restor, vera_wait_ready 10 | 11 | .export start 12 | 13 | .segment "INIT" 14 | ; start - system reset 15 | ; 16 | start ldx #$ff 17 | sei 18 | txs 19 | 20 | jsr ioinit ;go initilize i/o devices 21 | jsr ramtas ;go ram test and set 22 | jsr restor ;go set up os vectors 23 | ; 24 | jsr cint ;go initilize screen 25 | cli ;interrupts okay now 26 | 27 | sec 28 | jmp enter_basic 29 | -------------------------------------------------------------------------------- /keymap/asm/10409.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: United States-Dvorak 5 | ; Locale: en-US 6 | ; KLID: 10409 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "EN-US/DVO", 0, 0, 0, 0, 0 11 | .word kbtab_10409 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_10409: 16 | .incbin "asm/10409.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; chars: '£π←' 22 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 23 | ; Keys outside of PETSCII: 24 | ; '\_{|}~' 25 | 26 | ; ISO 27 | ; ~~~ 28 | ; Keys outside of ISO-8859-15: 29 | ; --none-- 30 | ; Non-reachable ISO-8859-15: 31 | ; ' ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ' 32 | 33 | -------------------------------------------------------------------------------- /keymap/asm/415.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Polish (Programmers) 5 | ; Locale: pl-PL 6 | ; KLID: 415 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "PL-PL", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_415 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_415: 16 | .incbin "asm/415.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 22 | ; Keys outside of PETSCII: 23 | ; '\_{|}~ÓóĄąĆćĘꣳŃńŚśŹźŻż€' 24 | 25 | ; ISO 26 | ; ~~~ 27 | ; Keys outside of ISO-8859-15: 28 | ; 'ĄąĆćĘꣳŃńŚśŹźŻż' 29 | ; Non-reachable ISO-8859-15: 30 | ; ' ¡¢£¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòôõö÷øùúûüýþ' 31 | 32 | -------------------------------------------------------------------------------- /test/date.bas: -------------------------------------------------------------------------------- 1 | 0 REM--------------------------------------------------------------- 2 | 1 REM UNIT TEST FOR BASIC: 3 | 2 REM * TI$ ASSIGNMENT 4 | 3 REM * TI$ READING 5 | 4 REM * DA$ ASSIGNMENT 6 | 5 REM * DA$ READING 7 | 6 REM IN ADDITION, THIS CALCULATES THE DAY OF WEEK :) 8 | 7 REM--------------------------------------------------------------- 9 | 8 REM (C)2020 Michael Steil, License: 2-clause BSD 10 | 11 | 10 DA$="20191231":TI$="235955" 12 | 20 GOSUB1000 13 | 30 GOSUB1010:GOTO30 14 | 15 | 1000 DIMT(11):RESTORE:FORI=0TO11:READT(I):NEXT:DATA,3,2,5,,3,5,1,4,6,2,4:RETURN 16 | 17 | 1010 D$=DA$:Y=VAL(MID$(D$,1,4)):M=VAL(MID$(D$,5,2)):D=VAL(MID$(D$,7,2)) 18 | 1020 Y=Y+(M<3):T=Y+INT(Y/4)-INT(Y/100)+INT(Y/400)+T(M-1)+D:DW=T-INT(T/7)*7 19 | 1030 PRINTDW,DA$,TI$ 20 | 1040 RETURN 21 | 22 | RUN 23 | -------------------------------------------------------------------------------- /graphics/fonts/conio3b.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 KERNAL 2 | ; based on GEOS by Berkeley Softworks; reversed by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Font library: init 5 | 6 | .export GRAPH_set_font 7 | .export font_init 8 | 9 | GRAPH_set_font: 10 | lda r0L 11 | ora r0H 12 | bne set_font2 13 | font_init: 14 | LoadW r0, SystemFont 15 | set_font2: 16 | ldy #0 17 | lda (r0),y 18 | sta baselineOffset 19 | iny 20 | lda (r0),y 21 | sta curSetWidth 22 | iny 23 | lda (r0),y 24 | sta curSetWidth+1 25 | iny 26 | lda (r0),y 27 | sta curHeight 28 | iny 29 | lda (r0),y 30 | sta curIndexTable 31 | iny 32 | lda (r0),y 33 | sta curIndexTable+1 34 | iny 35 | lda (r0),y 36 | sta cardDataPntr 37 | iny 38 | lda (r0),y 39 | sta cardDataPntr+1 40 | AddW r0, curIndexTable 41 | AddW r0, cardDataPntr 42 | rts 43 | -------------------------------------------------------------------------------- /cfg/basic-x16.cfgtpl: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | #include "x16.cfginc" 3 | 4 | BASIC: start = $C000, size = $3B00, fill=yes, fillval=$AA; 5 | KSUP_CODE: start = $FB00, size = $0300, fill=yes, fillval=$AA; 6 | FPJMP: start = $FE00, size = $00A8, fill=yes, fillval=$AA; 7 | KSUP_VEC: start = $FEA8, size = $0158, fill=yes, fillval=$AA; 8 | } 9 | 10 | SEGMENTS { 11 | ZPBASIC: load = ZPBASIC, type = zp; 12 | BVECTORS: load = BVECTORS, type = bss; 13 | BVARS: load = BVARS, type = bss; 14 | 15 | ZPMATH: load = ZPMATH, type = zp; 16 | FPVARS: load = FPVARS, type = bss; 17 | 18 | BASIC: load = BASIC, type = ro; 19 | MATH: load = BASIC, type = ro; 20 | FPJMP: load = FPJMP, type = ro; 21 | KSUP_CODE: load = KSUP_CODE, type = ro; 22 | KSUP_VEC: load = KSUP_VEC, type = ro; 23 | } 24 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_return.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; RETURN key handling within CHROUT 7 | ; 8 | 9 | 10 | chrout_screen_RETURN: 11 | 12 | ; RETURN clears quote and insert modes, it also clears reverse flag 13 | 14 | lda #$00 15 | sta QTSW 16 | sta INSRT 17 | sta RVS 18 | 19 | ; RETURN key moves cursor two lines down in case 20 | ; of first line of the extended logical line 21 | 22 | ldy TBLX 23 | cpy nlinesm1 24 | beq :+ ; last line on screen - no need for a double line skip 25 | 26 | lda LDTBL+1, y 27 | bmi :+ ; current line is not continued 28 | 29 | inc TBLX 30 | jsr screen_calculate_PNT_USER 31 | : 32 | jmp screen_advance_to_next_line 33 | -------------------------------------------------------------------------------- /geos/kernal/graph/clrscr.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Graphics library: ClrScr 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .segment "graph1" 14 | 15 | .import i_Rectangle 16 | .import SetPattern 17 | 18 | .global ClrScr 19 | 20 | ;--------------------------------------------------------------- 21 | ; used by EnterDesktop 22 | ;--------------------------------------------------------------- 23 | ClrScr: 24 | LoadB dispBufferOn, ST_WR_FORE | ST_WR_BACK 25 | lda #2 26 | jsr SetPattern 27 | jsr i_Rectangle 28 | .byte 0 ; y1 29 | .byte SC_PIX_HEIGHT-1 ; y2 30 | .word 0 ; x1 31 | .word SC_PIX_WIDTH-1 ; x2 32 | rts 33 | -------------------------------------------------------------------------------- /scripts/c64-create-e000.sh: -------------------------------------------------------------------------------- 1 | # *** 2 | # Create VICE C64 KERNAL ROM image 3 | # *** 4 | 5 | set -e 6 | 7 | dd if=basic-orig.bin bs=256 skip=32 > build/c64/e000-with_basic.bin 2> /dev/null 8 | dd if=build/c64/kernal.bin bs=256 skip=5 count=27 >> build/c64/e000-with_basic.bin 2> /dev/null 9 | 10 | exit # disable code below for now 11 | 12 | # *** 13 | # *** Create VICE SuperCPU ROM image 14 | # *** 15 | 16 | # header 17 | dd if=scpu64-orig.bin of=scpu64 bs=256 count=1 18 | # basic #1 19 | # hi_basic #1 20 | cat basic-orig.bin >> scpu64 21 | # kernal #1 22 | dd if=c64-rom.bin bs=256 skip=5 count=27 >> scpu64 23 | # hi_basic #2 24 | dd if=basic-orig.bin bs=256 skip=32 >> scpu64 25 | # kernal #2 26 | dd if=c64-rom.bin bs=256 skip=5 count=27 >> scpu64 27 | # rest 28 | dd if=scpu64-orig.bin skip=97 bs=256 >> scpu64 29 | 30 | -------------------------------------------------------------------------------- /geos/kernal/conio/conio2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Console I/O: i_PutString syscall 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import _PutString 14 | 15 | .global _i_PutString 16 | 17 | .segment "conio2" 18 | 19 | _i_PutString: 20 | PopB r0L 21 | pla 22 | inc r0L 23 | bne @1 24 | addv 1 25 | @1: sta r0H 26 | ldy #0 27 | lda (r0),y 28 | inc r0L 29 | bne @2 30 | inc r0H 31 | @2: sta r11L 32 | lda (r0),y 33 | inc r0L 34 | bne @3 35 | inc r0H 36 | @3: sta r11H 37 | lda (r0),y 38 | inc r0L 39 | bne @4 40 | inc r0H 41 | @4: sta r1H 42 | jsr _PutString 43 | inc r0L 44 | bne @5 45 | inc r0H 46 | @5: jmp (r0) 47 | 48 | -------------------------------------------------------------------------------- /keymap/asm/426.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Latvian 5 | ; Locale: lv-LV 6 | ; KLID: 426 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "LV-LV", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_426 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_426: 16 | .incbin "asm/426.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; chars: "#'@^£π←" 22 | ; codes: CURSOR_DOWN 23 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 24 | ; Keys outside of PETSCII: 25 | ; '\_{|}~¨«­°±´»Õ×õĀāČčĒēĢģĪīĶķĻļŅņŖŗŠšŪūŽž–—’€' 26 | 27 | ; ISO 28 | ; ~~~ 29 | ; Keys outside of ISO-8859-15: 30 | ; '¨´ĀāČčĒēĢģĪīĶķĻļŅņŖŗŪū–—’' 31 | ; Non-reachable ISO-8859-15: 32 | ; ''*+` ¡¢£¥§©ª¬®¯²³µ¶·¹ºŒœŸ¿ÀÁÂÃÆÇÈÊËÌÍÎÏÐÑÒÔØÙÚÛÝÞßàáâãæçèêëìíîïðñòô÷øùúûýþ' 33 | 34 | -------------------------------------------------------------------------------- /kernal/open-roms/keyboard/f6ed.stop.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | .import kbdbuf_get_stop 6 | 7 | ; 8 | ; Official Kernal routine, described in: 9 | ; 10 | ; - [RG64] C64 Programmers Reference Guide - page 301 11 | ; - [CM64] Computes Mapping the Commodore 64 - page 232 12 | ; 13 | ; CPU registers that has to be preserved (see [RG64]): .Y 14 | ; 15 | 16 | STOP: 17 | ; Bit 7 of STKEY contains the state of the STOP key 18 | ; (Computes Mapping the 64, p27) 19 | 20 | ; BASIC checks carry flag to indicate STOP or not 21 | jsr kbdbuf_get_stop 22 | beq stop_pressed 23 | 24 | ; By trial and error, we know that Z + C = BREAK 25 | ; and that neither should be set otherwise 26 | lda #$FF 27 | clc 28 | rts 29 | 30 | stop_pressed: 31 | sec 32 | lda #$00 33 | rts 34 | -------------------------------------------------------------------------------- /codex/src/bank_assy_vars.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Vars to record predefined banks for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .psc02 ; Enable 65c02 instructions 9 | .feature labels_without_colons 10 | 11 | .ifndef __X16_BANK_ASSY_VARS__ 12 | __X16_BANK_ASSY_VARS__=1 13 | 14 | .data 15 | 16 | .export bank_max, bank_assy, bank_scr1, bank_scr2, bank_meta_l, bank_meta_i, bank_rom_orig, bank_plugin, bank_scrollback 17 | 18 | bank_max .byte 0 19 | bank_assy .byte 0 20 | bank_meta_l .byte 0 21 | bank_meta_i .byte 0 22 | bank_plugin .byte 0 23 | bank_scrollback .byte 0 24 | bank_scr1 .byte 0 25 | bank_scr2 .byte 0 26 | bank_rom_orig .byte 0 27 | 28 | .endif 29 | 30 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_tab.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Tabulation keys handling within CHROUT 7 | ; 8 | 9 | 10 | .if CONFIG_EDIT_TABULATORS 11 | 12 | 13 | chrout_screen_TAB_FW: 14 | 15 | jsr screen_get_clipped_PNTR 16 | tya 17 | ora #%00000111 18 | tay 19 | iny 20 | cpy llen 21 | bcc :+ 22 | ldy llen 23 | dey 24 | : 25 | sty PNTR 26 | 27 | jmp chrout_screen_calc_lptr_done 28 | 29 | 30 | chrout_screen_TAB_BW: 31 | 32 | jsr screen_get_clipped_PNTR 33 | beq :+ ; column 0, recalculating pointers is not necessary, but this is a rare case nevertheless 34 | 35 | dey 36 | tya 37 | and #%11111000 38 | sta PNTR 39 | : 40 | jmp chrout_screen_calc_lptr_done 41 | 42 | 43 | .endif ; CONFIG_EDIT_TABULATORS 44 | -------------------------------------------------------------------------------- /geos/kernal/load/load1b.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Loading 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import _EnterDT_Str1 14 | .import _EnterDT_Str0 15 | 16 | .global _EnterDT_DB 17 | 18 | .segment "load1b" 19 | 20 | .ifndef wheels 21 | _EnterDT_DB: 22 | .byte DEF_DB_POS | 1 23 | .byte DBTXTSTR, TXT_LN_X, TXT_LN_1_Y+6 24 | .word _EnterDT_Str0 25 | .byte DBTXTSTR, TXT_LN_X, TXT_LN_2_Y+6 26 | .word _EnterDT_Str1 27 | .byte OK, DBI_X_2, DBI_Y_2 28 | .byte NULL 29 | .endif 30 | 31 | .ifdef wheels_size 32 | .global IncR0JmpInd 33 | .global JmpR0Ind 34 | .import IncR0 35 | IncR0JmpInd: 36 | jsr IncR0 37 | JmpR0Ind: 38 | jmp (r0) 39 | .endif 40 | 41 | -------------------------------------------------------------------------------- /keymap/asm/427.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 PETSCII/ISO Keyboard Table 2 | ; ***this file is auto-generated!*** 3 | ; 4 | ; Name: Lithuanian IBM 5 | ; Locale: lt-LT 6 | ; KLID: 427 7 | 8 | .segment "KBDMETA" 9 | 10 | .byte "LT-LT", 0, 0, 0, 0, 0, 0, 0, 0, 0 11 | .word kbtab_427 12 | 13 | .segment "KBDTABLES" 14 | 15 | kbtab_427: 16 | .incbin "asm/427.bin.lzsa" 17 | 18 | ; PETSCII 19 | ; ~~~~~~~ 20 | ; C64 keyboard regressions: 21 | ; chars: "#$%&'<>@QQWWXX^£π←" 22 | ; codes: CURSOR_DOWN 23 | ; graph: '\xa4\xa6\xa8\xa9\xba' <--- *** THIS IS BAD! *** 24 | ; Keys outside of PETSCII: 25 | ; '\_{|}~ĄąČčĖėĘęĮįŠšŪūŲųŽž“”€' 26 | 27 | ; ISO 28 | ; ~~~ 29 | ; Keys outside of ISO-8859-15: 30 | ; 'ĄąČčĖėĘęĮįŪūŲų“”' 31 | ; Non-reachable ISO-8859-15: 32 | ; '#$%&'*<>@QWX^qwx ¡¢£¥§©ª«¬­®¯°±²³µ¶·¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ' 33 | 34 | -------------------------------------------------------------------------------- /cfg/monitor-x16.cfgtpl: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | #include "x16.cfginc" 3 | 4 | L0220: start = $0220, size = $0039; # overlaps with top end of BASIC input line only 5 | 6 | BANK5: start = $C000, size = $3B00, fill=yes, fillval=$AA; 7 | KSUP_CODE2: start = $FB00, size = $03A8, fill=yes, fillval=$AA; 8 | KSUP_VEC2: start = $FEA8, size = $0158, fill=yes, fillval=$AA; 9 | } 10 | 11 | SEGMENTS { 12 | monitor: load = BANK5, type = ro; 13 | asmchars1: load = BANK5, type = ro, define = yes; 14 | asmchars2: load = BANK5, type = ro, define = yes; 15 | mnemos1: load = BANK5, type = ro, define = yes; 16 | mnemos2: load = BANK5, type = ro, define = yes; 17 | monitor_ram_code: load = BANK5, run = L0220, type = ro, define = yes; 18 | KSUP_CODE2: load = KSUP_CODE2, type = ro; 19 | KSUP_VEC2: load = KSUP_VEC2, type = ro; 20 | } 21 | -------------------------------------------------------------------------------- /geos/kernal/memory/memory3.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Memory utility functions: i_FillRam 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import _FillRam 14 | .import GetMDataDatas 15 | 16 | .import DoInlineReturn 17 | 18 | .global _i_FillRam 19 | 20 | .segment "memory3" 21 | 22 | ;--------------------------------------------------------------- 23 | ; i_FillRam $C1B4 24 | ; 25 | ; Same as FillRam with data after the jsr 26 | ;--------------------------------------------------------------- 27 | _i_FillRam: 28 | PopW returnAddress 29 | jsr GetMDataDatas 30 | jsr _FillRam 31 | php 32 | lda #6 33 | jmp DoInlineReturn 34 | -------------------------------------------------------------------------------- /kernal/drivers/x16/smc.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; X16 System Management Controller Driver 3 | ;---------------------------------------------------------------------- 4 | ; (C)2021 Michael Steil, License: 2-clause BSD 5 | 6 | .segment "KVAR" 7 | activity_led_state: 8 | .res 1 9 | 10 | .segment "I2C" 11 | 12 | .import i2c_write_byte 13 | .export smc_set_activity_led 14 | 15 | uc_address = $42 16 | 17 | ; 0x01 0x00 - Power Off 18 | ; 0x01 0x01 - Hard Reboot 19 | ; 0x02 0x00 - Reset Button Press 20 | ; 0x03 0x00 - NMI Button Press 21 | ; 0x04 0x00-0xFF - Power LED Level (PWM) 22 | ; 0x05 0x00-0xFF - Activity LED Level (PWM) 23 | 24 | smc_set_activity_led: 25 | cmp activity_led_state 26 | beq @rts 27 | sta activity_led_state 28 | ldx #uc_address 29 | ldy #5 30 | jmp i2c_write_byte 31 | @rts: rts 32 | -------------------------------------------------------------------------------- /kernal/open-roms/interrupts/ea81.return_from_interrupt.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; The IRQ is a commonly messed with thing on the C64, 6 | ; so we need to handle entry points that are commonly 7 | ; relied upon, including: 8 | ; $EA31 - Standard IRQ routine 9 | ; $EA61 - Check keyboard, but do not update timer? https:;github.com/cc65/cc65/issues/324 10 | ; $EA81 - https:;www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb 11 | ; Also the $0314 vector is widely used (e.g., https:;www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb) 12 | 13 | 14 | return_from_interrupt: 15 | 16 | ; Restore registers and return 17 | ; Sequence according to Computes Mapping the 64 p73 18 | 19 | ply_trash_a 20 | plx_trash_a 21 | pla 22 | 23 | rti 24 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/cursor_show.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Variables used: 7 | ; - BLNSW (cursor blink switch) 8 | ; - BLNON (if cursor is visible) 9 | ; - BLNCT (cursor blink countdown) 10 | ; 11 | 12 | 13 | cursor_show_if_enabled: 14 | lda BLNSW 15 | bne cursor_show_end 16 | lda BLNON 17 | bne cursor_show_end 18 | 19 | ; FALLTROUGH 20 | 21 | cursor_show: 22 | 23 | ; Set cursor as though it had just finished the off phase, 24 | ; so that the call to cursor_blink paints it 25 | lda #$00 26 | sta BLNCT 27 | sta BLNON 28 | jsr cursor_blink 29 | 30 | ; Then set the timeout to 1 frame, so that the cursor 31 | ; blinks under key repeat conditions, like on the original KERNAL 32 | lda #$01 33 | sta BLNCT 34 | 35 | ; FALLTROUGH 36 | 37 | cursor_show_end: 38 | rts 39 | -------------------------------------------------------------------------------- /basic/basic.s: -------------------------------------------------------------------------------- 1 | .feature labels_without_colons 2 | 3 | .include "banks.inc" 4 | .include "kernal.inc" 5 | .include "../math/math.inc" 6 | 7 | ; XXX exports for Math library 8 | .global error, fcerr ; code 9 | .global errdvo, errov ; constants 10 | 11 | ; for emulator 12 | .global vartab 13 | 14 | .include "declare.s" 15 | .include "tokens.s" 16 | .include "token2.s" 17 | .include "code1.s" 18 | .include "code2.s" 19 | .include "code3.s" 20 | .include "code4.s" 21 | .include "code5.s" 22 | .include "code6.s" 23 | .include "code7.s" 24 | .include "code8.s" 25 | .include "code9.s" 26 | .include "code10.s" 27 | .include "code11.s" 28 | .include "code12.s" 29 | .include "code13.s" 30 | .include "code14.s" 31 | .include "code15.s" 32 | .include "code16.s" 33 | .include "code17.s" 34 | .include "code26.s" 35 | .include "init.s" 36 | .include "x16additions.s" 37 | .include "graph.s" 38 | 39 | -------------------------------------------------------------------------------- /geos/kernal/mouse/mouse3.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Mouse 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global RcvrMnu0 14 | .global ResetMseRegion 15 | 16 | .segment "mouse3" 17 | 18 | .ifndef wheels 19 | ResetMseRegion: 20 | lda #NULL 21 | sta mouseLeft 22 | sta mouseLeft+1 23 | sta mouseTop 24 | .ifdef bsw128 25 | LoadB mouseBottom, SC_PIX_HEIGHT-1 26 | bbsf 7, graphMode, @2 27 | LoadW mouseRight, SC_PIX_WIDTH-1 28 | bbrf 7, graphMode, @1 29 | LoadW mouseRight, SCREENPIXELWIDTH-1 30 | @1: rts 31 | @2: LoadW mouseRight, SCREENPIXELWIDTH-1 32 | .else 33 | LoadW mouseRight, SC_PIX_WIDTH-1 34 | LoadB mouseBottom, SC_PIX_HEIGHT-1 35 | .endif 36 | rts 37 | .endif 38 | 39 | -------------------------------------------------------------------------------- /kernal/graph/console.s: -------------------------------------------------------------------------------- 1 | .export console_get_char 2 | .export console_init 3 | .export console_put_char 4 | .export console_put_image 5 | .export console_set_paging_message 6 | 7 | .import jsrfar 8 | .include "banks.inc" 9 | .include "graphics.inc" 10 | 11 | .segment "GRAPH" 12 | console_get_char: 13 | jsr jsrfar 14 | .word gr_console_get_char 15 | .byte BANK_GRAPH 16 | rts 17 | 18 | console_init: 19 | jsr jsrfar 20 | .word gr_console_init 21 | .byte BANK_GRAPH 22 | rts 23 | 24 | console_put_char: 25 | jsr jsrfar 26 | .word gr_console_put_char 27 | .byte BANK_GRAPH 28 | rts 29 | 30 | console_put_image: 31 | jsr jsrfar 32 | .word gr_console_put_image 33 | .byte BANK_GRAPH 34 | rts 35 | 36 | console_set_paging_message: 37 | jsr jsrfar 38 | .word gr_console_set_paging_message 39 | .byte BANK_GRAPH 40 | rts -------------------------------------------------------------------------------- /codex/inc/vera.inc: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; VERA interface for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .ifndef __X16_VERA__ 9 | __X16_VERAL__=1 10 | 11 | .import vera_out_a, vera_goto_xy, vera_goto, VERA_DATA0, VERA_DATA1, VERA_ADDR_LO, VERA_ADDR_MID, VERA_ADDR_HI 12 | 13 | ;; 14 | ;; Output character 15 | ;; Clobbers A,Y 16 | .macro charOut c 17 | lda #c 18 | jsr vera_out_a 19 | .endmacro 20 | 21 | ;; 22 | ;; Inline characer writer (from accumulator) 23 | ;; Clobbers A,Y 24 | ;; 25 | .macro charOutA 26 | jsr vera_out_a 27 | .endmacro 28 | 29 | .macro vgotoXY col, row 30 | ldx #col 31 | ldy #row 32 | jsr vera_goto_xy 33 | .endmacro 34 | 35 | .macro vgoto 36 | jsr vera_goto 37 | .endmacro 38 | 39 | .endif 40 | 41 | -------------------------------------------------------------------------------- /geos/kernal/math/dec.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Math library: Ddec syscall 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global _Ddec 14 | 15 | .segment "math1c2" 16 | 17 | ;--------------------------------------------------------------- 18 | ; Ddec $C175 19 | ; 20 | ; Function: Decrements an unsigned word 21 | ; 22 | ; Pass: x add. of zpage contaning the nbr 23 | ; Return: x zpage: contains the decremented nbr 24 | ; Destroyed: a 25 | ;--------------------------------------------------------------- 26 | _Ddec: 27 | lda zpage,x 28 | bne @1 29 | dec zpage+1,x 30 | @1: dec zpage,x 31 | lda zpage,x 32 | ora zpage+1,x 33 | rts 34 | 35 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: ROM Build CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: actions/setup-python@v4 12 | with: 13 | python-version: '3.9' 14 | - name: Install Dependencies 15 | run: | 16 | sudo apt-get install -y make build-essential 17 | git clone https://github.com/cc65/cc65.git 18 | cd cc65 19 | make -j4 20 | sudo make install 21 | - name: Build ROM 22 | run: | 23 | make 24 | mkdir artifact 25 | cp build/x16/*.h artifact/. 26 | cp build/x16/*.sym artifact/. 27 | cp build/x16/rom.bin artifact/. 28 | - name: Archive Build Result 29 | uses: actions/upload-artifact@v3 30 | with: 31 | name: ROM Image 32 | path: artifact -------------------------------------------------------------------------------- /geos/kernal/mouse/mouse1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Mouse: IsMseInRegion syscalls 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import NormalizeX 14 | 15 | .global _IsMseInRegion 16 | 17 | .segment "mouse1" 18 | 19 | _IsMseInRegion: 20 | .ifdef bsw128 21 | txa 22 | pha 23 | ldx #r3 24 | jsr NormalizeX 25 | ldx #r4 26 | jsr NormalizeX 27 | pla 28 | tax 29 | .endif 30 | lda mouseYPos 31 | cmp r2L 32 | bcc @5 33 | cmp r2H 34 | beq @1 35 | bcs @5 36 | @1: lda mouseXPos+1 37 | cmp r3H 38 | bne @2 39 | lda mouseXPos 40 | cmp r3L 41 | @2: bcc @5 42 | lda mouseXPos+1 43 | cmp r4H 44 | bne @3 45 | lda mouseXPos 46 | cmp r4L 47 | @3: beq @4 48 | bcs @5 49 | @4: lda #$ff 50 | rts 51 | @5: lda #0 52 | rts 53 | 54 | -------------------------------------------------------------------------------- /geos/kernal/math/shr.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .ifdef wheels 14 | .import BBMult_ret 15 | .endif 16 | 17 | .global _DShiftRight 18 | 19 | .segment "math1a2" 20 | 21 | ;--------------------------------------------------------------- 22 | ;--------------------------------------------------------------- 23 | _DShiftRight: 24 | dey 25 | .ifdef wheels 26 | .ifdef wheels 27 | .if 0 ; XXX cc65 issue: branch can't cross segment 28 | bmi BBMult_ret 29 | .else 30 | .byte $30, <(BBMult_ret - (* + 1)) 31 | .endif 32 | .else 33 | bmi @1 34 | .endif 35 | .else 36 | bmi @1 37 | .endif 38 | lsr zpage+1,x 39 | ror zpage,x 40 | jmp _DShiftRight 41 | .ifndef wheels 42 | @1: rts 43 | .endif 44 | 45 | -------------------------------------------------------------------------------- /kernal/cbm/channel/messages.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; Channel: Messages 3 | ;---------------------------------------------------------------------- 4 | ; (C)1983 Commodore Business Machines (CBM) 5 | ; additions: (C)2020 Michael Steil, License: 2-clause BSD 6 | 7 | ms1 .byt $d,"I/O ERROR ",$a3 8 | ms5 .byt $d,"SEARCHING",$a0 9 | ms6 .byt "FOR",$a0 10 | ms7 .byte " FROM ",'$'+$80 11 | ms8 .byte " TO ",'$'+$80 12 | ms10 .byt $d,"LOADIN",$c7 13 | ms11 .byt $d,"SAVING",$a0 14 | ms21 .byt $d,"VERIFYIN",$c7 15 | ms17 .byt $d,"FOUND",$a0 16 | ms18 .byt $d,"OK",$8d 17 | ; ms34 .byt $d,"MONITOR",$8d 18 | ; ms36 .byt $d,"BREA",$cb 19 | 20 | ;print message to screen only if 21 | ;output enabled 22 | ; 23 | spmsg bit msgflg ;printing messages? 24 | bpl msg10 ;no... 25 | msg lda ms1,y 26 | php 27 | and #$7f 28 | jsr bsout 29 | iny 30 | plp 31 | bpl msg 32 | msg10 clc 33 | rts 34 | 35 | -------------------------------------------------------------------------------- /cfg/codex-x16.cfgtpl: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | #include "x16.cfginc" 3 | 4 | MAIN: file = %O, define = yes, start = $C000, size = $3AE2, fill=yes fillval=$A3; 5 | RWRAM: file = "", start = $0400, size = $3FF; 6 | BANK: file = "", start = $A000, size = $2000; 7 | CODEX_VECS: start = $FAE2, size = $001E, fill=yes, fillval=$A0; 8 | KSUP_CODE2: start = $FB00, size = $03A8, fill=yes, fillval=$A1; 9 | KSUP_VEC2: start = $FEA8, size = $0158, fill=yes, fillval=$A2; 10 | } 11 | 12 | SEGMENTS { 13 | CODE: load = MAIN, type = ro; 14 | DATA: load = RWRAM, type = rw; 15 | META_L: load = BANK, type = rw; 16 | META_I: load = BANK, type = rw; 17 | CODEX_STATE:load = BANK, type = rw; 18 | CODEX_VECS: load = CODEX_VECS, type = ro; 19 | KSUP_CODE2: load = KSUP_CODE2, type = ro; 20 | KSUP_VEC2: load = KSUP_VEC2, type = ro; 21 | } 22 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/readst.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 292 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 239 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .X, .Y 12 | ; 13 | 14 | READST: 15 | 16 | ; Check the current device number 17 | 18 | lda FA 19 | cmp #$02 20 | bne :+ 21 | 22 | ; This is RS-232 device - according to 'Computes Mapping the Commodore 64' page 239 23 | ; it reads status from RSSTAT 24 | ; XXX 'lda RSSTAT' not possible due to extended scnkey, fix it! 25 | lda #$FF 26 | rts 27 | : 28 | ; According to 'Computes Mapping the Commodore 64' page 239, it usually retrieves 29 | ; status from IOSTATUS 30 | 31 | ; XXX is it always the case if device is not RS-232 ? 32 | 33 | lda IOSTATUS 34 | rts 35 | -------------------------------------------------------------------------------- /codex/cfg/utest.cfg: -------------------------------------------------------------------------------- 1 | FEATURES { 2 | STARTADDRESS: default = $0801; 3 | } 4 | SYMBOLS { 5 | __LOADADDR__: type = weak, value = %S; 6 | __HIMEM__: type = weak, value = $9F00; 7 | } 8 | MEMORY { 9 | ZP: file = "", define = yes, start = $0022, size = $0080 - $0022; 10 | BOOTSTRAP: file = %O, start = %S - 2, size = $0012; 11 | MAIN: file = %O, define = yes, start = %S + $0F, size = __HIMEM__ - %S; 12 | BANK: file = "", start = $A000, size = $2000; 13 | } 14 | SEGMENTS { 15 | BOOTSTRAP: load = BOOTSTRAP, type = ro; 16 | CODE: load = MAIN, type = ro; 17 | RODATA: load = MAIN, type = ro; 18 | DATA: load = MAIN, type = rw; 19 | META_L: load = BANK, type = rw; 20 | META_I: load = BANK, type = rw; 21 | CODEX_STATE: load = BANK, type = rw; 22 | } 23 | -------------------------------------------------------------------------------- /codex/src/screen_vars.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Screen control vars for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .psc02 ; Enable 65c02 instructions 9 | .feature labels_without_colons 10 | 11 | .data 12 | 13 | .export orig_color, input_string_length, input_string, input_string_cursor 14 | .export screen_width, screen_height, screen_row_prompt, screen_row_data_count, screen_last_row 15 | .export print_to_file 16 | 17 | orig_color .byte 0 18 | input_string_length .byte 0 19 | input_string .res 64, 0 20 | input_string_cursor .word 0 ; timer to blink 21 | 22 | print_to_file .byte 0 23 | 24 | screen_width .byte 0 25 | screen_height .byte 0 26 | screen_row_prompt .byte 0 27 | screen_row_data_count .byte 0 28 | screen_last_row .byte 0 29 | 30 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/e50a.plot.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 290 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 215 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): none 12 | ; 13 | 14 | 15 | PLOT: 16 | 17 | bcs plot_get 18 | 19 | ; Note: the 'set' part has to start from $E50C, as this is a known address 20 | ; - https:;www.lemon64.com/forum/viewtopic.php?t=3296&%3Bstart=15 21 | ; - https:;sys64738.org/2019/05/c64-bedtime-coding-eng-printing-08/ 22 | ; - 'Duotris' game calls $E50C during startup screen initialization 23 | 24 | plot_set: 25 | 26 | sty PNTR 27 | stx TBLX 28 | 29 | jsr screen_calculate_pointers 30 | 31 | ; FALLTROUGH to save one byte on RTS 32 | 33 | plot_get: 34 | 35 | ldy PNTR 36 | ldx TBLX 37 | rts 38 | -------------------------------------------------------------------------------- /kernal/open-roms/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The following copyright notices apply to the entirety of this package, 3 | including each source file, unless otherwise noted in each file. 4 | 5 | Copyright Paul Gardner-Stephen, 2019. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this program. If not, see . 19 | 20 | 21 | -------------------------------------------------------------------------------- /kernal/open-roms/interrupts/fe47.default_nmi_handler.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | default_nmi_handler: 7 | 8 | ; Implemented according to Computes Mapping the Commodore 64, page 74 9 | ; and to https:;www.c64-wiki.com/wiki/Interrupt 10 | 11 | ; Save registers, sequence according to Computes Mapping the Commodore 64, page 73 12 | pha 13 | phx_trash_a 14 | phy_trash_a 15 | 16 | ; XXX: RS-232 support is not implemented 17 | 18 | ; XXX confirm NMIs from CIA, or no other NMI will arrive! 19 | 20 | .if 0 21 | jsr cartridge_check 22 | bne !+ 23 | jmp (ICART_WARM_START) 24 | !: 25 | .endif 26 | ; According to C64 Wiki, if STOP key is pressed, the routine assumes warm start request 27 | 28 | ; XXX is it right? how to check that IRQ was caused by RESTORE? 29 | 30 | jsr JSTOP 31 | bcs :+ 32 | jmp return_from_interrupt ; no STOP pressed 33 | : 34 | jmp (CBINV) 35 | -------------------------------------------------------------------------------- /geos/kernal/serial/serial2.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Serial number 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import SerialNumber 14 | 15 | .global _GetSerialNumber 16 | .global GetSerialNumber2 17 | 18 | .segment "serial2" 19 | 20 | ;--------------------------------------------------------------- 21 | ; GetSerialNumber $C196 22 | ; 23 | ; Pass: nothing 24 | ; Return: r0 serial nbr of your kernal 25 | ; Destroyed: a 26 | ;--------------------------------------------------------------- 27 | _GetSerialNumber: 28 | lda SerialNumber 29 | sta r0L 30 | GetSerialNumber2: 31 | lda SerialNumber+1 32 | sta r0H 33 | rts 34 | 35 | .if (!.defined(wheels_size)) && (!.defined(bsw128)) 36 | .byte 1, $60 ; ??? 37 | .endif 38 | -------------------------------------------------------------------------------- /codex/cfg/cx-dc.cfg: -------------------------------------------------------------------------------- 1 | FEATURES { 2 | STARTADDRESS: default = $a000; 3 | } 4 | SYMBOLS { 5 | __LOADADDR__: type = weak, value = %S; 6 | __HIMEM__: type = weak, value = $9F00; 7 | } 8 | MEMORY { 9 | ZP: file = "", define = yes, start = $0022, size = $0080 - $0022; 10 | PLUGIN: file = %O, start = %S - 2, size = $5; 11 | RWRAM: file = "", start = $0400, size = $3FF; 12 | MAIN: file = %O, define = yes, start = %S + $3, size = $2000 - %S; 13 | BANK: file = "", start = $A000, size = $2000; 14 | } 15 | SEGMENTS { 16 | PLUGIN: load = PLUGIN, type = ro; 17 | CODE: load = MAIN, type = ro; 18 | DATA: load = RWRAM, type = rw; 19 | META_L: load = BANK, type = rw; 20 | META_I: load = BANK, type = rw; 21 | CODEX_STATE: load = BANK, type = rw; 22 | } 23 | -------------------------------------------------------------------------------- /geos/kernal/init/init1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Machine initialization 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import InitRamTab 14 | .import _DoFirstInitIO 15 | .import _InitRam 16 | 17 | .global InitGEOEnv 18 | .global _InitMachine 19 | .ifdef bsw128 20 | .global _InitMachine2 21 | .endif 22 | 23 | .segment "init1" 24 | 25 | _InitMachine: 26 | jsr _DoFirstInitIO 27 | .ifdef bsw128 28 | .import SetRightMargin 29 | .import SetNewMode0 30 | _InitMachine2: 31 | jsr InitGEOEnv 32 | jmp SetNewMode0 33 | .endif 34 | InitGEOEnv: 35 | LoadW r0, InitRamTab 36 | .ifdef bsw128 37 | jsr _InitRam 38 | jmp SetRightMargin 39 | .else 40 | .ifdef wheels 41 | .assert * = _InitRam, error, "Code must run into _InitRam" 42 | .else 43 | jmp _InitRam 44 | .endif 45 | .endif 46 | 47 | -------------------------------------------------------------------------------- /codex/cfg/dev.cfg: -------------------------------------------------------------------------------- 1 | FEATURES { 2 | STARTADDRESS: default = $0801; 3 | } 4 | SYMBOLS { 5 | __LOADADDR__: type = weak, value = %S; 6 | __HIMEM__: type = weak, value = $9F00; 7 | } 8 | MEMORY { 9 | ZP: file = "", define = yes, start = $0022, size = $0080 - $0022; 10 | BOOTSTRAP: file = %O, start = %S - 2, size = $12; 11 | RWRAM: file = "", start = $0400, size = $3FF; 12 | MAIN: file = %O, define = yes, start = %S + $0F, size = __HIMEM__ - %S; 13 | BANK: file = "", start = $A000, size = $2000; 14 | } 15 | SEGMENTS { 16 | BOOTSTRAP: load = BOOTSTRAP, type = ro; 17 | CODE: load = MAIN, type = ro; 18 | DATA: load = RWRAM, type = rw; 19 | META_L: load = BANK, type = rw; 20 | META_I: load = BANK, type = rw; 21 | CODEX_STATE: load = BANK, type = rw; 22 | } 23 | -------------------------------------------------------------------------------- /kernal/open-roms/assets/fd30.vector_defaults.s: -------------------------------------------------------------------------------- 1 | 2 | ; 3 | ; Default values for Kernal vectors - described in: 4 | ; 5 | ; - [RG64] C64 Programmers Reference Guide - page 293 (RESTOR), 304 (VECTOR) 6 | ; - [CM64] Computes Mapping the Commodore 64 - page 237 7 | ; 8 | 9 | vector_defaults: 10 | .word default_irq_handler ; CINV 11 | .word default_brk_handler ; CBINV 12 | .word default_nmi_handler ; NMINV 13 | 14 | .word OPEN ; IOPEN 15 | .word CLOSE ; ICLOSE 16 | .word CHKIN ; ICHKIN 17 | .word CKOUT ; ICKOUT 18 | .word CLRCHN ; ICLRCH 19 | .word CHRIN ; IBASIN 20 | .word CHROUT ; IBSOUT 21 | .word STOP ; ISTOP 22 | .word GETIN ; IGETIN 23 | .word CLALL ; ICLALL 24 | .word default_brk_handler ; USRCMD 25 | .word LOAD ; ILOAD 26 | .word SAVE ; ISAVE 27 | 28 | 29 | -------------------------------------------------------------------------------- /codex/cfg/cx-plugin.cfg: -------------------------------------------------------------------------------- 1 | FEATURES { 2 | STARTADDRESS: default = $a000; 3 | } 4 | SYMBOLS { 5 | __LOADADDR__: type = weak, value = %S; 6 | __HIMEM__: type = weak, value = $9F00; 7 | } 8 | MEMORY { 9 | ZP: file = "", define = yes, start = $0022, size = $0080 - $0022; 10 | PLUGIN: file = %O, start = %S - 2, size = $5; 11 | RWRAM: file = "", start = $0400, size = $3FF; 12 | MAIN: file = %O, define = yes, start = %S + $3, size = $2000 - %S; 13 | BANK: file = "", start = $A000, size = $2000; 14 | } 15 | SEGMENTS { 16 | PLUGIN: load = PLUGIN, type = ro; 17 | CODE: load = MAIN, type = ro; 18 | DATA: load = RWRAM, type = rw; 19 | META_L: load = BANK, type = rw; 20 | META_I: load = BANK, type = rw; 21 | CODEX_STATE: load = BANK, type = rw; 22 | } 23 | -------------------------------------------------------------------------------- /geos/kernal/graph/inline.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global GetInlineDrwParms 14 | 15 | .segment "inline" 16 | 17 | GetInlineDrwParms: 18 | .ifdef bsw128 19 | PopW r6 20 | .endif 21 | PopW r5 22 | PopW returnAddress 23 | .ifdef wheels_size 24 | ldy #0 25 | @1: iny 26 | lda (returnAddress),y 27 | sta r1H,y 28 | cpy #6 29 | bne @1 30 | .else 31 | ldy #1 32 | lda (returnAddress),Y 33 | sta r2L 34 | iny 35 | lda (returnAddress),Y 36 | sta r2H 37 | iny 38 | lda (returnAddress),Y 39 | sta r3L 40 | iny 41 | lda (returnAddress),Y 42 | sta r3H 43 | iny 44 | lda (returnAddress),Y 45 | sta r4L 46 | iny 47 | lda (returnAddress),Y 48 | sta r4H 49 | .endif 50 | PushW r5 51 | .ifdef bsw128 52 | PushW r6 53 | .endif 54 | rts 55 | 56 | -------------------------------------------------------------------------------- /kernal/open-roms/init/e518.cint_legacy.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Part of the official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 280 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 242 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): none 12 | ; 13 | 14 | 15 | cint_legacy: ; $E518 16 | 17 | ; Setup video and I/O 18 | ; See here: https:;csdb.dk/forums/index.php?roomid=11&topicid=17048&firstpost=22 19 | jsr screen_init 20 | lda #2 ;80x60 21 | ; lda #0 ;40x30 22 | clc 23 | jsr screen_mode ;set screen mode to default 24 | jsr clrchn_reset 25 | 26 | ; Code below must be placed under $E51B, or some code will break - see here: 27 | ; - https:;csdb.dk/forums/index.php?roomid=11&topicid=17048&firstpost=2 28 | ; Game 'Operacja Proboszcz' is one example. 29 | 30 | jmp cint_screen_keyboard ; XXX try to fit the code here 31 | -------------------------------------------------------------------------------- /geos/kernal/graph/graph2l1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Graphics library 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import GraphPenX 14 | .import GraphPenY 15 | .import GetCoords 16 | 17 | GraphPenXL = GraphPenX 18 | GraphPenXH = GraphPenX+1 19 | 20 | .global GrStSetCoords 21 | 22 | .segment "graph2l1" 23 | 24 | GrStSetCoords: 25 | jsr GetCoords 26 | cmp GraphPenY 27 | bcs @1 28 | sta r2L 29 | pha 30 | lda GraphPenY 31 | sta r2H 32 | bra @2 33 | @1: sta r2H 34 | pha 35 | lda GraphPenY 36 | sta r2L 37 | @2: PopB GraphPenY 38 | cpy GraphPenXH 39 | beq @3 40 | bcs @5 41 | @3: bcc @4 42 | cpx GraphPenXL 43 | bcs @5 44 | @4: stx r3L 45 | sty r3H 46 | MoveW GraphPenX, r4 47 | bra @6 48 | @5: stx r4L 49 | sty r4H 50 | MoveW GraphPenX, r3 51 | @6: stx GraphPenXL 52 | sty GraphPenXH 53 | rts 54 | 55 | -------------------------------------------------------------------------------- /geos/kernal/time/time1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; C64/CIA clock driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import alarmWarnFlag 14 | 15 | .global _DoUpdateTime 16 | 17 | .segment "time1" 18 | 19 | _DoUpdateTime: 20 | ; XXX TODO * read clock from KERNAL 21 | ; * convert into h:m:s 22 | ; * store y-m-d h:m:s in year/month/dat/hour/minutes/seconds 23 | ldy #5 24 | : lda dateCopy,y 25 | sta year,y 26 | dey 27 | bpl :- 28 | .if 0 ; XXX TODO alarm logic 29 | bbrf 7, alarmSetFlag, @5 30 | and #ALARMMASK 31 | beq @6 32 | lda #$4a 33 | sta alarmSetFlag 34 | lda alarmTmtVector 35 | ora alarmTmtVector+1 36 | beq @5 37 | jmp (alarmTmtVector) 38 | @5: bbrf 6, alarmSetFlag, @6 39 | ; XXX TODO bell 40 | @6: 41 | .endif 42 | rts 43 | 44 | dateCopy: 45 | .byte 19,09,27 46 | .byte 9,41,0 47 | -------------------------------------------------------------------------------- /test/vpeek-vpoke.bas: -------------------------------------------------------------------------------- 1 | 100 REM TEST PROGRAM FOR X16-ROM ISSUE #167 2 | 110 REM FOR FIX BY JEREMY DILATUSH 3 | 120 REM 29 SEP 2021 4 | 130 REM THEORY OF OPERATION: 5 | 140 REM PERFORM OPERATIONS A LOT (IN VERY SIMPLE WAYS) TO SEE 6 | 150 REM HOW LONG THEY TAKE WITH AND WITHOUT THE FIX. 7 | 190 : 8 | 200 PRINT"100,000 VPOKE" 9 | 210 T1=TI 10 | 220 FORI=0TO9999 11 | 230 VPOKE0,0,0 12 | 231 VPOKE0,0,0 13 | 232 VPOKE0,0,0 14 | 233 VPOKE0,0,0 15 | 234 VPOKE0,0,0 16 | 235 VPOKE0,0,0 17 | 236 VPOKE0,0,0 18 | 237 VPOKE0,0,0 19 | 238 VPOKE0,0,0 20 | 239 VPOKE0,0,0 21 | 240 NEXT 22 | 250 T2=TI 23 | 260 T=T2-T1 24 | 270 PRINTT;"JIFFIES ELAPSED -- ";T/60;" SEC" 25 | 390 : 26 | 400 PRINT"100,000 VPEEK" 27 | 410 T1=TI 28 | 420 FORI=0TO9999 29 | 430 A=VPEEK(0,0) 30 | 431 A=VPEEK(0,0) 31 | 432 A=VPEEK(0,0) 32 | 433 A=VPEEK(0,0) 33 | 434 A=VPEEK(0,0) 34 | 435 A=VPEEK(0,0) 35 | 436 A=VPEEK(0,0) 36 | 437 A=VPEEK(0,0) 37 | 438 A=VPEEK(0,0) 38 | 439 A=VPEEK(0,0) 39 | 440 NEXT 40 | 450 T2=TI 41 | 460 PRINTT;"JIFFIES ELAPSED -- ";T/60;" SEC" 42 | 490 : 43 | -------------------------------------------------------------------------------- /kernal/drivers/c64/entropy.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; C64 Entropy Driver 3 | ;---------------------------------------------------------------------- 4 | ; (C)2020 Michael Steil, License: 2-clause BSD 5 | 6 | .export entropy_init, entropy_get 7 | 8 | .segment "ENTROPY" 9 | 10 | ;--------------------------------------------------------------- 11 | ; entropy_init 12 | ; 13 | ; Function: Initialize entropy generator 14 | ; 15 | ;--------------------------------------------------------------- 16 | entropy_init: 17 | rts 18 | 19 | ;--------------------------------------------------------------- 20 | ; entropy_get 21 | ; 22 | ; Function: Return 24 random bits 23 | ; 24 | ; Return: a random value 25 | ; x random value 26 | ; y random value 27 | ;--------------------------------------------------------------- 28 | ; XXX TODO This is pretty weak. We should set up a timer line on 29 | ; XXX TODO the X16. 30 | entropy_get: 31 | lda $d012 32 | tax 33 | tay 34 | rts 35 | -------------------------------------------------------------------------------- /geos/kernal/misc/misc.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Misc 6502 helpers 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | 12 | ; syscalls 13 | .global _CallRoutine 14 | .global _DoInlineReturn 15 | 16 | .segment "misc" 17 | 18 | ;--------------------------------------------------------------- 19 | ;--------------------------------------------------------------- 20 | _CallRoutine: 21 | .ifndef wheels_size_and_speed 22 | cmp #0 23 | bne @1 24 | cpx #0 25 | beq @2 26 | .endif 27 | @1: sta CallRLo 28 | stx CallRHi 29 | .ifdef wheels_size_and_speed 30 | ora CallRHi 31 | beq @2 32 | .endif 33 | jmp (CallRLo) 34 | @2: rts 35 | 36 | ;--------------------------------------------------------------- 37 | ;--------------------------------------------------------------- 38 | _DoInlineReturn: 39 | add returnAddress 40 | sta returnAddress 41 | bcc @1 42 | inc returnAddress+1 43 | @1: plp 44 | jmp (returnAddress) 45 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/clall_real.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 281 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 230 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .Y 12 | ; 13 | 14 | 15 | clall_real: 16 | 17 | ; Store .Y register 18 | phy_trash_a 19 | 20 | ; Original routine probably just sets LDTND to 0, but this is not really safe, 21 | ; so we actually close all the channels; at least IDE64 does the same for 22 | ; its channels, see CLALL description in the IDE64 Users Guide 23 | : 24 | ldy LDTND 25 | beq :+ 26 | dey 27 | lda LAT, y 28 | jsr JCLOSE 29 | jmp :- 30 | : 31 | ; Restore .Y register 32 | ply_trash_a 33 | 34 | ; 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too 35 | jsr CLRCHN 36 | 37 | ; Not sure whether original Kernal does so, but it seems sane to also clear possible errors 38 | jmp kernalstatus_reset 39 | -------------------------------------------------------------------------------- /geos/kernal/graph/pattern.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Graphics library: SetPattern syscall 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .setcpu "65c02" 14 | 15 | .import g_col1 16 | 17 | .global _SetPattern 18 | 19 | .segment "graph2l2" 20 | 21 | ;--------------------------------------------------------------- 22 | ; SetPattern $C139 23 | ; 24 | ; Pass: a pattern nbr (0-33) 25 | ; Return: g_col1 - updated 26 | ; Destroyed: a 27 | ;--------------------------------------------------------------- 28 | _SetPattern: 29 | ; convert patterns (0-33) into colors that look nice 30 | cmp #2 ; 50% shading 31 | beq @a 32 | cmp #9 ; horizontal stripes 33 | beq @b 34 | cmp #2 35 | bcs @c 36 | eor #1 ; swap black and white 37 | bra @c 38 | @a: lda #14 ; light blue 39 | bra @c 40 | @b: lda #6 ; dark blue 41 | @c: sta g_col1 42 | rts 43 | 44 | -------------------------------------------------------------------------------- /geos/kernal/load/load1c.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Loading 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global DeskTopName 14 | .global _EnterDT_Str1 15 | .global _EnterDT_Str0 16 | 17 | .segment "load1c" 18 | 19 | DeskTopName: 20 | .if 0 21 | .byte "GEOWRITE", 0 22 | .else 23 | .byte "DESK TOP", 0 24 | .endif 25 | 26 | .segment "load1d" 27 | 28 | _EnterDT_Str0: 29 | .ifdef bsw128 30 | .byte BOLDON, "Please insert a disk with the", 0 31 | .else 32 | .byte BOLDON, "Please insert a disk", 0 33 | .endif 34 | _EnterDT_Str1: 35 | .ifndef bsw128 36 | .byte "with " 37 | .endif 38 | .ifdef bsw128 39 | .byte "128 DESKTOP" 40 | .elseif .defined(gateway) 41 | .byte "gateWay" 42 | .else 43 | .byte "deskTop" 44 | .endif 45 | .byte " V" 46 | .ifdef bsw128 47 | .byte "2.0" 48 | .elseif .defined(wheels) 49 | .byte "3.0" 50 | .else 51 | .byte "1.5" 52 | .endif 53 | .byte " or higher", 0 54 | -------------------------------------------------------------------------------- /test/clock.bas: -------------------------------------------------------------------------------- 1 | 0 REM--------------------------------------------------------------- 2 | 1 REM UNIT TEST FOR KERNAL API: 3 | 2 REM CLOCK_SET_DATE_TIME 4 | 3 REM CLOCK_GET_DATE_TIME 5 | 4 REM--------------------------------------------------------------- 6 | 5 REM (C)2019 REVCURTISP, MICHAEL STEIL, LICENSE: 2-CLAUSE BSD 7 | 8 | 10 SCREEN 0: REM 40 COLUMN MODE 9 | 11 PRINT CHR$(147);:REM CLEAR SCREEN 10 | 12 POKE 2,119:REM YEAR (2019) 11 | 13 POKE 3,12: REM MONTH 12 | 14 POKE 4,31: REM YEAR 13 | 15 POKE 5,23: REM HOUR 14 | 16 POKE 6,59: REM MINUTES 15 | 17 POKE 7,50: REM SECONDS 16 | 18 POKE 8,11: REM JIFFIES 17 | 19 SYS $FF4D:REM CLOCK-SET-DATE-TIME 18 | 20 REM SYSTEM CLOCK VARIABLES 19 | 21 PRINT CHR$(19);:REM CURSOR HOME 20 | 40 SYS $FF50:REM CLOCK-GET-DATE-TIME 21 | 41 PRINT 22 | 42 PRINT "YEAR ";1900+PEEK(2);" " 23 | 43 PRINT "MONTH ";PEEK(3);"\X9D " 24 | 44 PRINT "DAY ";PEEK(4);"\X9D " 25 | 45 PRINT "HOUR ";PEEK(5);"\X9D " 26 | 46 PRINT "MINUTES";PEEK(6);"\X9D " 27 | 47 PRINT "SECONDS";PEEK(7);"\X9D " 28 | 48 PRINT "JIFFIES";PEEK(8);"\X9D " 29 | 49 GOTO 20 30 | 31 | RUN 32 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_crsr.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Cursor keys handling within CHROUT 7 | ; 8 | 9 | 10 | chrout_screen_CRSR_UP: 11 | 12 | lda TBLX 13 | beq chrout_screen_CRSR_done 14 | dec TBLX 15 | 16 | ; FALLTROUGH 17 | 18 | chrout_screen_CRSR_done: 19 | 20 | jmp chrout_screen_calc_lptr_done 21 | 22 | 23 | chrout_screen_CRSR_DOWN: 24 | 25 | lda TBLX 26 | cmp nlinesm1 27 | bne :+ 28 | jsr screen_scroll_up 29 | : 30 | inc TBLX 31 | jmp chrout_screen_calc_lptr_done 32 | 33 | 34 | chrout_screen_CRSR_RIGHT: 35 | 36 | jsr screen_get_clipped_PNTR 37 | iny 38 | cpy llen 39 | beq_16 screen_advance_to_next_line 40 | 41 | l8: 42 | sty PNTR 43 | bpl chrout_screen_CRSR_done ; branch always 44 | 45 | 46 | chrout_screen_CRSR_LEFT: 47 | 48 | jsr screen_get_clipped_PNTR 49 | dey 50 | bpl l8 51 | 52 | lda TBLX 53 | beq chrout_screen_CRSR_done 54 | 55 | dec TBLX 56 | lda llen 57 | sta PNTR 58 | dec PNTR 59 | bne chrout_screen_CRSR_done ; branch always 60 | -------------------------------------------------------------------------------- /geos/kernal/load/load4b.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Loading: LdApplic syscall 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import UNK_4 14 | .import UNK_5 15 | .import EnterDeskTop 16 | .import StartAppl 17 | .import GetFHdrInfo 18 | .import A885E 19 | .ifdef bsw128 20 | .import CheckAppCompat 21 | .import _LdFile2 22 | .else 23 | .import LdFile 24 | .endif 25 | 26 | .global _LdApplic 27 | 28 | .segment "load4b" 29 | 30 | _LdApplic: 31 | .ifdef bsw128 32 | jsr UNK_5 33 | jsr GetFHdrInfo 34 | bnex @1 35 | jsr CheckAppCompat 36 | beq @2 37 | @1: rts 38 | @2: jsr _LdFile2 39 | bnex @3 40 | bbsf 0, A885E, @3 41 | jsr UNK_4 42 | MoveW_ fileHeader+O_GHST_VEC, r7 43 | jmp StartAppl 44 | @3: jmp EnterDeskTop 45 | .else 46 | jsr UNK_5 47 | jsr LdFile 48 | bnex @1 49 | bbsf 0, A885E, @1 50 | jsr UNK_4 51 | MoveW_ fileHeader+O_GHST_VEC, r7 52 | jmp StartAppl 53 | @1: rts 54 | .endif 55 | 56 | -------------------------------------------------------------------------------- /scripts/checksum.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def calc_checksum(data, old): 4 | a = 0 5 | c = 0 6 | for b in data: 7 | a = a + b + c 8 | c = 0 9 | if a > 255: 10 | a = a - 256 11 | c = 1 12 | if not old: 13 | a += c 14 | return a 15 | 16 | def usage(): 17 | print "Usage: python checksum.py {--old|--new} [ ]" 18 | exit(1) 19 | 20 | # main 21 | 22 | if len(sys.argv) != 3 and len(sys.argv) != 5: 23 | usage() 24 | 25 | if sys.argv[1] == "--old": 26 | old = True 27 | elif sys.argv[1] == "--new": 28 | old = False 29 | else: 30 | usage() 31 | 32 | filename = sys.argv[2] 33 | 34 | data = bytearray(open(filename, 'rb').read()) 35 | 36 | checksum = calc_checksum(data, old) 37 | 38 | if len(sys.argv) != 5: 39 | print filename + ": " + hex(checksum) 40 | exit(0) 41 | 42 | desired_checksum = int(sys.argv[3], 16) 43 | offset = int(sys.argv[4], 16) 44 | 45 | if checksum < desired_checksum: 46 | data[offset] = desired_checksum - checksum 47 | else: 48 | data[offset] = 0xff - (checksum - desired_checksum) 49 | 50 | file = open(filename, "wb") 51 | file.write(data) 52 | -------------------------------------------------------------------------------- /codex/examples/x16skel.txt: -------------------------------------------------------------------------------- 1 | R0=$0002 2 | R0H=$0003 3 | R1=$0004 4 | R1H=$0005 5 | R2=$0006 6 | R2H=$0007 7 | R3=$0008 8 | R3H=$0009 9 | R4=$000A 10 | R4H=$000B 11 | R5=$000C 12 | R5H=$000D 13 | CR=$000D 14 | R6=$000E 15 | R6H=$000F 16 | R7=$0010 17 | R7H=$0011 18 | R8=$0012 19 | R8H=$0013 20 | R9=$0014 21 | R9H=$0015 22 | R10=$0016 23 | R10H=$0017 24 | R11=$0018 25 | R11H=$0019 26 | R12=$001A 27 | R12H=$001B 28 | R13=$001C 29 | R13H=$001D 30 | R14=$001E 31 | R14H=$001F 32 | R15=$0020 33 | R15H=$0021 34 | CLS=$0093 35 | GRINIT=$FF20 36 | GRCLEAR=$FF23 37 | SCRMOD=$FF5F 38 | READST=$FFB7 39 | SETLFS=$FFBA 40 | SETNAME=$FFBD 41 | OPEN=$FFC0 42 | CLOSE=$FFC3 43 | CHKOUT=$FFC9 44 | BSOUT=$FFD2 45 | 46 | *=0801 47 | BASIC 48 | .BYTE $0B,$08,$01 49 | .BYTE $00,$9E,$32 50 | .BYTE $30,$36,$31 51 | .BYTE $00,$00,$00 52 | MAIN 53 | NOP 54 | EXIT 55 | RTS 56 | PRINT 57 | LDY #$00 58 | PRINT_LOOP 59 | LDA (R0),Y 60 | BEQ PRINT_EXIT 61 | JSR BSOUT 62 | INY 63 | BRA PRINT_LOOP 64 | PRINT_EXIT 65 | RTS 66 | -------------------------------------------------------------------------------- /dos/functions.inc: -------------------------------------------------------------------------------- 1 | .global initialize 2 | .global validate 3 | .global new 4 | .global scratch 5 | .global make_directory 6 | .global remove_directory 7 | .global change_directory 8 | .global change_partition 9 | .global user 10 | .global rename 11 | .global rename_header 12 | .global rename_partition 13 | .global change_unit 14 | .global copy_start 15 | .global copy_do 16 | .global copy_end 17 | .global copy_all 18 | .global duplicate 19 | .global file_lock 20 | .global file_lock_toggle 21 | .global file_unlock 22 | .global file_restore 23 | .global write_protect 24 | .global get_partition 25 | .global get_diskchange 26 | .global memory_read 27 | .global memory_write 28 | .global memory_execute 29 | .global set_sector_interleave 30 | .global set_retries 31 | .global test_rom_checksum 32 | .global set_fast_serial 33 | .global set_verify 34 | .global set_directory_interleave 35 | .global set_large_rel_support 36 | .global set_buffer_pointer 37 | .global block_allocate 38 | .global block_free 39 | .global block_status 40 | .global block_read 41 | .global block_read_u1 42 | .global block_write 43 | .global block_write_u2 44 | .global block_execute 45 | .global set_position 46 | -------------------------------------------------------------------------------- /geos/kernal/mainloop/mainloop.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Main Loop 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import _DoUpdateTime 14 | .import _ExecuteProcesses 15 | .import _DoCheckButtons 16 | .import _DoCheckDelays 17 | .import __GetRandom 18 | .import ProcessCursor 19 | .import __ProcessDelays 20 | .import __ProcessTimers 21 | .import ProcessMouse 22 | .import CallRoutine 23 | 24 | .global _MNLP 25 | .global _MainLoop 26 | 27 | .global _InterruptMain 28 | 29 | .segment "mainloop1" 30 | 31 | _MainLoop: 32 | jsr _DoCheckButtons 33 | jsr _ExecuteProcesses ; process 34 | jsr _DoCheckDelays ; process 35 | jsr _DoUpdateTime 36 | lda appMain+0 37 | ldx appMain+1 38 | _MNLP: jsr CallRoutine 39 | cli 40 | jmp _MainLoop 41 | 42 | .segment "mainloop2" 43 | 44 | .segment "mainloop3" 45 | 46 | _InterruptMain: 47 | jsr ProcessMouse 48 | jsr __ProcessTimers ; process 49 | jsr __ProcessDelays ; process 50 | jsr ProcessCursor 51 | jmp __GetRandom 52 | -------------------------------------------------------------------------------- /codex/src/cx_vecs.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Additional vectors for Codex, mainly so the external plugins can access functionality 3 | ;;; 4 | ;;; Copyright 2020-2021 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .include "decoder.inc" 9 | .include "meta.inc" 10 | .include "meta_i.inc" 11 | 12 | .segment "CODEX_VECS" 13 | 14 | .export vec_meta_get_region, vec_meta_get_label, vec_meta_find_label, vec_meta_expr_iter, vec_meta_print_banked_label 15 | .export vec_decode_next_instruction, vec_decode_next_argument, vec_decode_get_byte_count 16 | 17 | vec_meta_get_region: jmp meta_get_region 18 | vec_meta_add_label: jmp meta_add_label 19 | vec_meta_delete_label: jmp meta_delete_label 20 | vec_meta_get_label: jmp meta_get_label 21 | vec_meta_find_label: jmp meta_find_label 22 | vec_meta_expr_iter: jmp meta_expr_iter_next 23 | vec_meta_print_banked_label: jmp meta_print_banked_label 24 | vec_decode_next_instruction: jmp decode_next_instruction 25 | vec_decode_next_argument: jmp decode_next_argument 26 | vec_decode_get_byte_count: jmp decode_get_byte_count 27 | 28 | -------------------------------------------------------------------------------- /geos/kernal/rename.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Michael Steil 3 | ; 4 | ; C64: Aliases for utility functions 5 | ; 6 | ; The C128 version calls some functions indirectly, 7 | ; so for the C64, we alias the symbols. 8 | 9 | .import _ProcessDelays 10 | .import GetInlineDrwParms 11 | .import GrStSetCoords 12 | .import _ProcessTimers 13 | .import _IsMseInRegion 14 | .import _CRC 15 | .import _GetRandom 16 | .import _DSdiv 17 | .import _Ddiv 18 | .import _DMult 19 | .import _BMult 20 | .import _BBMult 21 | 22 | .global __ProcessDelays 23 | .global __GetInlineDrwParms 24 | .global __GrStSetCoords 25 | .global __ProcessTimers 26 | .global __IsMseInRegion 27 | .global __CRC 28 | .global __GetRandom 29 | .global __DSdiv 30 | .global __Ddiv 31 | .global __DMult 32 | .global __BMult 33 | .global __BBMult 34 | 35 | __ProcessDelays = _ProcessDelays 36 | __GetInlineDrwParms = GetInlineDrwParms 37 | __GrStSetCoords = GrStSetCoords 38 | __ProcessTimers = _ProcessTimers 39 | __IsMseInRegion = _IsMseInRegion 40 | __CRC = _CRC 41 | __GetRandom = _GetRandom 42 | __DSdiv = _DSdiv 43 | __Ddiv = _Ddiv 44 | __DMult = _DMult 45 | __BMult = _BMult 46 | __BBMult = _BBMult 47 | -------------------------------------------------------------------------------- /dos/jumptab.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; CMDR-DOS Jump Table 3 | ;---------------------------------------------------------------------- 4 | ; (C)2020 Michael Steil, License: 2-clause BSD 5 | 6 | .import dos_secnd, dos_tksa, dos_acptr, dos_ciout, dos_untlk, dos_unlsn, dos_listn, dos_talk, dos_macptr 7 | 8 | .import dos_OpenDisk, dos_ReadBuff, dos_ReadBlock, dos_GetDirHead, dos_CalcBlksFree, dos_Get1stDirEntry, dos_GetNxtDirEntry 9 | 10 | .import dos_init, dos_set_time 11 | 12 | .segment "dos_jmptab" 13 | ; $C000 14 | 15 | ; IEEE 16 | jmp dos_secnd ; 0 17 | jmp dos_tksa ; 1 18 | jmp dos_acptr ; 2 19 | jmp dos_ciout ; 3 20 | jmp dos_untlk ; 4 21 | jmp dos_unlsn ; 5 22 | jmp dos_listn ; 6 23 | jmp dos_talk ; 7 24 | 25 | ; GEOS 26 | jmp dos_OpenDisk ; 8 27 | jmp dos_ReadBuff ; 9 28 | jmp dos_ReadBlock ; 10 29 | jmp dos_GetDirHead ; 11 30 | jmp dos_CalcBlksFree ; 12 31 | jmp dos_Get1stDirEntry ; 13 32 | jmp dos_GetNxtDirEntry ; 14 33 | 34 | ; init/meta 35 | jmp dos_init ; 15 36 | jmp dos_set_time ; 16 37 | 38 | jmp dos_macptr ; 17 39 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/f4a5.load.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 286 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 231 10 | ; - IEC reference at http:;www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf 11 | ; 12 | ; CPU registers that has to be preserved (see [RG64]): none 13 | ; 14 | 15 | 16 | ; Expects that SETLFS and SETNAM are called before hand. 17 | ; $YYXX = load address. 18 | ; (ignored if SETLFS channel = 1, i.e., like ,8,1) 19 | ; If A=1 then VERIFY instead of LOAD. 20 | ; On exit, $YYXX is the highest address into which data 21 | ; will have been placed. 22 | 23 | 24 | LOAD: 25 | 26 | ; Are we loading or verifying? 27 | sta VERCKK 28 | 29 | ; Store start address of LOAD 30 | lda MEMUSS+0 31 | sta STAL+0 32 | lda MEMUSS+1 33 | sta STAL+1 34 | 35 | ; Reset status 36 | jsr kernalstatus_reset 37 | 38 | ; Check whether we support the requested device 39 | lda FA 40 | 41 | jsr iec_check_devnum_lvs 42 | bcc_16 load_iec 43 | 44 | jmp lvs_illegal_device_number 45 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/screen_calculate_pntr_lnmx.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Sets PNTR in a proper range (0-39 or 40-79) 7 | ; Sets LNMX to 39 or 79 8 | ; 9 | 10 | 11 | screen_calculate_PNTR_LNMX: 12 | 13 | ldy TBLX 14 | lda LDTBL, y 15 | php 16 | jsr screen_get_clipped_PNTR 17 | plp 18 | bmi screen_calculate_PNTR_0_39 19 | 20 | ; FALLTROUGH 21 | 22 | screen_calculate_PNTR_40_79: 23 | 24 | tya 25 | clc 26 | adc llen 27 | tay 28 | 29 | ; FALLTROUGH 30 | 31 | screen_calculate_PNTR_0_39: 32 | 33 | sty PNTR 34 | 35 | ; FALLTROUGH 36 | 37 | screen_calculate_LNMX: 38 | 39 | ldy TBLX 40 | lda LDTBL, y 41 | bpl screen_calculate_lnmx_79 ; this line is a continuation 42 | 43 | cpy nlinesm1 44 | beq screen_calculate_lnmx_39 ; this is the last line, which is not a continuation 45 | 46 | iny 47 | lda LDTBL, y 48 | bpl screen_calculate_lnmx_79 ; line is continued 49 | 50 | ; FALLTROUGH 51 | 52 | screen_calculate_lnmx_39: 53 | 54 | lda llen 55 | bne l9 56 | 57 | ; FALLTROUGH 58 | 59 | screen_calculate_lnmx_79: 60 | 61 | asl 62 | l9: 63 | sta LNMX 64 | dec LNMX 65 | rts 66 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/f157.chrin.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routine, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 277/278 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 228 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .Y 12 | ; 13 | 14 | ; Reads a byte of input, unless from keyboard. 15 | ; If from keyboard, then it gets a whole line of input, and returns the first char. 16 | ; Repeated calls after that read out the successive bytes of the line of input. 17 | 18 | 19 | CHRIN: 20 | 21 | ; Determine the device number 22 | lda DFLTN 23 | 24 | ; Try $00 - keyboard 25 | beq_16 chrin_keyboard 26 | 27 | ; XXX Try $03 - screen 28 | ; cmp #$03 29 | ; beq_16 chrin_screen 30 | 31 | .if HAS_RS232 32 | 33 | ; Try $02 - RS-232 34 | cmp #$02 35 | beq_16 chrin_rs232 36 | 37 | .endif ; HAS_RS232 38 | 39 | chrin_getin: ; jump entry for GETIN 40 | 41 | .if CONFIG_IEC 42 | 43 | ; Try IEC devices 44 | jsr iec_check_devnum_oc 45 | bcc_16 chrin_iec 46 | 47 | .endif ; CONFIG_IEC 48 | 49 | ; Not a supported device 50 | 51 | jmp lvs_device_not_found_error 52 | -------------------------------------------------------------------------------- /kernal/open-roms/init/cint_screen_keyboard.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; This is a part CINT which initializes screen and keyboard 7 | ; 8 | ; For more details see: 9 | ; - [RG64] C64 Programmers Reference Guide - page 280 10 | ; - [CM64] Computes Mapping the Commodore 64 - page 242 11 | ; 12 | 13 | 14 | cint_screen_keyboard: 15 | 16 | ; Setup KEYLOG vector 17 | 18 | ; Initialise cursor blink flags (Computes Mapping the 64 p215) 19 | 20 | lda #$01 21 | sta BLNCT 22 | sta BLNSW 23 | 24 | ; Enable cursor repeat - XXX make it configurable 25 | 26 | ; Set keyboard decode vector (Computes Mapping the 64 p215) 27 | 28 | jsr emulator_get_data 29 | jsr kbd_config 30 | 31 | ; Set current colour for text (Computes Mapping the 64 p215) 32 | ldx #$61 ; default is light blue ($0E), but we use a different one 33 | stx COLOR 34 | 35 | ; Set maximum keyboard buffer size (Computes Mapping the 64 p215) 36 | ;ldx #10 37 | ;stx XMAX 38 | 39 | ; Put non-zero value in MODE to enable case switch 40 | ldx #$00 41 | stx MODE 42 | 43 | ; Fallthrough/jump to screen clear routine (Computes Mapping the 64 p215) 44 | 45 | jmp clear_screen 46 | -------------------------------------------------------------------------------- /geos/kernal/math/shl.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Math library: DShiftLeft syscall 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .ifdef wheels 14 | .import BBMult_ret 15 | .endif 16 | 17 | .global _DShiftLeft 18 | 19 | .segment "math1a1" 20 | 21 | ;--------------------------------------------------------------- 22 | ; DShiftLeft $C15D 23 | ; 24 | ; Function: Arithmetically shift operand left n bits. Computes 25 | ; operand * 2^n 26 | ; 27 | ; Pass: x add of zpage Reg 28 | ; y nbr of bits to shift left 29 | ; Return: (x) Reg pointed by x is shifted 30 | ; Destroyed: y 31 | ;--------------------------------------------------------------- 32 | _DShiftLeft: 33 | dey 34 | .ifdef wheels 35 | .if 0 ; XXX cc65 issue: branch can't cross segment 36 | bmi BBMult_ret 37 | .else 38 | .byte $30, <(BBMult_ret - (* + 1)) 39 | .endif 40 | .else 41 | bmi @1 42 | .endif 43 | asl zpage,x 44 | rol zpage+1,x 45 | jmp _DShiftLeft 46 | .ifndef wheels 47 | @1: rts 48 | .endif 49 | -------------------------------------------------------------------------------- /graphics/kernal.s: -------------------------------------------------------------------------------- 1 | ;--------------------------------------------------------------- 2 | ; This file contains bridge functions for routines in the 3 | ; Kernal ROM bank used by the graphic and fonts library 4 | ;--------------------------------------------------------------- 5 | 6 | .export grjsrfar 7 | 8 | .import k_kbdbuf_get ;Set during link stage from Kernal.sym 9 | .import k_sprite_set_position ;Set during link stage from Kernal.sym 10 | .import k_sprite_set_image ;Set during link stage from Kernal.sym 11 | 12 | .export kbdbuf_get 13 | .export sprite_set_position 14 | .export sprite_set_image 15 | .export bsout 16 | 17 | .include "banks.inc" 18 | .include "kernal_vectors.inc" 19 | 20 | .segment "GRAPH" 21 | 22 | kbdbuf_get: 23 | jsr grjsrfar 24 | .word k_kbdbuf_get 25 | .byte BANK_KERNAL 26 | rts 27 | 28 | sprite_set_image: 29 | jsr grjsrfar 30 | .word k_sprite_set_image 31 | .byte BANK_KERNAL 32 | rts 33 | 34 | sprite_set_position: 35 | jsr grjsrfar 36 | .word k_sprite_set_position 37 | .byte BANK_KERNAL 38 | rts 39 | 40 | bsout: 41 | jsr grjsrfar 42 | .word k_bsout 43 | .byte BANK_KERNAL 44 | rts 45 | 46 | ram_bank = $00 47 | rom_bank = $01 48 | 49 | grjsrfar: .include "jsrfar.inc" -------------------------------------------------------------------------------- /geos/kernal/math/crc.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Math library: CRC syscall 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import Ddec 14 | 15 | .global _CRC 16 | 17 | .segment "math2" 18 | 19 | ;--------------------------------------------------------------- 20 | ; CRC $C20E 21 | ; 22 | ; Function: CRC performs a checksum on specified data 23 | ; 24 | ; Pass: r0 ptr to data 25 | ; r1 nbr of bytes to check 26 | ; Return: r2 checksum 27 | ; Destroyed: a, x, y, r0, r1, r3l 28 | ;--------------------------------------------------------------- 29 | _CRC: 30 | ldy #$ff 31 | sty r2L 32 | sty r2H 33 | iny 34 | @1: lda #$80 35 | sta r3L 36 | @2: asl r2L 37 | rol r2H 38 | lda (r0),y 39 | and r3L 40 | bcc @3 41 | eor r3L 42 | @3: beq @4 43 | lda r2L 44 | eor #$21 45 | sta r2L 46 | lda r2H 47 | eor #$10 48 | sta r2H 49 | @4: lsr r3L 50 | bcc @2 51 | iny 52 | bne @5 53 | inc r0H 54 | @5: ldx #r1 55 | jsr Ddec 56 | lda r1L 57 | ora r1H 58 | bne @1 59 | rts 60 | -------------------------------------------------------------------------------- /kernal/graph/graph.s: -------------------------------------------------------------------------------- 1 | .include "mac.inc" 2 | .include "regs.inc" 3 | .include "banks.inc" 4 | .include "graphics.inc" 5 | .include "fb.inc" 6 | 7 | .import jsrfar 8 | 9 | .macro graph_call addr 10 | jsr jsrfar 11 | .word addr 12 | .byte BANK_GRAPH 13 | .endmacro 14 | 15 | .export GRAPH_clear 16 | .export GRAPH_draw_image 17 | .export GRAPH_draw_line 18 | .export GRAPH_draw_oval 19 | .export GRAPH_draw_rect 20 | .export GRAPH_init 21 | .export GRAPH_move_rect 22 | .export GRAPH_set_colors 23 | .export GRAPH_set_window 24 | 25 | .segment "GRAPH" 26 | 27 | GRAPH_clear: 28 | graph_call gr_GRAPH_clear 29 | rts 30 | 31 | GRAPH_draw_image: 32 | graph_call gr_GRAPH_draw_image 33 | rts 34 | 35 | GRAPH_draw_line: 36 | graph_call gr_GRAPH_draw_line 37 | rts 38 | 39 | GRAPH_draw_oval: 40 | graph_call gr_GRAPH_draw_oval 41 | rts 42 | 43 | GRAPH_draw_rect: 44 | graph_call gr_GRAPH_draw_rect 45 | rts 46 | 47 | GRAPH_init: 48 | graph_call gr_GRAPH_init 49 | rts 50 | 51 | GRAPH_move_rect: 52 | graph_call gr_GRAPH_move_rect 53 | rts 54 | 55 | GRAPH_set_colors: 56 | graph_call gr_GRAPH_set_colors 57 | rts 58 | 59 | GRAPH_set_window: 60 | graph_call gr_GRAPH_set_window 61 | rts -------------------------------------------------------------------------------- /geos/kernal/math/random.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Math library: GetRandom syscall 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .global _GetRandom 14 | 15 | .segment "math1d" 16 | 17 | ;--------------------------------------------------------------- 18 | ; GetRandom $C187 19 | ; 20 | ; Function: Get 16 bit pseudorandom number. 21 | ; 22 | ; Pass: nothing 23 | ; Return: ramdom - contains new 16 bit nbr 24 | ; Destroyed: a 25 | ;--------------------------------------------------------------- 26 | _GetRandom: 27 | inc random 28 | bne @1 29 | inc random+1 30 | @1: asl random 31 | rol random+1 32 | bcc @3 33 | clc 34 | lda #$0F 35 | adc random 36 | sta random 37 | bcc @2 38 | inc random+1 39 | @2: rts 40 | @3: 41 | .ifdef wheels 42 | CmpBI random+1, $f1 43 | .else 44 | CmpBI random+1, $ff 45 | .endif 46 | bcc @4 47 | lda random 48 | .ifdef wheels 49 | sbc #$f1 50 | .else 51 | subv $f1 52 | .endif 53 | bcc @4 54 | sta random 55 | lda #0 56 | sta random+1 57 | @4: rts 58 | 59 | -------------------------------------------------------------------------------- /codex/src/cx_vars.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Vaiables for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020-2021 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .psc02 ; Enable 65c02 instructions 9 | .feature labels_without_colons 10 | 11 | .export assy_selected_instruction, assy_last_disp_instruction, assy_selected_row, original_sp 12 | .export mem_last_addr, mem_last_bank, input_hex_bank_set, input_hex_bank, input_hex_value, run_break_shim 13 | 14 | .data 15 | 16 | assy_selected_instruction .word 0 17 | assy_last_disp_instruction .word 0 ; So cursor down can know when to scroll 18 | assy_selected_row .byte 0 19 | 20 | original_sp .byte 0 21 | 22 | mem_last_addr .word 0 23 | mem_last_bank .byte 0 24 | input_hex_bank_set .byte 0 25 | input_hex_bank .byte 0 26 | input_hex_value .word 0 27 | 28 | SHIM_BUFFER_SIZE .set 22 29 | 30 | ;; Shim code for running user program, needed to switch ROM bank prior to run. 31 | ;; Also contains BRK shim, again to switch ROM banks. This space can not be used 32 | ;; for anything else during user program executions. 33 | run_break_shim: .res SHIM_BUFFER_SIZE 34 | 35 | -------------------------------------------------------------------------------- /graphics/fonts/fonts4b.s: -------------------------------------------------------------------------------- 1 | ; Commander X16 KERNAL 2 | ; based on GEOS by Berkeley Softworks; reversed by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Font library: drawing 5 | 6 | FontGt1: 7 | sty fontTemp1+1 8 | sty fontTemp1+2 9 | lda (r2),y 10 | and FontTVar3 11 | and r7H 12 | jmp (r12) 13 | 14 | FontGt2: 15 | sty fontTemp1+2 16 | sty fontTemp1+3 17 | lda (r2),y 18 | and FontTVar3 19 | sta fontTemp1 20 | iny 21 | lda (r2),y 22 | and r7H 23 | sta fontTemp1+1 24 | FontGt2_1: 25 | lda fontTemp1 26 | jmp (r12) 27 | 28 | FontGt3: 29 | sty fontTemp1+3 30 | sty fontTemp1+4 31 | lda (r2),y 32 | and FontTVar3 33 | sta fontTemp1 34 | iny 35 | lda (r2),y 36 | sta fontTemp1+1 37 | iny 38 | lda (r2),y 39 | and r7H 40 | sta fontTemp1+2 41 | .ifdef bsw128 ; dup for speed? 42 | lda fontTemp1 43 | jmp (r12) 44 | .else 45 | bra FontGt2_1 46 | .endif 47 | 48 | FontGt4: 49 | lda (r2),y 50 | and FontTVar3 51 | sta fontTemp1 52 | FontGt4_1: 53 | iny 54 | cpy r3H 55 | beq FontGt4_2 56 | lda (r2),y 57 | sta fontTemp1,y 58 | bra FontGt4_1 59 | FontGt4_2: 60 | lda (r2),y 61 | and r7H 62 | sta fontTemp1,y 63 | lda #0 64 | sta fontTemp1+1,y 65 | sta fontTemp1+2,y 66 | .ifdef bsw128 ; dup for speed? 67 | lda fontTemp1 68 | jmp (r12) 69 | .else 70 | beq FontGt2_1 71 | .endif 72 | -------------------------------------------------------------------------------- /kernal/cbm/util.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; PRIMM 3 | ;---------------------------------------------------------------------- 4 | ; (C)1985 Commodore Business Machines (CBM) 5 | ; additions: (C)2020 Michael Steil, License: 2-clause BSD 6 | 7 | .feature labels_without_colons 8 | 9 | .include "banks.inc" 10 | 11 | bsout = $ffd2 12 | 13 | .export primm 14 | 15 | .segment "UTIL" 16 | 17 | ; \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 18 | ; *** print immediate *** 19 | ; a jsr to this routine is followed by an immediate ascii string, 20 | ; terminated by a $00. the immediate string must not be longer 21 | ; than 255 characters including the terminator. 22 | 23 | primm 24 | pha ;save registers 25 | txa 26 | pha 27 | tya 28 | pha 29 | ldy #0 30 | 31 | @1 tsx ;increment return address on stack 32 | inc $104,x ;and make imparm = return address 33 | bne @2 34 | inc $105,x 35 | @2 lda $104,x 36 | sta imparm 37 | lda $105,x 38 | sta imparm+1 39 | 40 | lda (imparm),y ;fetch character to print (*** always system bank ***) 41 | beq @3 ;null= eol 42 | jsr bsout ;print the character 43 | bcc @1 44 | 45 | @3 pla ;restore registers 46 | tay 47 | pla 48 | tax 49 | pla 50 | rts ;return 51 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/e8ea.screen_scroll_up.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Scroll the whole screen up by 1 logical line, described in: 7 | ; 8 | ; - [CM64] Computes Mapping the Commodore 64 - page 218 9 | ; 10 | 11 | 12 | screen_scroll_up: 13 | 14 | ; Check if CTRL key pressed - if so, perform a delay 15 | 16 | lda SHFLAG 17 | and #KEY_FLAG_CTRL 18 | beq screen_scroll_up_delay_done 19 | 20 | ldy #$09 21 | : 22 | ldx #$FF 23 | jsr wait_x_bars 24 | dey 25 | bne :- 26 | 27 | ; FALLTROUGH 28 | 29 | screen_scroll_up_delay_done: ; entry point for cursor move control codes 30 | 31 | ; Scroll the LDTBL (line link table) 32 | 33 | ldy #$00 34 | : 35 | lda LDTBL+1, y 36 | sta LDTBL+0, y 37 | iny 38 | cpy nlinesm1 39 | bne :- 40 | 41 | lda #$80 42 | sta LDTBL+24 43 | 44 | ldx #0 45 | : jsr screen_set_position 46 | inx 47 | jsr screen_copy_line 48 | cpx nlinesm1 49 | bne :- 50 | 51 | ; Clear the newly introduced line 52 | 53 | ldx nlinesm1 54 | jsr screen_clear_line 55 | 56 | ; Decrement the current physical line number 57 | 58 | dec TBLX 59 | 60 | ; If the first line is linked, scroll once more 61 | 62 | bit LDTBL+0 63 | bpl screen_scroll_up 64 | 65 | ; Recalculate PNT and USER 66 | 67 | jmp screen_calculate_PNT_USER 68 | -------------------------------------------------------------------------------- /kernal/drivers/x16/rs232.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; VERA RS232 Driver 3 | ;---------------------------------------------------------------------- 4 | ; (C)2019 Michael Steil, License: 2-clause BSD 5 | 6 | .include "io.inc" 7 | 8 | .segment "RS232" 9 | 10 | .import dfltn, dflto 11 | .import t1, status 12 | 13 | .export opn232 14 | .export cls232 15 | .export cko232 16 | .export cki232 17 | .export bso232 18 | .export bsi232 19 | 20 | ;OPEN 21 | ; 22 | opn232: 23 | clc 24 | rts 25 | 26 | ;CLOSE 27 | ; 28 | cls232: 29 | clc 30 | rts 31 | 32 | ;CKOUT 33 | ; 34 | cko232: 35 | sta dflto 36 | clc 37 | rts 38 | 39 | ;CHKIN 40 | ; 41 | cki232: 42 | sta dfltn 43 | clc 44 | rts 45 | 46 | ;BSOUT 47 | ; 48 | bso232: 49 | ; lda #$01 50 | ; sta veralo 51 | ; lda #$80 52 | ; sta veramid 53 | ; lda #$0F 54 | ; sta verahi 55 | ; lda #2 56 | ; : bit veradat 57 | ; bne :- 58 | ; dec veralo 59 | ; lda t1 60 | ; sta veradat 61 | rts 62 | 63 | ;BASIN 64 | ; 65 | bsi232: 66 | ; lda #$01 67 | ; sta veralo 68 | ; lda #$80 69 | ; sta veramid 70 | ; lda #$0F 71 | ; sta verahi 72 | ; lda #1 73 | ; bit veradat 74 | ; bne :+ 75 | ; lda #8 ; EMPTY 76 | ; sta status 77 | ; lda #0 78 | ; rts 79 | 80 | ; : lda #0 ; OK 81 | ; sta status 82 | ; dec veralo 83 | ; lda veradat 84 | rts 85 | -------------------------------------------------------------------------------- /keymap/klc/409 US.klcpatch: -------------------------------------------------------------------------------- 1 | // - -> - [unchanged] 2 | // [Shft] _ -> PETSCII GRAPH 0xdd 3 | // [Alt] -> PETSCII GRAPH 0xdc 4 | 0c OEM_MINUS 0 002d f8dd -1 f8dc // HYPHEN-MINUS, PETSCII GRAPH 0xDD, , PETSCII GRAPH 0xDC 5 | 6 | // = -> = [unchanged] 7 | // [Shft] + -> + [unchanged] 8 | // [Alt] -> PETSCII GRAPH 0xa6 9 | 0d OEM_PLUS 0 003d 002b -1 f8a6 // EQUALS SIGN, PLUS SIGN, , PETSCII GRAPH 0xA6 10 | 11 | // [ -> [ [unchanged] 12 | // [Shft] { -> PETSCII GRAPH 0xba 13 | // [Alt] ^[ -> PETSCII GRAPH 0xa4 14 | 1a OEM_4 0 005b f8ba -1 f8a4 // LEFT SQUARE BRACKET, PETSCII GRAPH 0xBA, , PETSCII GRAPH 0xA4 15 | 16 | // ] -> [ [unchanged] 17 | // [Shft] } -> PETSCII GRAPH 0xc0 18 | // [Alt] ^] -> PETSCII GRAPH 0xdf 19 | 1b OEM_6 0 005d f8c0 -1 f8df // RIGHT SQUARE BRACKET, PETSCII GRAPH 0xC0,, PETSCII GRAPH 0xDF 20 | 21 | // ` -> ← 22 | // [Shft] ~ -> π 23 | // [Alt] -> PETSCII GRAPH 0xdb 24 | 29 OEM_3 0 2190 03c0 -1 f8db // LEFTWARDS ARROW, GREEK SMALL LETTER PI, , PETSCII GRAPH 0xDB 25 | 26 | // \ -> £ 27 | // [Shft] | -> PETSCII GRAPH 0xa9 28 | // [Alt] -> PETSCII GRAPH 0xa8 29 | 2b OEM_5 0 00a3 f8a9 -1 f8a8 // POUND SIGN, PETSCII GRAPH 0xA9, , PETSCII GRAPH 0xA8 30 | 31 | -------------------------------------------------------------------------------- /codex/examples/HW.TXT: -------------------------------------------------------------------------------- 1 | R0=$0002 2 | R0H=$0003 3 | R1=$0004 4 | R1H=$0005 5 | R2=$0006 6 | R2H=$0007 7 | R3=$0008 8 | R3H=$0009 9 | R4=$000A 10 | R4H=$000B 11 | R5=$000C 12 | R5H=$000D 13 | CR=$000D 14 | R6=$000E 15 | R6H=$000F 16 | R7=$0010 17 | R7H=$0011 18 | R8=$0012 19 | R8H=$0013 20 | R9=$0014 21 | R9H=$0015 22 | R10=$0016 23 | R10H=$0017 24 | R11=$0018 25 | R11H=$0019 26 | R12=$001A 27 | R12H=$001B 28 | R13=$001C 29 | R13H=$001D 30 | R14=$001E 31 | R14H=$001F 32 | R15=$0020 33 | R15H=$0021 34 | CLS=$0093 35 | GRINIT=$FF20 36 | GRCLEAR=$FF23 37 | SCRMOD=$FF5F 38 | READST=$FFB7 39 | SETLFS=$FFBA 40 | SETNAME=$FFBD 41 | OPEN=$FFC0 42 | CLOSE=$FFC3 43 | CHKOUT=$FFC9 44 | BSOUT=$FFD2 45 | 46 | *=0801 47 | BASIC 48 | .BYTE $0B,$08,$01 49 | .BYTE $00,$9E,$32 50 | .BYTE $30,$36,$31 51 | .BYTE $00,$00,$00 52 | MAIN 53 | NOP 54 | LDA #$93 55 | JSR BSOUT 56 | LDA #STR 59 | STA R0H 60 | JSR PRINT 61 | EXIT 62 | RTS 63 | PRINT 64 | LDY #$00 65 | PRINT_LOOP 66 | LDA (R0),Y 67 | BEQ PRINT_EXIT 68 | JSR BSOUT 69 | INY 70 | BRA PRINT_LOOP 71 | PRINT_EXIT 72 | RTS 73 | STR 74 | .CSTR "HELLO WERLD" 75 | -------------------------------------------------------------------------------- /kernal/open-roms/memory/vector_real.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | 6 | vector_real: 7 | 8 | ; Use MEMUSS as temporary storage location - checked on real C64 that this is the 9 | ; address originally used; after calling VECTOR and checking zero page 10 | ; area afterwards, the address could be found there 11 | 12 | ; According to 'Computes Mapping the Commodore 64' page 237, 13 | ; the CBM implementation does not disable IRQs - yet, the 14 | ; 'C64 Programmers Reference Guide' does not contain such 15 | ; warning and does not mention any preparations needed. 16 | 17 | ; Initial idea was to do php, cli, ..., plp to make the routine safer, 18 | ; but it seems it might cause problem with initialization on XEMU emulator 19 | ; XXX find out, why 20 | 21 | ; Prepare the user data pointer - strange order to reduce risk 22 | ; of potential similarity to the original routine 23 | sty MEMUSS + 1 24 | stx MEMUSS + 0 25 | 26 | ; Select routine variant - store or restore vectors 27 | ldy #$1F 28 | bcc vector_restore 29 | 30 | lda CINV, y 31 | sta (MEMUSS), y 32 | 33 | bcs vector_end_loop ; branch always 34 | 35 | vector_restore: 36 | lda (MEMUSS), y 37 | sta CINV, y 38 | 39 | ; FALLTROUGH 40 | 41 | vector_end_loop: 42 | dey 43 | bpl vector_restore 44 | 45 | rts 46 | -------------------------------------------------------------------------------- /codex/src/vera.s: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; VERA interface for the Commander 16 Assembly Language Environment 3 | ;;; 4 | ;;; Copyright 2020 Michael J. Allison 5 | ;;; License, 2-clause BSD, see license.txt in source package. 6 | ;;; 7 | 8 | .psc02 ; Enable 65c02 instructions 9 | .feature labels_without_colons 10 | 11 | VERA_ADDR_LO=$9F20 12 | VERA_ADDR_MID=$9F21 13 | VERA_ADDR_HI=$9F22 14 | VERA_DATA0=$9F23 15 | VERA_DATA1=$9F24 16 | VERA_CTRL=$9F25 17 | VERA_IEN=$9F26 18 | VERA_ISR=$9F27 19 | 20 | VERA_CTRL_SEL=$00 21 | 22 | .export vera_out_a, vera_goto_xy, vera_goto, VERA_DATA0, VERA_DATA1, VERA_ADDR_LO, VERA_ADDR_MID, VERA_ADDR_HI 23 | 24 | .include "kvars.inc" 25 | .include "x16_kernal.inc" 26 | .include "screen_vars.inc" 27 | 28 | ;; 29 | ;; Vera print char 30 | ;; Input A - screen code 31 | vera_out_a 32 | sta VERA_DATA0 33 | lda K_TEXT_COLOR 34 | sta VERA_DATA0 35 | inc SCR_COL 36 | rts 37 | 38 | ;; 39 | ;; Vera goto (aka PLOT) via X-Y registers 40 | ;; 41 | vera_goto_xy 42 | stx SCR_COL 43 | sty SCR_ROW 44 | jsr vera_goto 45 | rts 46 | 47 | ;; 48 | ;; Vera goto (aka PLOT) via SCR_COL, SCR_ROW 49 | ;; 50 | vera_goto 51 | lda SCR_COL 52 | asl 53 | sta VERA_ADDR_LO 54 | lda SCR_ROW 55 | clc 56 | adc #$B0 57 | sta VERA_ADDR_MID 58 | lda #$11 59 | sta VERA_ADDR_HI 60 | rts 61 | -------------------------------------------------------------------------------- /geos/kernal/keyboard/keyboard3.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; C64/C128 keyboard driver 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import KbdQueHead 14 | .import KbdQueue 15 | .import KbdQueTail 16 | 17 | .global KbdScanHelp2 18 | .global KbdScanHelp3 19 | .global KbdScanHelp5 20 | .global KbdScanHelp6 21 | .global _GetNextChar 22 | 23 | .segment "keyboard3" 24 | 25 | KbdScanHelp2: 26 | php 27 | sei 28 | pha 29 | smbf KEYPRESS_BIT, pressFlag 30 | ldx KbdQueTail 31 | pla 32 | sta KbdQueue,x 33 | jsr KbdScanHelp4 34 | cpx KbdQueHead 35 | beq @1 36 | stx KbdQueTail 37 | @1: plp 38 | rts 39 | 40 | KbdScanHelp3: 41 | php 42 | sei 43 | ldx KbdQueHead 44 | lda KbdQueue,x 45 | sta keyData 46 | jsr KbdScanHelp4 47 | stx KbdQueHead 48 | cpx KbdQueTail 49 | bne @2 50 | rmb KEYPRESS_BIT, pressFlag 51 | @2: plp 52 | rts 53 | 54 | KbdScanHelp4: 55 | inx 56 | cpx #16 57 | bne @1 58 | ldx #0 59 | @1: rts 60 | 61 | ;--------------------------------------------------------------- 62 | ;--------------------------------------------------------------- 63 | _GetNextChar: 64 | bbrf KEYPRESS_BIT, pressFlag, @1 65 | jmp KbdScanHelp3 66 | @1: lda #0 67 | rts 68 | -------------------------------------------------------------------------------- /geos/kernal/dlgbox/dlgbox1e1.s: -------------------------------------------------------------------------------- 1 | ; GEOS KERNAL by Berkeley Softworks 2 | ; reverse engineered by Maciej Witkowiak, Michael Steil 3 | ; 4 | ; Dialog box: default icon descriptors 5 | 6 | .include "const.inc" 7 | .include "geossym.inc" 8 | .include "geosmac.inc" 9 | .include "config.inc" 10 | .include "gkernal.inc" 11 | .include "c64.inc" 12 | 13 | .import DBIcDISK 14 | .import DBIcPicDISK 15 | .import DBIcOPEN 16 | .import DBIcPicOPEN 17 | .import DBIcNO 18 | .import DBIcPicNO 19 | .import DBIcYES 20 | .import DBIcPicYES 21 | .import DBIcCANCEL 22 | .import DBIcPicCANCEL 23 | .import DBIcOK 24 | .import DBIcPicOK 25 | 26 | .global DBDefIconsTab 27 | 28 | .ifdef wheels 29 | .global DBDefIconsTabRoutine 30 | .endif 31 | 32 | .segment "dlgbox1e1" 33 | 34 | .ifdef bsw128 35 | MSB = DOUBLE_B 36 | .else 37 | MSB = 0 38 | .endif 39 | 40 | DBDefIconsTab: 41 | .word DBIcPicOK 42 | .word 0 43 | .byte MSB | 6, 16 44 | DBDefIconsTabRoutine: 45 | .word DBIcOK 46 | 47 | .word DBIcPicCANCEL 48 | .word 0 49 | .byte MSB | 6, 16 50 | .word DBIcCANCEL 51 | 52 | .word DBIcPicYES 53 | .word 0 54 | .byte MSB | 6, 16 55 | .word DBIcYES 56 | 57 | .word DBIcPicNO 58 | .word 0 59 | .byte MSB | 6, 16 60 | .word DBIcNO 61 | 62 | .word DBIcPicOPEN 63 | .word 0 64 | .byte 6, 16 65 | .word DBIcOPEN 66 | 67 | .word DBIcPicDISK 68 | .word 0 69 | .byte 6, 16 70 | .word DBIcDISK 71 | 72 | -------------------------------------------------------------------------------- /kernal/cbm/channel/clall.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; Channel: CLALL/CLRCH 3 | ;---------------------------------------------------------------------- 4 | ; (C)1983 Commodore Business Machines (CBM) 5 | ; additions: (C)2020 Michael Steil, License: 2-clause BSD 6 | 7 | ;*************************************** 8 | ;* clall -- close all logical files * 9 | ;* deletes all table entries and* 10 | ;* restores default i/o channels * 11 | ;* and clears ieee port devices * 12 | ;************************************* 13 | ; 14 | nclall lda #0 15 | sta ldtnd ;forget all files 16 | 17 | ;******************************************** 18 | ;* clrch -- clear channels * 19 | ;* unlisten or untalk ieee devices, but * 20 | ;* leave others alone. default channels * 21 | ;* are restored. * 22 | ;******************************************** 23 | ; 24 | nclrch ldx #3 25 | cpx dflto ;is output channel ieee? 26 | bcs jx750 ;no... 27 | ; 28 | jsr unlsn ;yes...unlisten it 29 | ; 30 | jx750 cpx dfltn ;is input channel ieee? 31 | bcs clall2 ;no... 32 | ; 33 | jsr untlk ;yes...untalk it 34 | ; 35 | ;restore default values 36 | ; 37 | ; 38 | clall2 stx dflto ;output chan=3=screen 39 | lda #0 40 | sta dfltn ;input chan=0=keyboard 41 | rts 42 | 43 | -------------------------------------------------------------------------------- /kernal/open-roms/iostack/f250.ckout.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; Official Kernal routines, described in: 7 | ; 8 | ; - [RG64] C64 Programmers Reference Guide - page 276 9 | ; - [CM64] Computes Mapping the Commodore 64 - page 229 10 | ; 11 | ; CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213) 12 | ; 13 | 14 | 15 | CKOUT: 16 | 17 | ; Store registers for preservation 18 | pha 19 | phy_trash_a 20 | 21 | ; Reset status 22 | jsr kernalstatus_reset 23 | 24 | ; First retrieve the FAT/LAT/SAT table index (and check if file is open) 25 | 26 | txa 27 | jsr find_fls 28 | bcs_16 chkinout_file_not_open 29 | 30 | ; Now we have table index in Y 31 | 32 | lda FAT,Y 33 | 34 | ; Handle all the devices 35 | 36 | beq ckout_file_not_output ; 0 - keyboard 37 | 38 | ; Tape not supported here 39 | 40 | .if HAS_RS232 41 | 42 | cmp #$02 43 | beq_16 ckout_rs232 44 | 45 | .endif ; HAS_RS232 46 | 47 | .if CONFIG_IEC 48 | 49 | jsr iec_check_devnum_oc 50 | bcc_16 ckout_iec 51 | 52 | .endif ; CONFIG_IEC 53 | 54 | cmp #$03 ; screen - only legal one left 55 | bne_16 chkinout_device_not_present 56 | 57 | ckout_set_device: 58 | lda FAT,Y 59 | sta DFLTO 60 | jmp chkinout_end 61 | 62 | ckout_file_not_output: 63 | ply_trash_a 64 | pla 65 | jmp kernalerror_FILE_NOT_OUTPUT 66 | -------------------------------------------------------------------------------- /test/joystick.bas: -------------------------------------------------------------------------------- 1 | 80 R1$=CHR$($12):R0$=CHR$($92) 2 | 90 PRINTCHR$($93) 3 | 4 | 95 PRINTCHR$($13); 5 | 97 FORI=0TO4 6 | 100 J=JOY(I):POKE$30C,I:SYS$FF56:J1=PEEK($30C):J2=PEEK($30D):J3=PEEK($30E) 7 | 105 X1=255-J1:X2=255-J2 8 | 9 | 110 A=JAND2048 10 | 120 X=JAND1024 11 | 130 L=JAND512 12 | 140 R=JAND256 13 | 150 B=JAND128 14 | 160 Y=JAND64 15 | 170 SL=JAND32 16 | 180 SR=JAND16 17 | 190 UP=JAND8 18 | 200 DN=JAND4 19 | 210 LT=JAND2 20 | 220 RT=JAND1 21 | 22 | 230 PRINT"PORT";I;"- ";BIN$(J1),BIN$(J2),BIN$(J3),J;CHR$($9D);" " 23 | 24 | 240 IFJ=-1THENPRINT" NOT CONNECTED";:GOTO800 25 | 26 | 300 PRINTR0$;" ";:IFATHENPRINTR1$; 27 | 310 PRINT" A "; 28 | 320 PRINTR0$;" ";:IFBTHENPRINTR1$; 29 | 330 PRINT" B "; 30 | 31 | 400 PRINTR0$;" ";:IFXTHENPRINTR1$; 32 | 410 PRINT" X "; 33 | 420 PRINTR0$;" ";:IFYTHENPRINTR1$; 34 | 430 PRINT" Y "; 35 | 36 | 450 PRINTR0$;" ";:IFLTHENPRINTR1$; 37 | 460 PRINT" L "; 38 | 470 PRINTR0$;" ";:IFRTHENPRINTR1$; 39 | 480 PRINT" R "; 40 | 41 | 500 PRINTR0$;" ";:IFSLTHENPRINTR1$; 42 | 510 PRINT" SELECT "; 43 | 520 PRINTR0$;" ";:IFSRTHENPRINTR1$; 44 | 530 PRINT" START "; 45 | 46 | 600 PRINTR0$;" ";:IFDNTHENPRINTR1$; 47 | 610 PRINT" DOWN "; 48 | 620 PRINTR0$;" ";:IFUPTHENPRINTR1$; 49 | 630 PRINT" UP "; 50 | 640 PRINTR0$;" ";:IFLTTHENPRINTR1$; 51 | 650 PRINT" LEFT "; 52 | 660 PRINTR0$;" ";:IFRTTHENPRINTR1$; 53 | 670 PRINT" RIGHT "; 54 | 55 | 800 PRINT:PRINT:NEXT 56 | 999 GOTO95 57 | -------------------------------------------------------------------------------- /kernal/drivers/x16/entropy.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; X16 Entropy Driver 3 | ;---------------------------------------------------------------------- 4 | ; (C)2020 Michael Steil, License: 2-clause BSD 5 | 6 | .include "io.inc" 7 | 8 | .export entropy_init, entropy_get 9 | 10 | .segment "ENTROPY" 11 | 12 | ;--------------------------------------------------------------- 13 | ; entropy_init 14 | ; 15 | ; Function: Initialize entropy generator 16 | ; 17 | ;--------------------------------------------------------------- 18 | entropy_init: 19 | lda #$ff 20 | sta d1t1l ; max value: $ffff 21 | sta d1t1h 22 | lda #$40 ; set t1 free run 23 | sta d1acr 24 | rts 25 | 26 | ;--------------------------------------------------------------- 27 | ; entropy_get 28 | ; 29 | ; Function: Return 24 random bits 30 | ; 31 | ; Return: a random value 32 | ; x random value 33 | ; y random value 34 | ;--------------------------------------------------------------- 35 | ; We only have two bytes of entropy, so we return the XOR in the 36 | ; third byte: 37 | ; a timer lo 38 | ; x timer hi 39 | ; y timer lo + timer hi 40 | ; Timer lo is read twice, so there will be some difference. 41 | entropy_get: 42 | lda d1t1h 43 | tax 44 | adc d1t1l ; feed in .C from user 45 | tay 46 | lda d1t1l 47 | rts 48 | -------------------------------------------------------------------------------- /kernal/open-roms/screen/chrout_screen_control.s: -------------------------------------------------------------------------------- 1 | ; #LAYOUT# STD * #TAKE 2 | ; #LAYOUT# * KERNAL_0 #TAKE 3 | ; #LAYOUT# * * #IGNORE 4 | 5 | ; 6 | ; CHROUT routine - screen support, control codes 7 | ; 8 | 9 | chrout_screen_control: 10 | 11 | txa 12 | 13 | chrout_try_jumptable: 14 | 15 | ldx #(__chrout_screen_jumptable_codes_end - chrout_screen_jumptable_codes - 1) 16 | 17 | chrout_try_jumptable_loop: 18 | 19 | cpx #(__chrout_screen_jumptable_quote_guard - chrout_screen_jumptable_codes - 1) 20 | bne chrout_try_jumptable_loop_noquote 21 | 22 | ; Is this insert/quote mode? 23 | tay 24 | lda QTSW 25 | ora INSRT 26 | beq :+ 27 | tya 28 | jmp chrout_screen_quote 29 | : 30 | tya 31 | 32 | ; FALLTROUGH 33 | 34 | chrout_try_jumptable_loop_noquote: 35 | 36 | cmp chrout_screen_jumptable_codes, x 37 | bne :+ 38 | 39 | ; Found, perform a jump to subroutine 40 | lda chrout_screen_jumptable_hi, x 41 | pha 42 | lda chrout_screen_jumptable_lo, x 43 | pha 44 | rts 45 | : 46 | dex 47 | bpl chrout_try_jumptable_loop 48 | 49 | chrout_try_COLOR: 50 | 51 | ldx #$0F 52 | 53 | chrout_try_color_loop: 54 | 55 | cmp colour_codes,x 56 | bne :+ 57 | lda COLOR 58 | and #$f0 59 | stx COLOR 60 | ora COLOR 61 | sta COLOR 62 | jmp chrout_screen_done 63 | : 64 | dex 65 | bpl chrout_try_color_loop 66 | 67 | ; Unknown code, or key not requiring any handling 68 | jmp chrout_screen_done 69 | --------------------------------------------------------------------------------