//----------------------------------------------------------- // load_binary Demo // Demonstrates loading binary data from a file at compile time // using the Starlark scripting built-in load_binary(). // // The SCRIPT block reads screendata.bin (40 bytes of C64 // screen codes) and emits them as assembler data. At runtime, // a c65gm FOR loop copies the data to screen memory ($0400) // using WORD pointers with self-modifying code. // // Build: c65gm load_binary_demo.c65 //----------------------------------------------------------- #INCLUDE GOTO start //----------------------------------------------------------- // Load binary data at compile time using Starlark load_binary() // and emit it as data statements in the assembly output. //----------------------------------------------------------- SCRIPT data = load_binary("screendata.bin") print("; Loaded %d bytes from screendata.bin" % len(data)) print("scrdata:") for i in range(0, len(data), 8): row = ", ".join(["%d" % b for b in data[i:i+8]]) print(" !8 " + row) ENDSCRIPT LABEL start // Pointers to source data and screen memory WORD src WORD dst BYTE i BYTE val POINTER src TO scrdata POINTER dst TO $0400 // Copy 40 bytes from scrdata to screen memory FOR i = 0 TO 39 val = PEEK src POKE dst, val src++ dst++ NEXT SUBEND