Here's an illustration what I'm trying to do. I
I don't understand how to do array completely. I don't know how to directly put data in a specific RAM area. Any help or example appreciated.
Posted Mon Aug 23, 2010 9:37 PM
Posted Tue Aug 24, 2010 12:10 AM
unsigned char vram_buf[8]; /* defines an 8-byte buffer in VDP RAM */ get_vram(0x480, vram_buf, 8); /* assuming VRAM source is first parameter */ put_vram(0x408, vram_buf, 8); /* assuming VRAM dest is first parameter */
// used for patcpy
unsigned char tmpbuf[8];
// base address in VDP RAM of the pattern table
#define gPATTERN 0x1000
// copies a VDP character pattern
void patcpy(int8 from, int8 to) {
cvu_vmemtomemcpy(tmpbuf, ((int)from<<3)+gPATTERN, 8);
cvu_memtovmemcpy(((int)to<<3)+gPATTERN, tmpbuf, 8);
}
Posted Tue Aug 24, 2010 1:15 AM
Posted Fri Aug 27, 2010 9:45 PM
byte spelltext,e,f;
[codes]
f = 18;
put_char(3,f,0x01);
e = 0;
while (e==0)
{
if(joypad_1&(UP|DOWN))
{
print_at(3,f," ");
if(joypad_1&DOWN)f--;
if(joypad_1&UP)f++;
put_char(3,f,0x01);
}
if(joypad_1&FIRE1)e++;
delay(1);
}
if(f==18)
{
ClearTextBox();
print_at(3,16,"King:");
print_at(3,18,"Thank you! you are so");
print_at(3,19,"kind!");
}
if(f==19)
{
ClearTextBox();
print_at(3,16,"King:");
print_at(3,18,"The dragon is... ");
print_at(3,19,"um... I don't know.");
print_at(3,20,"People in our town");
print_at(3,21,"probably can help you.");
}
if(f==20)
{
ClearTextBox();
print_at(3,16,"King:");
print_at(3,18,"How dare you reject my");
print_at(3,19,"request!!! Thou art the");
print_at(3,20,"hero! Please help me");
print_at(3,21,"get Plum back!PLEASE!!");
}
pause();
Posted Fri Aug 27, 2010 11:58 PM
Posted Sat Aug 28, 2010 8:26 AM
Posted Sat Aug 28, 2010 2:24 PM
enable_nmi();
choice:
print_at(3,16,"Choose a choice below.");
print_at(3,18," Yes, I will help you.");
print_at(3,19," Where is the dragon? ");
print_at(3,20," No I cannot help you.");
f = 18;
e = 0;
put_char(3,f,0x01);
delay(2);
while (e==0)
{
if(joypad_1&(UP|DOWN))
{
print_at(3,f," ");
if(joypad_1&DOWN && f!=20)f++;
if(joypad_1&UP && f!=18)f--;
put_char(3,f,0x01);
}
if(joypad_1&FIRE1)e++;
delay(1);
}
Works. There is a delay function in the loop, and delay(2) before it to prevent pushing the fire button accidentally before reading all the choices. Plus enable_nmi does slow the program when it is enable. I remove the delay function when there are only 2 choices. 3 or more will have delay() function in it. I will consider changing the while (e==0) to while(!(joypad_1&FIRE1)) to erase the e=0;, saving several bytes in my program. Also save my confusion for forgetting to set e to 0. I probably change the ifs into cases instead once I understand how it works, which I think it'll save bytes. Thanks for your advice Bruce.
Posted Sat Aug 28, 2010 8:42 PM
0 members, 1 guests, 0 anonymous users