Compare commits

...

3 Commits

Author SHA1 Message Date
Zorchenhimer b032b50b6a
[rom] Tweak output for packetMarkDataStart
Changed the variable names in the Asm() output for the
packetMarkDataStart type:

    ArgA -> Bank
    ArgB -> Addr
2025-10-26 19:01:03 -04:00
Zorchenhimer 31b297b2e0
[script] load_rom_screen, setup_sprite, & draw_debug_sprites
- Added comments for setup_sprite
- Renamed draw_string_sprites to draw_debug_sprites and added comments.
- Discovered load_rom_screen (opcode 0xA1)
2025-10-26 18:57:41 -04:00
Zorchenhimer 37711fa4bb
[script] Tweak CDL caching
Reworked the CDL caching to properly handle unknown bytes in scripts.
2025-10-26 18:33:10 -04:00
5 changed files with 53 additions and 24 deletions

View File

@ -180,7 +180,7 @@ func (p *packetMarkDataStart) dataType() string {
}
func (p *packetMarkDataStart) Asm() string {
return fmt.Sprintf("mark_datatype_start Type:%s ArgA:$%02X ArgB:$%02X ; Checksum:%02X",
return fmt.Sprintf("mark_datatype_start Type:%s Bank:$%02X Addr:$%02X00 ; Checksum:%02X",
p.dataType(), p.ArgA, p.ArgB, p.checksum)
}

View File

@ -7,6 +7,7 @@ import (
"strconv"
"fmt"
"slices"
"bytes"
)
type CodeDataLog struct {
@ -166,8 +167,11 @@ func (cdl *CodeDataLog) setCode(addr int) {
cdl.cache[addr] |= cdlCode
}
func (cdl *CodeDataLog) doCache() error {
func (cdl *CodeDataLog) doCache(size int) error {
cdl.cache = make(map[int]cdlBit)
for i := 0x6000; i < size+0x6000; i++ {
cdl.cache[i] = cdlUnknown
}
for _, rng := range cdl.Code {
start, err := strconv.ParseInt(rng.Start, 0, 32)
@ -215,15 +219,18 @@ func (cdl *CodeDataLog) doCache() error {
}
func CdlFromJson(r io.Reader) (*CodeDataLog, error) {
raw, err := io.ReadAll(r)
buf := bytes.NewReader(raw)
cdl := NewCDL()
dec := json.NewDecoder(r)
err := dec.Decode(cdl)
dec := json.NewDecoder(buf)
err = dec.Decode(cdl)
if err != nil {
return nil, err
}
//cdl.Data = []CdlRange{}
cdl.doCache()
cdl.doCache(len(raw))
return cdl, nil
}

View File

@ -69,7 +69,25 @@ var Instructions []*Instruction = []*Instruction{
&Instruction{ 0x9F, 6, 0, 0, false, ""},
&Instruction{ 0xA0, 2, 0, 1, false, ""},
&Instruction{ 0xA1, 1, 0, 0, false, ""},
// Draw a screen from ROM.
// ArgA is screen index (ArgA <= 14)
// 00 - Window (used as the unit screens in the english tapes)
// 01 - bricks??
// 02 - Notebook (used for the mid-lesson quizes in the english tapes)
// 03 - Blimp (used after english lessons, before Gold Tomahawk)
// 04 - Map of USA (used in english tapes before final quiz)
// 05 - Green rounded title card (used in math/science)
// 06 - Orange rounded title card (used in math/science)
// 07 - Blue Triangle title card (used in a math tape)
// 08 - Blue Sci-fi title card (used in science tapes)
// 09 - Green block border (from here on don't seem to be used)
// 0A - Generic brick border
// 0B - Generic twist border
// 0C - Generic yellow embossed border
// 0D - Generic blue diamond border
// 0E - Generic brownish border
&Instruction{ 0xA1, 1, 0, 0, false, "load_rom_screen"},
&Instruction{ 0xA2, 1, 0, 0, false, "buffer_palette"},
// Possibly a sprite setup routine. loads up some CHR data and some palette
@ -194,6 +212,14 @@ var Instructions []*Instruction = []*Instruction{
&Instruction{ 0xE0, 2, 0, 1, false, "modulo"},
&Instruction{ 0xE1, 4, 0, 0, false, ""},
// ArgA: Palette ID
// ArgB: FG palette index
// ArgC: BG palette index
// ArgD: Priority (something else too?)
// ArgE: X coord
// ArgF: Y coord
// ArgG: ??
&Instruction{ 0xE2, 7, 0, 0, false, "setup_sprite"},
// Pops a word off the stack, uses it as a pointer, and pushes the byte
@ -229,7 +255,10 @@ var Instructions []*Instruction = []*Instruction{
// ArgD: Priority (something else too?)
// ArgE: X coord
// ArgF: Y coord
&Instruction{ 0xEF, 6, 0, 0, false, "draw_string_sprites"},
// THIS WORD WRAPS APPARENTLY?????
// Duplicate tiles are ignored and not displayed. However, space is left
// for them as if they were. Word wrapping adds 17 to the Y offset.
&Instruction{ 0xEF, 6, 0, 0, false, "draw_debug_sprites"},
&Instruction{ 0xF0, 0, 0, 0, false, "disable_sprites"},
&Instruction{ 0xF1, 4, 0, 0, false, ""},

View File

@ -191,26 +191,19 @@ INNER:
}
// Add data tokens
for addr, bit := range p.script.CDL.cache {
if addr < 0x6002 {
continue
}
for addr := 0x6002; addr < len(rawinput)+0x6000; addr++ {
bit := p.script.CDL.cache[addr]
// ignore code bytes
if bit & cdlCode == cdlCode {
continue
}
// ignore labels outside the script's address range
if addr > len(rawinput)+0x6000 {
continue
}
if _, ok := p.script.Labels[addr]; ok {
p.script.Tokens = append(p.script.Tokens, &Token{
Offset: addr,
Inline: []InlineVal{NewWordVal([]byte{rawinput[addr-0x6000], rawinput[addr+1-0x6000]})},
IsVariable: true,
//Inline: []InlineVal{NewWordVal([]byte{rawinput[addr-0x6000], rawinput[addr+1-0x6000]})},
//IsVariable: true,
IsData: true,
cdl: bit.String(),
})

View File

@ -44,12 +44,12 @@ func (s *Script) DebugCDL(filename string) error {
return fmt.Errorf("origSize == 0")
}
if s.CDL.cache == nil {
err := s.CDL.doCache()
if err != nil {
return fmt.Errorf("doCache() error: %w", err)
}
}
//if s.CDL.cache == nil {
// err := s.CDL.doCache()
// if err != nil {
// return fmt.Errorf("doCache() error: %w", err)
// }
//}
dat := make([]byte, s.origSize)
for i := 2; i < len(dat); i++ {