After reviewing the CC65 documentation, I noticed some functions that are similar to Action!. Specifically PeekW() to peek a word rather than a byte. To confirm it works as I think, I wrote a small program to determine a memory address via high byte & low byte calculation, and get the same address using peek word.
Here I grab the high byte and low byte of the screen memory vector using single byte peeks, then compute the address (high byte * 256, then add the low byte). I then use the word peek to get the address. The results are printed to confirm they match.
// ------------------------------------------------------------
// Program: peekpoke.c
// Desc...: Peek & Poke demonstration
// Author.: Ripdubski
// Date...: 202208
// Notes..: cl65 -v -O -t atari peekpoke.c -o peekpoke.xex
// ------------------------------------------------------------
// Pull in include files
#include <stdio.h>
#include <conio.h>
#include <peekpoke.h>
#include <atari.h>
// ------------------------------------------------------------
// Func...: void main(void)
// Desc...: Main routine
// ------------------------------------------------------------
void main(void)
{
// Declare vars
unsigned int iW, cW;
unsigned char cL,cH;
// Setup screen
clrscr();
printf("-[CC65 Peek/Poke Test]------------------");
// Show integer value and address of variable i
printf("\nPEEK\n");
// Byte Peeks
cL = PEEK(88);
cH = PEEK(89);
// Word Peek
iW = PEEKW(88);
// Compute byte peek address
cW = (cH * 256) + cL;
// Show results
printf("peek byte cH: %d\n", cH);
printf("peek byte cL: %d\n", cL);
printf(" address: %u\n", cW);
printf("peekw int iW: %u\n", iW);
printf("press any key\n");
while (! kbhit()) {}
// Exit
return;
}
The command used to build:
cl65 -v -O -t atarixl peekpoke.c -o peekpoke.xex
The output of the build process:
$ cl65 -v -t atarixl peekpoke.c -o peekpoke.xex
Opened include file '/usr/local/share/cc65/include/stdio.h'
Opened include file '/usr/local/share/cc65/include/stddef.h'
Opened include file '/usr/local/share/cc65/include/stdarg.h'
Opened include file '/usr/local/share/cc65/include/conio.h'
Opened include file '/usr/local/share/cc65/include/atari.h'
Opened include file '/usr/local/share/cc65/include/_gtia.h'
Opened include file '/usr/local/share/cc65/include/_pbi.h'
Opened include file '/usr/local/share/cc65/include/_pokey.h'
Opened include file '/usr/local/share/cc65/include/_pia.h'
Opened include file '/usr/local/share/cc65/include/_antic.h'
Opened include file '/usr/local/share/cc65/include/string.h'
Opened include file '/usr/local/share/cc65/include/stddef.h'
Opened include file '/usr/local/share/cc65/include/peekpoke.h'
Opened include file '/usr/local/share/cc65/include/atari.h'
0 errors, 0 warnings
Opened output file 'peekpoke.s'
Wrote output to 'peekpoke.s'
Closed output file 'peekpoke.s'
Opened 'peekpoke.xex'...
Dumping 'HEADER'
Writing 'EXEHDR'
Dumping 'SYSCHKHDR'
Writing 'SYSCHKHDR'
Dumping 'SYSCHKCHNK'
Writing 'SYSCHK'
Dumping 'SYSCHKTRL'
Writing 'SYSCHKTRL'
Dumping 'SRPREPHDR'
Writing 'SRPREPHDR'
Dumping 'SRPREPCHNK'
Writing 'LOWBSS'
Writing 'SRPREP'
Writing 'SHADOW_RAM'
Writing 'SHADOW_RAM2'
Dumping 'SRPREPTRL'
Writing 'SRPREPTRL'
Dumping 'MAINHDR'
Writing 'MAINHDR'
Dumping 'MAIN'
Writing 'STARTUP'
Writing 'LOWCODE'
Writing 'ONCE'
Writing 'CODE'
Writing 'RODATA'
Writing 'DATA'
Writing 'BSS'
Dumping 'TRAILER'
Writing 'AUTOSTRT'
A screenshot of the running program:
