<commit_before>; Durango firmware (at least for prototype version)
; based on generic firmware template for minimOS·65
; v0.6.1b5
; (c)2015-2022 <NAME>
; last modified 20220105-0115

#define		ROM			_ROM
#define		HEADERS		_HEADERS
#define		FIRMWARE	_FIRMWARE
#define		DOWNLOAD	_DOWNLOAD
; setting 
; already set at FW_BASE via rom.s

.(
#ifdef	DOWNLOAD
#include "options/durango.h"
#include "macros.h"
#include "abi.h"
#include "zeropage.h"
* = $200
#include "firmware/durango.h"
.text
#else
;#include "../usual.h"
#endif
	* = FW_BASE					; 16 KiB ROM at $C000, otherwise at $2000-$5FFF

; *** since nanoBoot will start executing from first loaded address, an empty page with a JMP is mandatory ***
	JMP dreset					; skip up to two pages
; think about using the BRK handler (in bootloader firmware) to do JMP ($5FFC), like a regular reset

; could put here some routines, or tables, really disposable once booted into minimOS...

; *********************************
; *********************************
; *** administrative jump table *** this has been safely moved backwards, thanks to the mandatory jump instruction
; *********************************
; *********************************

-fw_admin:
#ifndef		FAST_FW
; generic functions, esp. interrupt related
	.word	gestalt				; GESTALT get system info (renumbered)
	.word	set_isr				; SET_ISR set IRQ vector
	.word	set_nmi				; SET_NMI set (magic preceded) NMI routine
	.word	set_dbg				; SET_DBG set debugger, new 20170517
	.word	chk_sum				; CHK_SUM *** new *** Fletcher-16 checksum
; pretty hardware specific
	.word	jiffy				; JIFFY set jiffy IRQ speed (enable hard int here)
	.word	irq_src				; IRQ_SOURCE get interrupt source in X for total ISR independence (check for enabled irq generator)
	.word	poweroff			; POWEROFF power-off, suspend or cold boot
	.word	freq_gen			; *** FREQ_GEN frequency generator hardware interface, TBD
; not for LOWRAM systems
	.word	install				; INSTALL copy jump table
	.word	patch				; PATCH patch single function (renumbered)
	.word	reloc				; RELOCate code and data (TBD)
	.word	nanolnk				; NANOLNK loader *** new
	.word	rle_dec				; RLE_DEC *** new *** RLE decoder
; basic I/O
	.word	conio				; CONIO, basic console with built-in video
#endif

; *** there's still some room for routines! ***
; ID strings unless residing on header
#ifdef	NOHEAD
fw_splash:
	.asc	"DURANGO FW 0.6.1", 0
#endif

; *** firmware code follows ***
#ifndef	NOHEAD
; header is expected to be page-aligned
	.dsb	FW_BASE+256-*, $FF

; *************************************
; *** first some ROM identification *** new 20150612 *** might go first with a proper bootloader BRK handler
; *************************************
fw_start:
	.asc 0, "m", CPU_TYPE		; standard system file wrapper, new format 20161010, experimental type
	.asc "****", CR				; flags TBD
	.asc "boot", 0				; standard filename
fw_splash:
#ifdef	DOWNLOAD
	.asc " *DOWNLOADABLE* "
#endif
	.asc "0.6.1  firmware for "	; machine description as comment
fw_mname:
	.asc	MACHINE_NAME, 0
; advance to end of header (may need extra fields for relocation)
	.dsb	fw_start + $F8 - *, $FF	; for ready-to-blow ROM, advance to time/date field

; *** date & time in MS-DOS format at byte 248 ($F8) ***
	.word	$6DA0				; time, 13.45
	.word	$5422				; date, 2022/1/2

fwSize	=	boot_end - fw_start - 256	; compute size NOT including header!

; filesize in top 32 bits NOT including header, new 20161216
	.word	fwSize				; filesize
	.word	0					; 64K space does not use upper 16-bit
; *** end of standard header ***
#endif

; *** cannot do proper shutdown as this will be executed first ***
; since this is the start point from nanoBoot, HERE starts the mOS firmware!

; ********************
; ********************
; *** cold restart ***
; ********************
; ********************

dreset:
; *** basic init *** could save a few bytes if unlikely to use a 65816, use basic_init02.s instead
#include "modules/basic_init02.s"
<commit_msg>make Durango firmware ROM-ready<commit_after>; Durango firmware
; based on generic firmware template for minimOS·65
; v0.6.1b6
; (c)2015-2022 <NAME>
; last modified 20220322-0945

#define		ROM			_ROM
#define		HEADERS		_HEADERS
#define		FIRMWARE	_FIRMWARE
;#define		DOWNLOAD	_DOWNLOAD
; setting 
; already set at FW_BASE via rom.s

.(
#ifdef	DOWNLOAD
#include "options/durango.h"
#include "macros.h"
#include "abi.h"
#include "zeropage.h"
* = $200
#include "firmware/durango.h"
.text
	* = FW_BASE					; 32 KiB ROM at $8000, otherwise at $2000-$5FFF

; *** since nanoBoot will start executing from first loaded address, an empty page with a JMP is mandatory ***
	JMP dreset					; skip up to two pages
; could put here some routines, or tables, really disposable once booted into minimOS...
#else
; these are temporarily included here
#include "options/durango.h"
#include "macros.h"
#include "abi.h"
#include "zeropage.h"
* = $200
#include "firmware/durango.h"
#include "../../forge/eh_basic/drv_ehbasic.h"
;#include "../usual.h"
.text
	* = ROM_BASE					; 32 KiB ROM at $8000, otherwise at $2000-$5FFF
; *** kludge app software and kernel included here ***
#include "../kernel.s"
; kernel includes suitable shell (options.h)
#include "../apps/ls.s"
#include "../apps/flags.s"
#include "../shell/miniMoDA.s"
#include "../../forge/eh_basic/ehbasic.s"

#endif


; *********************************
; *********************************
; *** administrative jump table *** this has been safely moved backwards, thanks to the mandatory jump instruction
; *********************************
; *********************************

-fw_admin:
#ifndef		FAST_FW
; generic functions, esp. interrupt related
	.word	gestalt				; GESTALT get system info (renumbered)
	.word	set_isr				; SET_ISR set IRQ vector
	.word	set_nmi				; SET_NMI set (magic preceded) NMI routine
	.word	set_dbg				; SET_DBG set debugger, new 20170517
	.word	chk_sum				; CHK_SUM *** new *** Fletcher-16 checksum
; pretty hardware specific
	.word	jiffy				; JIFFY set jiffy IRQ speed (enable hard int here)
	.word	irq_src				; IRQ_SOURCE get interrupt source in X for total ISR independence (check for enabled irq generator)
	.word	poweroff			; POWEROFF power-off, suspend or cold boot
	.word	freq_gen			; *** FREQ_GEN frequency generator hardware interface, TBD
; not for LOWRAM systems
	.word	install				; INSTALL copy jump table
	.word	patch				; PATCH patch single function (renumbered)
	.word	reloc				; RELOCate code and data (TBD)
	.word	nanolnk				; NANOLNK loader *** new
	.word	rle_dec				; RLE_DEC *** new *** RLE decoder
; basic I/O
	.word	conio				; CONIO, basic console with built-in video
#endif

; *** there's still some room for routines! ***
; ID strings unless residing on header
#ifdef	NOHEAD
fw_splash:
	.asc	"DURANGO FW 0.6.1", 0
#endif

; *** firmware code follows ***
#ifndef	NOHEAD
; header is expected to be page-aligned
	.dsb	FW_BASE+256-*, $FF

; *************************************
; *** first some ROM identification *** new 20150612 *** might go first with a proper bootloader BRK handler
; *************************************
fw_start:
	.asc 0, "m", CPU_TYPE		; standard system file wrapper, new format 20161010, experimental type
	.asc "****", CR				; flags TBD
	.asc "boot", 0				; standard filename
fw_splash:
#ifdef	DOWNLOAD
	.asc " *DOWNLOADABLE* "
#endif
	.asc "0.6.1b6 firmware for "	; machine description as comment
fw_mname:
	.asc	MACHINE_NAME, 0
; advance to end of header (may need extra fields for relocation)
	.dsb	fw_start + $F8 - *, $FF	; for ready-to-blow ROM, advance to time/date field

; *** date & time in MS-DOS format at byte 248 ($F8) ***
	.word	$6DA0				; time, 13.45
	.word	$5422				; date, 2022/1/2

fwSize	=	boot_end - fw_start - 256	; compute size NOT including header!

; filesize in top 32 bits NOT including header, new 20161216
	.word	fwSize				; filesize
	.word	0					; 64K space does not use upper 16-bit
; *** end of standard header ***
#endif

; *** cannot do proper shutdown as this will be executed first ***
; since this is the start point from nanoBoot, HERE starts the mOS firmware!

; ********************
; ********************
; *** cold restart ***
; ********************
; ********************

dreset:
; *** basic init *** could save a few bytes if unlikely to use a 65816, use basic_init02.s instead
#include "modules/basic_init02.s"

{'fraction_non_alphanumeric': 0.16792792792792793, 'fraction_numerical': 0.03231231231231231, 'mean_word_length': 3.9149940968122787, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6234326', 'n_tokens_mistral': 3103, 'n_tokens_neox': 2739, 'n_words': 995}