TempleOSCDV4.05.ISO
This commit is contained in:
1 parent
d1856315e0
commit
6fe38d2d9d
118 files changed
+4559
-5069
No files matched your search
Binary file not shown.
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
Char graphics are how games on the C64 were made. You don't need to do it
|
||||
this way, unless for fun. You can just make device context bigger than
|
||||
the screen and scroll around.
|
||||
|
||||
See $LK,"::/Demo/Games/RawHide.CPP"$ or $LK,"::/Demo/Games/BigGuns.CPP"$.
|
||||
|
||||
The nice thing about character graphics are the animations.
|
||||
*/
|
||||
|
||||
#define MAP_WIDTH (TEXT_COLS*2)
|
||||
#define MAP_HEIGHT (TEXT_ROWS*2)
|
||||
|
||||
#define CH_WATER '^'
|
||||
#define CH_LAND CH_SPACE
|
||||
#define CH_TREE '*'
|
||||
|
||||
U16 map[MAP_HEIGHT][MAP_WIDTH];
|
||||
|
||||
I64 screen_pix_x,screen_pix_y;
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *)
|
||||
{
|
||||
U16 *ptr;
|
||||
I64 i,j,y=screen_pix_y>>3;
|
||||
gr.hide_col=gr.hide_row=TRUE;
|
||||
gr.pan_text_x=7-screen_pix_x&7;
|
||||
gr.pan_text_y=7-screen_pix_y&7;
|
||||
for (i=0;i<task->win_height;i++) {
|
||||
ptr=&map[y++][screen_pix_x>>3];
|
||||
for (j=0;j<task->win_width;j++)
|
||||
//By the time you clip to window and handle Fs->scroll_x,Fs->scroll_y,
|
||||
//it is too much trouble to do raw access to gr.text_base like we do
|
||||
//in $LK,"::/Demo/Games/Maze.CPP"$.
|
||||
TextChar(task,FALSE,j,i,*ptr++);
|
||||
}
|
||||
}
|
||||
|
||||
U8 *old_font=text.font;
|
||||
U64 waves[4]={
|
||||
0x0011AA440011AA44,0x0022558800225588,
|
||||
0x0044AA110044AA11,0x0088552200885522};
|
||||
|
||||
U0 AnimateEndCB()
|
||||
{
|
||||
text.font=old_font;
|
||||
Exit;
|
||||
}
|
||||
|
||||
U0 AnimateTask(I64)
|
||||
{
|
||||
I64 i;
|
||||
U64 *font=MAlloc(256*8);
|
||||
Fs->task_end_cb=&AnimateEndCB;
|
||||
MemCpy(font,text.font,256*8);
|
||||
text.font=font;
|
||||
font[CH_TREE]=0x18187E7E3C3C18;
|
||||
while (TRUE) {
|
||||
font[CH_WATER]=waves[i++&0x3];
|
||||
Sleep(200);
|
||||
WinMgrSync;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ScrollTaskX(I64 sign)
|
||||
{
|
||||
I64 i;
|
||||
for (i=0;i<32;i++) {
|
||||
screen_pix_x=ClampI64(screen_pix_x+sign,0,
|
||||
(MAP_WIDTH-TEXT_COLS+1)*FONT_WIDTH);
|
||||
WinMgrSync;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ScrollTaskY(I64 sign)
|
||||
{
|
||||
I64 i;
|
||||
for (i=0;i<32;i++) {
|
||||
screen_pix_y=ClampI64(screen_pix_y+sign,0,
|
||||
(MAP_HEIGHT-TEXT_ROWS+2)*FONT_HEIGHT);
|
||||
WinMgrSync;
|
||||
}
|
||||
}
|
||||
|
||||
U0 Init()
|
||||
{
|
||||
I64 i,j,x,y;
|
||||
screen_pix_x=(MAP_WIDTH-TEXT_COLS)>>1*FONT_WIDTH;
|
||||
screen_pix_y=(MAP_HEIGHT-TEXT_ROWS)>>1*FONT_HEIGHT;
|
||||
|
||||
MemSetU16(map,CH_WATER+(BLUE<<4+LTBLUE)<<8,MAP_WIDTH*MAP_HEIGHT);
|
||||
for (i=1;i<MAP_WIDTH-1;i++)
|
||||
map[0][i]=map[MAP_HEIGHT-1][i]='Í'+(BLUE<<4+RED)<<8;
|
||||
for (i=1;i<MAP_HEIGHT-1;i++)
|
||||
map[i][0]=map[i][MAP_WIDTH-1]='º'+(BLUE<<4+RED)<<8;
|
||||
map[0][0] ='É'+(BLUE<<4+RED)<<8;
|
||||
map[0][MAP_WIDTH-1] ='»'+(BLUE<<4+RED)<<8;
|
||||
map[MAP_HEIGHT-1][0] ='È'+(BLUE<<4+RED)<<8;
|
||||
map[MAP_HEIGHT-1][MAP_WIDTH-1]='¼'+(BLUE<<4+RED)<<8;
|
||||
|
||||
for (i=0;i<20;i++) {
|
||||
x=MAP_WIDTH*Rand;
|
||||
y=MAP_HEIGHT*Rand;
|
||||
for (j=0;j<1000;j++) {
|
||||
map[y][x]=CH_LAND+(YELLOW<<4+BLACK)<<8;
|
||||
x=ClampI64(x+RandU16%3-1,0,MAP_WIDTH-1);
|
||||
y=ClampI64(y+RandU16%3-1,0,MAP_HEIGHT-1);
|
||||
}
|
||||
}
|
||||
for (i=0;i<100;i++) {
|
||||
do {
|
||||
x=MAP_WIDTH*Rand;
|
||||
y=MAP_HEIGHT*Rand;
|
||||
} while (map[y][x].u8[0]!=CH_LAND);
|
||||
for (j=0;j<100;j++) {
|
||||
map[y][x]=CH_TREE+(YELLOW<<4+GREEN)<<8;
|
||||
x=ClampI64(x+RandU16%3-1,0,MAP_WIDTH-1);
|
||||
y=ClampI64(y+RandU16%3-1,0,MAP_HEIGHT-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 CleanUp()
|
||||
{
|
||||
gr.pan_text_x=gr.pan_text_y=0;
|
||||
gr.hide_col=gr.hide_row=FALSE;
|
||||
}
|
||||
|
||||
U0 CharDemo()
|
||||
{
|
||||
I64 sc;
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->text_attr=YELLOW<<4+BLUE;
|
||||
AutoComplete;
|
||||
WinBorder;
|
||||
WinMax;
|
||||
DocCursor;
|
||||
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
" Up(,,SC_CURSOR_UP);"
|
||||
" Down(,,SC_CURSOR_DOWN);"
|
||||
"}"
|
||||
);
|
||||
Init;
|
||||
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
|
||||
Fs->draw_it=&DrawIt;
|
||||
try {
|
||||
while (TRUE) {
|
||||
switch (GetKey(&sc)) {
|
||||
case 0:
|
||||
switch (sc.u8[0]) {
|
||||
case SC_CURSOR_LEFT:
|
||||
Spawn(&ScrollTaskX,-1,"Scroll",,Fs);
|
||||
break;
|
||||
case SC_CURSOR_RIGHT:
|
||||
Spawn(&ScrollTaskX,1,"Scroll",,Fs);
|
||||
break;
|
||||
case SC_CURSOR_UP:
|
||||
Spawn(&ScrollTaskY,-1,"Scroll",,Fs);
|
||||
break;
|
||||
case SC_CURSOR_DOWN:
|
||||
Spawn(&ScrollTaskY,1,"Scroll",,Fs);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
CleanUp;
|
||||
Init;
|
||||
break;
|
||||
case CH_SHIFT_ESC:
|
||||
case CH_ESC:
|
||||
goto sq_done;
|
||||
}
|
||||
}
|
||||
sq_done: //Don't goto out of try
|
||||
} catch
|
||||
PutExcept;
|
||||
SettingsPop;
|
||||
CleanUp;
|
||||
MenuPop;
|
||||
}
|
||||
|
||||
CharDemo;
|
||||
@@ -27,7 +27,7 @@ RegExeBranch("TempleOS/EagleDive");
|
||||
class Panel
|
||||
{
|
||||
Panel *next;
|
||||
I32 n, //num polygon sides
|
||||
I32 n, //num polygon sides
|
||||
num; //panel number
|
||||
CD3I32 *pts;
|
||||
I64 color,cnt;
|
||||
@@ -49,15 +49,6 @@ $SP,"<1>",BI=1$
|
||||
|
||||
|
||||
I64 critical_section_flag;
|
||||
U0 CriticalSectionStart()
|
||||
{
|
||||
while (LBts(&critical_section_flag,0))
|
||||
Yield;
|
||||
}
|
||||
U0 CriticalSectionEnd()
|
||||
{
|
||||
LBtr(&critical_section_flag,0);
|
||||
}
|
||||
|
||||
/*These are $BK,1$NOT$BK,0$ dealloced after the program ends,
|
||||
but I did them this way for your benefit
|
||||
@@ -181,9 +172,10 @@ U0 MPDoPanels(CTask *task)
|
||||
tempf->p.x=(i+w/2)*MAP_SCALE;
|
||||
tempf->p.y=(j+h/2)*MAP_SCALE;
|
||||
tempf->p.z=l;
|
||||
CriticalSectionStart;
|
||||
while (LBts(&critical_section_flag,0))
|
||||
Yield;
|
||||
QueIns(tempf,fish_root.last);
|
||||
CriticalSectionEnd;
|
||||
LBtr(&critical_section_flag,0);
|
||||
}
|
||||
} else {
|
||||
if (RandI16&1) {
|
||||
@@ -242,11 +234,12 @@ U0 MPDoPanels(CTask *task)
|
||||
}
|
||||
}
|
||||
if (end_ptr) {
|
||||
CriticalSectionStart;
|
||||
while (LBts(&critical_section_flag,0))
|
||||
Yield;
|
||||
if (end_ptr)
|
||||
end_ptr->next=panel_root;
|
||||
panel_root=start_ptr;
|
||||
CriticalSectionEnd;
|
||||
LBtr(&critical_section_flag,0);
|
||||
}
|
||||
LBtr(&mp.init_not_done_flags,Gs->num);
|
||||
}
|
||||
@@ -443,7 +436,7 @@ U0 MPDrawIt(CTask *task,CDC *dc)
|
||||
yy+=y3;
|
||||
}
|
||||
|
||||
if (Gs->num&1) {//alternate left-right,right-left
|
||||
if (Gs->num&1) {//alt left-right,right-left
|
||||
yh2=-yh;
|
||||
xh2=-xh;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user