move samples that only work for a specific target into subdirs named the same as the target
This commit is contained in:
59
samples/supervision/Makefile
Normal file
59
samples/supervision/Makefile
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
# Run 'make SYS=<target>'; or, set a SYS env.
|
||||
# var. to build for another target system.
|
||||
SYS ?= supervision
|
||||
|
||||
# Just the usual way to find out if we're
|
||||
# using cmd.exe to execute make rules.
|
||||
ifneq ($(shell echo),)
|
||||
CMD_EXE = 1
|
||||
endif
|
||||
|
||||
ifdef CMD_EXE
|
||||
NULLDEV = nul:
|
||||
DEL = -del /f
|
||||
RMDIR = rmdir /s /q
|
||||
else
|
||||
NULLDEV = /dev/null
|
||||
DEL = $(RM)
|
||||
RMDIR = $(RM) -r
|
||||
endif
|
||||
|
||||
ifdef CC65_HOME
|
||||
AS = $(CC65_HOME)/bin/ca65
|
||||
CC = $(CC65_HOME)/bin/cc65
|
||||
CL = $(CC65_HOME)/bin/cl65
|
||||
LD = $(CC65_HOME)/bin/ld65
|
||||
SP = $(CC65_HOME)/bin/sp65
|
||||
else
|
||||
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
|
||||
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
|
||||
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
|
||||
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
|
||||
SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65)
|
||||
endif
|
||||
|
||||
EXELIST_supervision = \
|
||||
hello
|
||||
|
||||
ifneq ($(EXELIST_$(SYS)),)
|
||||
samples: $(EXELIST_$(SYS))
|
||||
else
|
||||
samples: notavailable
|
||||
endif
|
||||
|
||||
# empty target used to skip systems that will not work with any program in this dir
|
||||
notavailable:
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
@echo "info: supervision samples not available for" $(SYS)
|
||||
else
|
||||
# suppress the "nothing to be done for 'samples' message
|
||||
@echo > $(NULLDEV)
|
||||
endif
|
||||
|
||||
hello: hello.c
|
||||
$(CL) -t $(SYS) -O -o hello -m hello.map hello.c
|
||||
|
||||
clean:
|
||||
@$(DEL) $(EXELIST_supervision) 2>$(NULLDEV)
|
||||
@$(DEL) *.map 2>$(NULLDEV)
|
||||
95
samples/supervision/hello.c
Normal file
95
samples/supervision/hello.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Watara Supervision sample C program */
|
||||
/* */
|
||||
/* Fabrizio Caruso (fabrizio_caruso@hotmail.com), 2019 */
|
||||
/* Greg King (greg.king5@verizon.net), 2021 */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <supervision.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Number of words per screen line (Remark: Last 4 words aren't displayed) */
|
||||
#define WORDS_PER_LINE (160/8+4)
|
||||
|
||||
struct sv_vram {
|
||||
unsigned int v[160/8][8][WORDS_PER_LINE];
|
||||
};
|
||||
#define SV_VRAM ((*(struct sv_vram *)0x4000).v)
|
||||
|
||||
/* Character definitions in 8x8 format */
|
||||
/* That format gives us a screen of 20 columns and 20 rows */
|
||||
static const unsigned char h_char[] = {0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00};
|
||||
static const unsigned char e_char[] = {0x7E,0x60,0x60,0x78,0x60,0x60,0x7E,0x00};
|
||||
static const unsigned char l_char[] = {0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x00};
|
||||
static const unsigned char o_char[] = {0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x00};
|
||||
static const unsigned char w_char[] = {0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00};
|
||||
static const unsigned char r_char[] = {0x7C,0x66,0x66,0x7C,0x78,0x6C,0x66,0x00};
|
||||
static const unsigned char d_char[] = {0x78,0x6C,0x66,0x66,0x66,0x6C,0x78,0x00};
|
||||
|
||||
static void clear_screen(void)
|
||||
{
|
||||
memset(SV_VIDEO, 0, 0x2000);
|
||||
}
|
||||
|
||||
/* Necessary conversion to have 2 bits per pixel with darkest hue */
|
||||
/* Remark: The Supervision uses 2 bits per pixel, and bits are mapped into pixels in reversed order */
|
||||
static unsigned int __fastcall__ double_reversed_bits(unsigned char)
|
||||
{
|
||||
__asm__("stz ptr2");
|
||||
__asm__("stz ptr2+1");
|
||||
__asm__("ldy #$08");
|
||||
L1: __asm__("lsr a");
|
||||
__asm__("php");
|
||||
__asm__("rol ptr2");
|
||||
__asm__("rol ptr2+1");
|
||||
__asm__("plp");
|
||||
__asm__("rol ptr2");
|
||||
__asm__("rol ptr2+1");
|
||||
__asm__("dey");
|
||||
__asm__("bne %g", L1);
|
||||
__asm__("lda ptr2");
|
||||
__asm__("ldx ptr2+1");
|
||||
return __AX__;
|
||||
}
|
||||
|
||||
static void display_char(const unsigned char x, const unsigned char y, const unsigned char *ch)
|
||||
{
|
||||
unsigned char k;
|
||||
|
||||
for(k=0;k<8;++k)
|
||||
{
|
||||
SV_VRAM[y][k][x] = double_reversed_bits(ch[k]);
|
||||
}
|
||||
}
|
||||
|
||||
static void init_lcd(void)
|
||||
{
|
||||
SV_LCD.width = 160;
|
||||
SV_LCD.height = 160;
|
||||
}
|
||||
|
||||
static void hello(unsigned char x, unsigned char y)
|
||||
{
|
||||
display_char(x+ 0,y,h_char);
|
||||
display_char(x+ 1,y,e_char);
|
||||
display_char(x+ 2,y,l_char);
|
||||
display_char(x+ 3,y,l_char);
|
||||
display_char(x+ 4,y,o_char);
|
||||
|
||||
display_char(x+ 6,y,w_char);
|
||||
display_char(x+ 7,y,o_char);
|
||||
display_char(x+ 8,y,r_char);
|
||||
display_char(x+ 9,y,l_char);
|
||||
display_char(x+10,y,d_char);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
init_lcd();
|
||||
clear_screen();
|
||||
|
||||
hello(2,3);
|
||||
hello(7,16);
|
||||
}
|
||||
Reference in New Issue
Block a user