2018-01-28 18:57:49 +00:00
|
|
|
/************************************
|
|
|
|
* POINTERS - Test pointer.h02 Library *
|
|
|
|
************************************/
|
|
|
|
|
|
|
|
#include "include/vic20.h02"
|
|
|
|
#include <stdio.h02>
|
|
|
|
#include <pointer.h02>
|
|
|
|
|
2018-01-28 19:29:22 +00:00
|
|
|
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();
|
2018-01-28 19:29:22 +00:00
|
|
|
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
|
2018-01-28 19:29:22 +00:00
|
|
|
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");
|
2018-01-28 19:29:22 +00:00
|
|
|
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();
|
|
|
|
}
|