feat(buzbee): BUZBEE command tables now generated with bbmkcmds.c
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,7 +6,8 @@
|
|||||||
*.s19
|
*.s19
|
||||||
build/
|
build/
|
||||||
map.txt
|
map.txt
|
||||||
bbhashtool
|
bbmkcmds
|
||||||
|
|
||||||
# Build system generated files
|
# Build system generated files
|
||||||
src/version.s
|
src/version.s
|
||||||
|
src/bbcmds.s
|
||||||
|
38
bbhashtool.c
38
bbhashtool.c
@@ -1,38 +0,0 @@
|
|||||||
/* Generates "hashes" from ASCII strings to be used in BUZBEE */
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
const int CCH_CMD = 4;
|
|
||||||
|
|
||||||
int mkhash(const char pszCmd[]);
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
/* Add your commands here to be hashed. Imprtant that they all be CCH_CMD
|
|
||||||
* chars long EXCLUDING the NUL terminator. */
|
|
||||||
char *ppszCmds[] = {
|
|
||||||
"CALL",
|
|
||||||
"EXEC",
|
|
||||||
"HELP",
|
|
||||||
"PEEK",
|
|
||||||
"POKE",
|
|
||||||
"SREC",
|
|
||||||
/* "BOOT", */
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int iCmd = 0; iCmd < (sizeof(ppszCmds) / sizeof(char *)); iCmd++)
|
|
||||||
printf("BBC%s\n fcb $%.2X\n", ppszCmds[iCmd], mkhash(ppszCmds[iCmd]));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mkhash(const char pszCmd[]) {
|
|
||||||
uint8_t nhash = 0;
|
|
||||||
|
|
||||||
/* NOTE: Very important that condition is the length of the string MINUS the
|
|
||||||
* NUL terminator, in this case iChar < 4 */
|
|
||||||
for (int iChar = 0; iChar < CCH_CMD; iChar++)
|
|
||||||
nhash = nhash - pszCmd[iChar];
|
|
||||||
|
|
||||||
return nhash;
|
|
||||||
}
|
|
66
bbmkcmds.c
Normal file
66
bbmkcmds.c
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* Generates BUZBEE command data table asm file */
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Length of commands in printable-char count (excluding NUL terminator). */
|
||||||
|
const int s_cchCmd = 4;
|
||||||
|
|
||||||
|
/* Add your commands here to be hashed. Imprtant that they all be CCH_CMD
|
||||||
|
* chars long EXCLUDING the NUL terminator. */
|
||||||
|
const char *s_ppszCmds[] = {
|
||||||
|
"CALL",
|
||||||
|
"EXEC",
|
||||||
|
"HELP",
|
||||||
|
"PEEK",
|
||||||
|
"POKE",
|
||||||
|
"SREC",
|
||||||
|
/* "BOOT", */
|
||||||
|
};
|
||||||
|
|
||||||
|
int mkHash(const char pszCmd[]);
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
/* Emit file header */
|
||||||
|
puts("; CHIBI PC-09 -- BUZBEE -- Command Data\n\
|
||||||
|
; Copyright (c) 2025 Gale Faraday\n\
|
||||||
|
; Licensed under MIT\n\
|
||||||
|
\n\
|
||||||
|
; This file generated by bbmkcmds.c\n\
|
||||||
|
\n\
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\
|
||||||
|
;;\n\
|
||||||
|
;; BUZBEE Command Data\n\
|
||||||
|
;;\n\
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\
|
||||||
|
\n\
|
||||||
|
SECTION BBCMDS\n");
|
||||||
|
|
||||||
|
for (int iCmd = 0; iCmd < sizeof(s_ppszCmds) / sizeof(char *); iCmd++) {
|
||||||
|
const char *pszLabel = s_ppszCmds[iCmd];
|
||||||
|
printf(" EXPORT BBC%s\n", pszLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Extra newline */
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
/* Emit table data */
|
||||||
|
for (int iCmd = 0; iCmd < sizeof(s_ppszCmds) / sizeof(char *); iCmd++) {
|
||||||
|
const char *pszLabel = s_ppszCmds[iCmd];
|
||||||
|
uint8_t uHash = mkHash(s_ppszCmds[iCmd]);
|
||||||
|
printf("BBC%s\n fcb $%.2X\n", pszLabel, uHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mkHash(const char pszCmd[]) {
|
||||||
|
uint8_t nhash = 0;
|
||||||
|
|
||||||
|
/* NOTE: Very important that condition is the length of the string MINUS the
|
||||||
|
* NUL terminator, in this case iChar < 4 */
|
||||||
|
for (int iChar = 0; iChar < s_cchCmd; iChar++)
|
||||||
|
nhash = nhash - pszCmd[iChar];
|
||||||
|
|
||||||
|
return nhash;
|
||||||
|
}
|
11
makefile
11
makefile
@@ -13,7 +13,7 @@ TARGREC := $(TARGET).s19
|
|||||||
TARGROM := $(TARGET).bin
|
TARGROM := $(TARGET).bin
|
||||||
SRCDIR := src/
|
SRCDIR := src/
|
||||||
BUILDDIR := build/
|
BUILDDIR := build/
|
||||||
GENS := $(SRCDIR)version.s
|
GENS := $(SRCDIR)version.s $(SRCDIR)bbcmds.s
|
||||||
SRCS := $(wildcard $(SRCDIR)*.s)
|
SRCS := $(wildcard $(SRCDIR)*.s)
|
||||||
OBJS := $(patsubst $(SRCDIR)%.s,$(BUILDDIR)%.o,$(SRCS))
|
OBJS := $(patsubst $(SRCDIR)%.s,$(BUILDDIR)%.o,$(SRCS))
|
||||||
INCS := $(wildcard $(SRCDIR)*.inc)
|
INCS := $(wildcard $(SRCDIR)*.inc)
|
||||||
@@ -48,11 +48,18 @@ $(OBJS): $(BUILDDIR)%.o : $(SRCDIR)%.s
|
|||||||
-@mkdir -p $(BUILDDIR)
|
-@mkdir -p $(BUILDDIR)
|
||||||
$(AS) $(ASFLAGS) -o $@ $<
|
$(AS) $(ASFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
# Pseudo target for generation step
|
||||||
generate: $(GENS)
|
generate: $(GENS)
|
||||||
|
|
||||||
$(GENS):
|
# Run generation scripts
|
||||||
|
$(GENS): bbmkcmds
|
||||||
|
./bbmkcmds > src/bbcmds.s
|
||||||
./genver.sh
|
./genver.sh
|
||||||
|
|
||||||
|
# Build bbmkcmds, used to generate src/cmds.s
|
||||||
|
bbmkcmds: bbmkcmds.c
|
||||||
|
cc -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo 'Cleaning up intermediary files...'
|
@echo 'Cleaning up intermediary files...'
|
||||||
@rm -rv $(TARGROM) $(TARGREC) map.txt $(BUILDDIR)
|
@rm -rv $(TARGROM) $(TARGREC) map.txt $(BUILDDIR)
|
||||||
|
Reference in New Issue
Block a user