1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-28 10:51:14 +00:00
C02/vic20/pointers.c02

85 lines
1.6 KiB
Plaintext
Raw Normal View History

2018-01-28 18:57:49 +00:00
/************************************
* POINTERS - Test pointer.h02 Library *
************************************/
#include "include/vic20.h02"
#include <stdio.h02>
#include <pointer.h02>
char savelo, savehi; //Pointer Storage Variable
char ptemp; //Memory Marker for Compare
2018-01-28 18:57:49 +00:00
main:
//Set Pointer to Cassette Buffer
putstr("SET POINTER TO TBFFR");
ptrset(&tbffr);
prpntr();
newlin();
//Demonstrate Compare
putstr("COMPARE AGAINST");
outstr(" TEMP0 $");
prbyte(ptrcmp(&temp0)); newlin();
outstr(" TBFFR $");
prbyte(ptrcmp(&tbffr)); newlin();
outstr(" PTEMP $");
prbyte(ptrcmp(&ptemp)); newlin();
2018-01-28 18:57:49 +00:00
newlin();
anykey();
//Demonstrate Get, Put, Inc, and Dec
putstr("PUT '*' AT POINTER");
ptrput('*');
prpntr();
putstr("DECREMENT POINTER");
ptrdec();
prpntr();
outstr("GOT FROM POINTER: ");
putchr(ptrget());
newlin();
prpntr();
putstr("INCREMENT POINTER");
ptrinc();
prpntr();
newlin();
//Demonstrate Add and Subtract
putstr("ADD $FF TO POINTER");
ptradd($FF);
prpntr();
putstr("SUBTRACT $FF");
ptrsub($FF);
prpntr();
newlin();
anykey();
//Demonstrate Save and Restore
putstr("SAVE POINTER");
savelo = ptrlo; savehi = ptrhi;
2018-01-28 18:57:49 +00:00
putstr("CLEAR POINTER");
ptrlo = 0; ptrhi = 0;
prpntr();
putstr("RESTORE FROM PSAVE");
ptrlo = savelo; ptrhi = savehi;
2018-01-28 18:57:49 +00:00
prpntr();
goto exit;
//Print Pointer Contents
void prpntr() {
outstr(" POINTER IS NOW ");
prbyte(ptrhi);
prbyte(ptrlo);
newlin();
}
//Wait for Keypress
void anykey() {
putstr("PRESS ANY KEY...");
getchr();
newlin();
newlin();
}