This commit is contained in:
Carl-Henrik Skårstedt 2020-04-01 16:19:55 +02:00
commit c2492ab348
38 changed files with 39493 additions and 3 deletions

View File

@ -0,0 +1,91 @@
#
# fun2gs/Makefile
#
# This makefile was created by Jason Andersen
#
# I build on Windows-10 64-bit, this makefile is designed to run under
# a Windows-10 Command Prompt, and makes use of DOS shell commands
#
# In order to build this you need x65
#
# https://github.com/Sakrac/x65
#
# As far a free stuff, I setup a c:\bin directory, in my path
# the following packages and executables are in there
#
# Fine Tools from Brutal Deluxe
# http://www.brutaldeluxe.fr/products/crossdevtools/
# Cadius.exe
# Merlin32.exe
# OMFAnalyzer.exe
# LZ4.exe
#
# gnumake-4.2.1-x64.exe (with a symbolic link that aliases this to "make")
#
# https://apple2.gs/plus/
# gsplus32.exe (KEGS based GS Emulator fork by Dagen Brock)
# I configure this to boot the xrick.po image directly
# once that's done "make run" will build, update the disk image
# and boot into xrick2gs.
#
# Make and Build Variables
TARGETNAME = fun2gs
VPATH = src:obj
ASMFILES = $(wildcard asm/*.s)
OBJFILES += $(patsubst asm/%.s,obj/%.x65,$(ASMFILES))
ASM = x65
ASMFLAGS = -lst
# List of directories to create
DIRS=obj
help:
@echo.
@echo $(TARGETNAME) Makefile
@echo -------------------------------------------------
@echo build commands:
@echo make gs - Apple IIgs
@echo make image - Build Bootable .PO File
@echo make run - Build / Run IIgs on emulator
@echo make clean - Clean intermediate/target files
@echo make depend - Build dependencies
@echo -------------------------------------------------
@echo.
$(TARGETNAME).sys16: $(OBJFILES)
$(ASM) link.s $(TARGETNAME).sys16 -iobj -a2o -sym x65.sym -lst
gs: $(TARGETNAME).sys16
disk image: gs
@echo Updating $(TARGETNAME).po
@echo Remove $(TARGETNAME).sys16
cadius deletefile $(TARGETNAME).po /$(TARGETNAME)/$(TARGETNAME).sys16
@echo Add $(TARGETNAME).sys16
cadius addfile $(TARGETNAME).po /$(TARGETNAME) ./$(TARGETNAME).sys16
run: image
gsplus32
clean:
@echo Remove $(TARGETNAME).sys16
$(shell if exist $(TARGETNAME).sys16 echo Y | del $(TARGETNAME).sys16)
@echo Remove Intermediate Files
@del /q obj\*
depend:
@echo TODO - make dependencies
# Generic Rules
#objdir: obj
obj/%.x65 : asm/%.s
@echo Assembling $(<F)
$(ASM) $< -cpu=65816 -imacros -idata -obj $@ $(ASMFLAGS)
# Create all the directories
$(shell if not exist $(DIRS) mkdir $(DIRS))

View File

@ -0,0 +1 @@
FUN2GS.SYS16=Type(B3),AuxType(DB07),VersionCreate(24),MinVersion(00),Access(21),FolderInfo1(000000000000000000000000000000000000),FolderInfo2(000000000000000000000000000000000000)

View File

@ -0,0 +1,7 @@
xdef background.c1
section background, Data
background.c1:
incbin "background.c1"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,173 @@
*
* ORCA/M Format!!
* LZ4 Decompress by Brutal Deluxe!!!
*
include common.i
include dp.s
mx %00
xdef unpacklz4
xdef LZ4_Unpack
unpacklz4:
{
if 1
phb
phk
plb
sep #$20
lda dp.source+2
xba
lda dp.dest+2
rep #$31
tax
lda dp.dest
sta LZ4_Dst+1
plb
endif
rts
}
*
* int LZ4_Unpack(u8* pDest, u8* pPackedSource);
*
LZ4_Unpack start ASMCODE
pDest equ 5
pPackedSource equ 9
phb
phk
plb
sep #$20
lda pPackedSource+2,s ; Pull out the src/dst banks
xba
lda pDest+2,s ; Pull out the src/dst banks
rep #$31
tax ; Temp save in X
lda pDest,s
sta LZ4_Dst+1
lda pPackedSource+1,s ; address of packed source + 4, is the unpacked len
sta upl+2
lda pPackedSource,s
adc #12
sta upl+1
upl lda >0 ; packed length
adc #16 ; 16 bytes for packed buffer header
adc pPackedSource,s ; start of packed buffer
tay ; y has the pack data stop address
anop ; 1st packed Byte offset
lda pPackedSource,s ; skip 16 byte header on the source
adc #16
pha
txa
plx
jsr ASM_LZ4_Unpack
tay
anop ; Copy the Return address
lda 1,s
sta pPackedSource,s
lda 3,s
sta pPackedSource+2,s
tsc
sec
sbc #-8
tcs
tya ; return length
plb
rtl
*-------------------------------------------------------------------------------
ASM_LZ4_Unpack STA LZ4_Literal_3+1 ; Uncompress a LZ4 Packed Data buffer (64 KB max)
SEP #$20 ; A = Bank Src,Bank Dst
STA LZ4_Match_5+1 ; X = Header Size = 1st Packed Byte offset
STA LZ4_Match_5+2 ; Y = Pack Data Size
XBA ; => Return in A the length of unpacked Data
STA LZ4_ReadToken+3
STA LZ4_Match_1+3
STA LZ4_GetLength_1+3
REP #$30
STY LZ4_Limit+1
*--
LZ4_Dst LDY #$0000 ; Init Target unpacked Data offset
LZ4_ReadToken LDA >$AA0000,X ; Read Token Byte
INX
STA LZ4_Match_2+1
*----------------
LZ4_Literal AND #$00F0 ; >>> Process Literal Bytes <<<
BEQ LZ4_Limit ; No Literal
CMP #$00F0
BNE LZ4_Literal_1
JSR LZ4_GetLengthLit ; Compute Literal Length with next bytes
BRA LZ4_Literal_2
LZ4_Literal_1 LSR A ; Literal Length use the 4 bit
LSR A
LSR A
LSR A
*--
LZ4_Literal_2 DEC A ; Copy A+1 Bytes
LZ4_Literal_3 MVN $AA,$BB ; Copy Literal Bytes from packed data buffer
PHK ; X and Y are auto incremented
PLB
*----------------
LZ4_Limit CPX #$AAAA ; End Of Packed Data buffer ?
BEQ LZ4_End
*----------------
LZ4_Match TYA ; >>> Process Match Bytes <<<
SEC
LZ4_Match_1 SBC >$AA0000,X ; Match Offset
INX
INX
STA LZ4_Match_4+1
*--
LZ4_Match_2 LDA #$0000 ; Current Token Value
AND #$000F
CMP #$000F
BNE LZ4_Match_3
JSR LZ4_GetLengthMat ; Compute Match Length with next bytes
LZ4_Match_3 CLC
ADC #$0003 ; Minimum Match Length is 4 (-1 for the MVN)
*--
PHX
LZ4_Match_4 LDX #$AAAA ; Match Byte Offset
LZ4_Match_5 MVN $BB,$BB ; Copy Match Bytes from unpacked data buffer
PHK ; X and Y are auto incremented
PLB
PLX
*----------------
BRA LZ4_ReadToken
*----------------
LZ4_GetLengthLit LDA #$000F ; Compute Variable Length (Literal or Match)
LZ4_GetLengthMat STA LZ4_GetLength_2+1
LZ4_GetLength_1 LDA >$AA0000,X ; Read Length Byte
INX
AND #$00FF
CMP #$00FF
BNE LZ4_GetLength_3
CLC
LZ4_GetLength_2 ADC #$000F
STA LZ4_GetLength_2+1
BRA LZ4_GetLength_1
LZ4_GetLength_3 ADC LZ4_GetLength_2+1
RTS
*----------------
LZ4_End TYA ; A = Length of Unpack Data
RTS
*-------------------------------------------------------------------------------
end

View File

@ -0,0 +1,380 @@
*----- Merlin 16+ Directives
rel
dsk start.l
include common.i
; SECTION code
dbg XREF dbgprint_char
XREF background.c1
STRING FontOrder = " !""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
start ent
mx %00 ; assemble in 16 bit
rel ; Build a relocated S16 file
include Locator.Macs.s ; Macro Definition Files
include Mem.Macs.s
include Misc.Macs.s
include Util.Macs.s
include Sound.Macs.s
*----- Begin Of Program ----------
PHK ; Data Bank Register = Program Bank Register
PLB
; A has UserID
sta myID
bra .next
; work around OMF export bug
dc.t start
.next
; D = direct page address
; S = Stack Pointer
tsx
stx |mySP
tdc
sta |myDP
sec
tsc
sbc |myDP
inc ; Count byte # 0
sta |myBank0Size
JSR ToolInit ; Init Tools + Compact Memory + Ask Shadowing
JSR BackupEnv ; Backup environment (colors...)
*----- Your Code Starts Here ----------
phb
lda #$7FFF ; Length - 1
ldx #<background.c1 ; source address
ldy #$2000 ; dest address
mvn ^$e12000,^background.c1 ; dst/src addresses
plb
{
ldy #$2000+(32*160)
jsr PrintE1
text "Stack ADDR:"
dc.b 0
ldy #$2000+(40*160)
jsr PrintE1
text " DP ADDR:"
dc.b 0
ldy #$2000+(48*160)
jsr PrintE1
text "Bank0 Size:"
dc.b 0
ldy #$2000+(80*160)+(4*0)
jsr PrintE1
text "[Press any key to Quit]"
dc.b 0
ldy #$2000+(16*160)
jsr PrintE1
text "x65 OMF Test App"
dc.b 0
}
{
pool zpWork $e0-$100
zpWork zpCharNum.w
phb
* get us into bank e1
pea $e1e1
plb
plb
lda #32
ldy #$2000
clc
.loop
sta <zpCharNum
jsr dbgprint_char
tya
adc #4
tay
lda <zpCharNum
inc
cmp #64
bcc .loop
plb
}
{
pea $e1e1
plb
plb
ldy #$2000+(32*160)+(4*12)
lda >mySP
jsr PrintHEX
ldy #$2000+(40*160)+(4*12)
lda >myDP
jsr PrintHEX
ldy #$2000+(48*160)+(4*12)
lda >myBank0Size
jsr PrintHEX
phk
plb
}
JSR WaitForKey ; Wait until a Key is pressed
*----- End Of Program ---------
End JSR RestoreEnv ; Restore environment (colors...)
JSR ToolTerm ; End up Tools
JMP Exit ; Quit to the Launcher
************************************************************
******* INIT TOOL SET/ FREE TOOL CODE *******
************************************************************
ToolInit
; _TLStartUp ; Start Tools
; PHA
; _MMStartUp ; Start Memory Manager Tool Set
; PLA
; STA myID ; Get current ID
*--
_MTStartUp ; Start Miscellaneous Tool Set
*--
* clc ; grab the memory next to my DP
* lda |myDP
* adc #$100
* pha
* _SoundStartUp ; Start Sound Tool Set
*--
PushLong #0 ; Compact Memory
PushLong #$8fffff
PushWord myID
PushWord #%11000000_00000000
PushLong #0
_NewHandle
_DisposeHandle
_CompactMem
*--
// Allocate Bank 01 memory + 4K before and after (25 lines pre flow)
// $012000-$019BFF pixel data
// $019D00-$019DC7 SCB data
// $019E00-$019FFF Clut data
// $900 bytes afer, (14 lines buffer on the bottom, which will wreck SCB+CLUT
PushLong #0 ; Ask Shadowing Screen ($8000 bytes from $01/2000)
PushLong #$9600
PushWord myID
PushWord #%11000000_00000011
PushLong #$011000
_NewHandle
PLA
PLA
BCC :NoError
*--
:NoError
RTS
*-------
ToolTerm:
* _SoundShutDown ; Stop Tools
_MTShutDown
PushWord myID
_DisposeAll
; PushWord myID
; _MMShutDown
; _TLShutDown
RTS
myID ds 2 ; ID of this Program in memory
mySP ds 2
myDP ds 2
myBank0Size ds 2
*---------------------------------------
BackupEnv SEP #$30 ; Backup Environment values (color, border...)
LDAL $00C022
STA BE_C022
LDAL $00C029
STA BE_C029
LDAL $00C034
STA BE_C034
LDAL $00C035
STA BE_C035
REP #$30
RTS
*-----
RestoreEnv SEP #$30 ; Restore Environment values (color, border...)
LDA BE_C035
STAL $00C035
LDA BE_C034
STAL $00C034
LDA BE_C029
STAL $00C029
LDA BE_C022
STAL $00C022
REP #$30
RTS
BE_C022 byte 00 ; Background Color
BE_C029 byte 00 ; Linearization of the Graphic Page
BE_C034 byte 00 ; Border Color
BE_C035 byte 00 ; Shadowing
************************************************************
******* GS/OS CODE *******
************************************************************
GSOS = $E100A8
*-------
Exit JSL GSOS ; Quit Program
dc.w $2029
dc.l gsosQUIT
*-------
gsosQUIT ds.w 2 ; pCount
ds.b 4 ; pathname
ds.b 2 ; flags
************************************************************
******* EVENT HANDLER CODE *******
************************************************************
WaitForKey SEP #$30 ; Wait for a Key Press
WFK_1 LDAL $00c000
BPL WFK_1
STAL $00c010
REP #$30
RTS
************************************************************
*
* Print out a TEXT String, at memory location Y
* in Bank E1
*
PrintE1:
mx %00
{
pool zpWork $e0-$100
zpWork pString.l
* Setup pString as pointer to the string
plx
inx
stx <pString
phk
phk
pla
sta <pString+2
* Font render bank
pea $e1e1
plb
plb
clc
.loop
lda [pString]
and #$00FF
beq .done
sbc #31
jsr dbgprint_char
tya
adc #4
tay
inc <pString
bra .loop
.done
pei <pString
rts
}
************************************************************
*
* Print out a 16 bit hex number, at memory location Y
* in the current bank
*
PrintHEX:
mx %00
{
pha
xba
lsr
lsr
lsr
lsr
and #$000F
tax
lda >chartable,x
and #$00FF
jsr dbgprint_char
tya
adc #4
tay
lda 2,s
and #$000F
tax
lda >chartable,x
and #$00FF
jsr dbgprint_char
tya
adc #4
tay
lda 1,s
lsr
lsr
lsr
lsr
and #$000F
tax
lda >chartable,x
and #$00FF
jsr dbgprint_char
tya
adc #4
tay
pla
and #$000F
tax
lda >chartable,x
and #$00FF
jsr dbgprint_char
rts
chartable dc.b 16,17,18,19,20,21,22,23,24,25,33,34,35,36,37,38
}
************************************************************

View File

@ -0,0 +1,153 @@
#--------------------------------------------------------
# $File: Makefile,v $
#
# $Date: 2019/10/20 $
# $Author: jandersen $
# $Revision: #1 $
#--------------------------------------------------------
#
# ftile GCC-Gnu Makefile
#
# compile under *nix, or Windows Subsystem for Linux
SHELL = /bin/sh
MKDIR = mkdir
TARGET = ftile
PROJROOT = .
#SYSTEM = /usr
#SYSLIBDIR = $(SYSTEM)/lib
#SYSINCDIR = $(SYSTEM)/include
INCCMD = -I$(SYSINCDIR)
INCCMD += -I$(PROJROOT)/source
INCCMD += -I$(PROJROOT)/include
OBJDIR = $(PROJROOT)/obj
DEPDIR = $(PROJROOT)/dep
LSTDIR = $(PROJROOT)/lst
#
# Special GnuMake Search Path Directive
#
VPATH = $(PROJROOT)/source
#
# Dedicated Search Paths for Specific Types
#
# Can be used to speed up compile by using this feature
# for each filetype (reducing the amount of searching)
#
vpath %.o $(OBJDIR)
vpath %.d $(DEPDIR)
LIBCMD +=-lm
OBJS := ftile.o
OBJS += rawdata.o
# change list of .o's into a list of .d's
DEPS := $(OBJS:%.o=%.d)
AS = gcc
CC = gcc
LD = gcc
RM = /bin/rm -rfv
CFLAGS = -O2 -Wall -Werror -Wa,-al -fno-common
CXXFLAGS = -O2 -Wall -Werror -Wa,-al -fno-common
ASFLAGS = -c -xassembler-with-cpp -Wa,-al
LDFLAGS = -Wl,-Map,$(TARGET).map $(LIBCMD)
# Clear Default Suffixes
.SUFFIXES:
# Set my Own Suffixes
.SUFFIXES: .c .s .cc .d .o
all: $(TARGET)
$(TARGET): $(DEPS) $(OBJS) $(LIBS)
$(LD) -o $@ $(addprefix $(OBJDIR)/,$(OBJS)) $(LIBS) $(LDFLAGS)
# Object Rules
.s.o:
$(AS) $(ASFLAGS) $(TMPFLAGS) $(INCCMD) -o $(OBJDIR)/$@ $< > $(LSTDIR)/$*.lst
.c.o:
$(CC) $(CFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o > $(LSTDIR)/$*.lst
.cc.o:
$(CC) $(CXXFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o > $(LSTDIR)/$*.lst
# Dependencie Rules
#
# for now just touch, to create the file if its not defined
#
.s.d:
touch $(DEPDIR)/$*.d
.c.d:
set -e; $(CC) -M $(CFLAGS) $(INCCMD) $< \
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $(DEPDIR)/$@; \
[ -s $(DEPDIR)/$@ ] || rm -f $(DEPDIR)/$@
.cc.d:
set -e; $(CC) -M $(CXXFLAGS) $(INCCMD) $< \
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $(DEPDIR)/$@; \
[ -s $(DEPDIR)/$@ ] || rm -f $(DEPDIR)/$@
.PHONY: install
install: $(TARGET)
cp $(TARGET).exe $(PROJROOT)/../bin
.PHONY: clean
clean:
$(RM) $(OBJDIR) *.o $(DEPDIR) *.map $(LSTDIR) $(TARGET) $(TARGET).exe
########################################
#
# HELPER TARGET RULES
#
########################################
#
# Target that forces all of the objects to be rebuilt if the makefile changes
#
$(OBJS) : Makefile
$(DEPS) : Makefile
#
# Targets that create the output object directory if it doesn't already exist
#
Makefile : $(OBJDIR) $(DEPDIR) $(LSTDIR)
$(OBJDIR) :
$(MKDIR) $(OBJDIR)
#
# Targets that create the output dependency directory if it doesn't already exist
#
$(DEPDIR) :
$(MKDIR) $(DEPDIR)
#
# Targets that create the output list directory if it doesn't already exist
#
$(LSTDIR) :
$(MKDIR) $(LSTDIR)
#
# Generated Dependencie Files
#
-include $(wildcard $(DEPDIR)/*.d)

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
/*
bctypes.h
Because Standard Types
*/
#ifndef _bctypes_h
#define _bctypes_h
typedef signed char i8;
typedef unsigned char u8;
typedef signed short i16;
typedef unsigned short u16;
typedef signed long i32;
typedef unsigned long u32;
#if !_MSVC
typedef signed long long i64;
typedef unsigned long long u64;
#endif
typedef i32 bool;
typedef float f32;
typedef float r32;
typedef double f64;
typedef double r64;
#define false (0)
#define true (!false)
#define null (0)
// Odd Types
typedef union {
u64 ul64[2];
u32 ui32[4];
} QWdata;
#endif // _bctypes_h
// EOF - bctypes.h

View File

@ -0,0 +1,187 @@
/*
#--------------------------------------------------------
# $File: ftile.c,v $
#--------------------------------------------------------
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "bctypes.h"
#include "ftile.h"
#include "rawdata.h"
u16 GetBest16(unsigned char* pFrame, int width, int height)
{
return 0;
}
RAWDATA* gResult = NULL;
void AddString(RAWDATA* pRaw, char* pString)
{
size_t len = strlen(pString);
size_t newlen = len+pRaw->size;
pRaw->data = (unsigned char*) realloc(pRaw->data, newlen);
memcpy(pRaw->data + pRaw->size, pString, len);
pRaw->size = newlen;
}
int AddLine(char*pLabel,char*pInst,char*pExp,int val,int clocks)
{
if (gResult)
{
char temp[256];
char pArg[256];
memset(pArg,0,256);
sprintf(pArg,pExp,val);
sprintf(temp, "%8s %3s %s\n", pLabel,pInst,pArg);
AddString(gResult, temp);
}
return clocks;
}
void CompileTile(RAWDATA *result, u8* pTile)
{
static int offsets[16] =
{
(160 * 0) + 0, (160 * 0) + 2,
(160 * 1) + 0, (160 * 1) + 2,
(160 * 2) + 0, (160 * 2) + 2,
(160 * 3) + 0, (160 * 3) + 2,
(160 * 4) + 0, (160 * 4) + 2,
(160 * 5) + 0, (160 * 5) + 2,
(160 * 6) + 0, (160 * 6) + 2,
(160 * 7) + 0, (160 * 7) + 2
};
int clocks = 0;
u16 *pData = (u16*) pTile;
bool slots[16];
memset(slots, 0, sizeof(bool) * 16);
bool done = false;
while (!done)
{
u16 pixel = 0;
done = true;
// Load a cached Pixel
for (int idx = 0; idx < 16; ++idx)
{
if (slots[idx])
continue;
done = false;
pixel = pData[idx];
clocks += AddLine("","LDA","#$%04X",pixel,3);
break;
}
for (int outIdx = 0; outIdx < 16; ++outIdx)
{
if (slots[outIdx])
continue;
if (pixel == pData[outIdx])
{
clocks += AddLine("","STA","$%04X,Y",offsets[outIdx],6);
slots[outIdx] = true;
}
}
}
clocks += AddLine("","RTL"," ;%d cycles",clocks+6,6);
}
RAWDATA* CompileTiles(RAWDATA* pTilesData, int bank)
{
RAWDATA* result = (RAWDATA*)malloc(sizeof(RAWDATA));
memset(result, 0, sizeof(RAWDATA));
gResult = result;
int numTiles = pTilesData->size / 32; // (32 bytes per tile)
char temp_label[256];
for (int idx = 0; idx < numTiles; ++idx)
{
sprintf(temp_label," da tile%d_%d\n", bank, idx);
AddString(result, temp_label);
}
for (int tileNo = 0; tileNo < numTiles; ++tileNo)
{
sprintf(temp_label,"tile%d_%d\n", bank, tileNo);
AddString(result, temp_label);
CompileTile(result, &pTilesData->data[ tileNo * 32 ]);
}
return result;
}
static void _usage()
{
printf("ftile v%s\n\n", VERSION);
printf("Usage: ftile <input_raw8x8_tile_file>\n"
"Written by Jason Andersen\n"
"Copyright (c) 2019 Jason Andersen.\n"
"Unauthorized use prohibited\n");
exit(1);
} // usage
//
// Parse command line options
//
int main(int argc, char **argv)
{
// Check Arguments
while (--argc > 0 && (*++argv)[0] == '-')
{
*argv+=1;
if (strcmp("v", *argv) == 0)
{
printf("ftile v%s\n", VERSION);
exit(0);
}
*argv+= strlen(*argv); // skip rest of string
}
if (argc != 1) _usage();
RAWDATA* pData = loadRaw(argv[0]);
RAWDATA* pSource = CompileTiles(pData,0);
char outname[256];
strcpy(outname, argv[0]);
int len = strlen(outname);
strcpy(outname+(len-2), "txt");
saveRaw(pSource, outname);
printf("\nftile - Processing complete.\n");
exit(0);
} // main
// eof - xrick2png.c

View File

@ -0,0 +1,19 @@
/*
#--------------------------------------------------------
# $File: ftile.h,v $
# $Author: jandersen $
# $Revision: #1 $
#--------------------------------------------------------
*/
#ifndef _ftile_h
#define _ftile_h
#define VERSION "1.00"
#endif // _ftile_h
// EOF - ftile.h

View File

@ -0,0 +1,53 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "rawdata.h"
RAWDATA* loadRaw(const char* path)
{
FILE* rawFile = fopen( path, "rb" );
if (rawFile)
{
RAWDATA* pData = (RAWDATA*)malloc(sizeof(RAWDATA));
fseek(rawFile, 0, SEEK_END);
pData->size = ftell(rawFile);
fseek(rawFile, 0, SEEK_SET);
pData->data = (unsigned char*)malloc(pData->size);
size_t read_size = fread(pData->data, 1, pData->size, rawFile);
if (read_size != pData->size)
{
printf("WARNING: read %ld of %ld bytes\n", read_size, pData->size);
}
fclose(rawFile);
return pData;
}
return NULL;
}
void saveRaw(RAWDATA* pData, const char* path)
{
FILE* rawFile = fopen( path, "wb" );
if (rawFile)
{
fwrite(pData->data, 1, pData->size, rawFile);
fclose(rawFile);
}
}
// rawdata.c

View File

@ -0,0 +1,16 @@
#ifndef _rawdata_h_
#define _rawdata_h_
#include "bctypes.h"
typedef struct {
unsigned char* data; // pointer to data
size_t size; // size in bytes
} RAWDATA;
RAWDATA* loadRaw(const char* path);
void saveRaw(RAWDATA* pData, const char* path);
#endif //_rawdata_h_

View File

@ -0,0 +1,249 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
namespace png2c1
{
class Program
{
public class spPalette
{
public List<Color> colors = new List<Color>();
}
public class spPixels
{
public int m_width;
public int m_height;
public List<byte> m_pixels = new List<byte>();
public spPixels(int width, int height, List<byte> pixels)
{
m_width = width;
m_height = height;
m_pixels = pixels;
}
}
static void Main(string[] args)
{
List<spPalette> pals = new List<spPalette>();
List<spPixels> pics = new List<spPixels>();
Console.WriteLine("png2c1");
Console.WriteLine("{0}", args.Length);
byte[] scbs = new byte[200]; // 200 scanlines
byte scb_index = 0;
foreach(string arg in args)
{
String pngPath = arg;
String palPath = Path.ChangeExtension(pngPath, ".pal");
//--------------------------------------------------------------
// Read in the palette file (thanks Pro Motion)
Console.WriteLine($"Loading {palPath}");
spPalette pal = new spPalette();
using (FileStream palStream = new FileStream(palPath, FileMode.Open, FileAccess.Read))
{
for(int idx = 0; idx < 16; ++idx)
{
int r = palStream.ReadByte();
int g = palStream.ReadByte();
int b = palStream.ReadByte();
pal.colors.Add(Color.FromArgb(255, r, g, b));
}
}
// Put it in the list
pals.Add(pal);
//--------------------------------------------------------------
// Read in the image file
Console.WriteLine($"Loading {pngPath}");
using (var image = new Bitmap(System.Drawing.Image.FromFile(pngPath)))
{
//Bitmap image = new Bitmap(pngStream);
Console.WriteLine("{0} width={1}, height={2}",pngPath, image.Width, image.Height);
List<byte> pixels = new List<byte>();
for (int y = 0; y < image.Height; ++y)
{
Color p = image.GetPixel(0,y);
if (255 == p.A)
{
scbs[ y ] = scb_index;
}
for (int x = 0; x < image.Width; x+=2)
{
Color p0 = image.GetPixel(x,y);
Color p1 = image.GetPixel(x+1,y);
int idx0 = GetIndex(ref pal.colors, p0);
int idx1 = GetIndex(ref pal.colors, p1);
byte pb = (byte)((idx0<<4) | (idx1));
pixels.Add( pb );
}
}
spPixels pic = new spPixels(image.Width, image.Height, pixels);
pics.Add(pic);
}
scb_index++;
}
//foreach (byte scb in scbs)
//{
// Console.WriteLine("{0:X2}", scb);
//}
String outPath = Path.ChangeExtension(args[0], ".c1");
Console.WriteLine("Saving {0}", outPath);
using (BinaryWriter b = new BinaryWriter(
File.Open(outPath, FileMode.Create)))
{
for (int y = 0; y < scbs.Length; ++y)
{
int imageIdx = scbs[ y ];
spPixels pix = pics[ imageIdx ];
int pixIndex = 160 * y;
// Write out the scanline of pix
for (int idx = 0; idx < 160; ++idx)
{
b.Write((byte)pix.m_pixels[ pixIndex + idx ]);
}
}
// Save out the scbs
b.Write(scbs);
// Pad out the page
for (int idx = 0; idx < 56; ++idx)
{
b.Write((byte)0x00);
}
// Save out the palettes
for (int palIdx = 0; palIdx < 16; ++palIdx)
{
if (palIdx < pals.Count)
{
spPalette pal = pals[ palIdx ];
for (int idx = 0; idx < 16; ++idx)
{
UInt16 rgb = ToGSColor(pal.colors[idx]);
b.Write(rgb);
}
}
else
{
for (int idx = 0; idx < 16; ++idx)
{
b.Write((UInt16)0);
}
}
}
}
    
}
//
// Get a IIgs color
//
static UInt16 ToGSColor( Color pixel )
{
int red = pixel.R;
int green = pixel.G;
int blue = pixel.B;
// we want to round up if it's needed
red+=8;
green+=8;
blue+=8;
if (red > 255) red = 255;
if (green > 255) green = 255;
if (blue > 255) blue = 255;
red >>= 4;
green >>= 4;
blue >>= 4;
int color = (red << 8) |
(green << 4) |
(blue);
return (UInt16)color;
}
//
// Get the Closest Matching Palette Index
//
static int GetIndex(ref List<Color> pal, Color pixel)
{
byte result_index = 0;
if (pal.Count > 0)
{
List<float> dist = new List<float>();
for (int idx = 0; idx < pal.Count; ++idx)
{
float delta = ColorDelta(pal[idx], pixel);
dist.Add(delta);
// Make sure the result_index is the one
// with the least amount of error
if (dist[idx] < dist[result_index])
{
result_index = (byte)idx;
}
}
}
return result_index;
}
static float ColorDelta(Color c0, Color c1)
{
// Y=0.2126R+0.7152G+0.0722B
float r = (c0.R-c1.R);
r = r * r;
r *= 0.2126f;
float g = (c0.G-c1.G);
g = g * g;
g *= 0.7152f;
float b = (c0.B-c1.B);
b = b * b;
b *= 0.0722f;
return r + g + b;
}
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,202 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
namespace png2tiles
{
class Program
{
public class spPalette
{
public List<Color> colors = new List<Color>();
}
public class spPixels
{
public int m_width;
public int m_height;
public List<byte> m_pixels = new List<byte>();
public spPixels(int width, int height, List<byte> pixels)
{
m_width = width;
m_height = height;
m_pixels = pixels;
}
}
static void Main(string[] args)
{
List<spPalette> pals = new List<spPalette>();
List<spPixels> pics = new List<spPixels>();
Console.WriteLine("png2tiles");
Console.WriteLine("{0}", args.Length);
foreach(string arg in args)
{
String pngPath = arg;
String palPath = Path.ChangeExtension(pngPath, ".pal");
//--------------------------------------------------------------
// Read in the palette file (thanks Pro Motion)
Console.WriteLine($"Loading {palPath}");
spPalette pal = new spPalette();
using (FileStream palStream = new FileStream(palPath, FileMode.Open, FileAccess.Read))
{
for(int idx = 0; idx < 16; ++idx)
{
int r = palStream.ReadByte();
int g = palStream.ReadByte();
int b = palStream.ReadByte();
pal.colors.Add(Color.FromArgb(255, r, g, b));
}
}
// Put it in the list
pals.Add(pal);
//--------------------------------------------------------------
// Read in the image file
Console.WriteLine($"Loading {pngPath}");
using (var image = new Bitmap(System.Drawing.Image.FromFile(pngPath)))
{
//Bitmap image = new Bitmap(pngStream);
Console.WriteLine("{0} width={1}, height={2}",pngPath, image.Width, image.Height);
List<byte> pixels = new List<byte>();
for (int y = 0; y < image.Height; ++y)
{
for (int x = 0; x < image.Width; x+=2)
{
Color p0 = image.GetPixel(x,y);
Color p1 = image.GetPixel(x+1,y);
int idx0 = GetIndex(ref pal.colors, p0);
int idx1 = GetIndex(ref pal.colors, p1);
byte pb = (byte)((idx0<<4) | (idx1));
pixels.Add( pb );
}
}
spPixels pic = new spPixels(image.Width, image.Height, pixels);
pics.Add(pic);
}
}
String outPath = Path.ChangeExtension(args[0], ".gs");
Console.WriteLine("Saving {0}", outPath);
using (BinaryWriter b = new BinaryWriter(
File.Open(outPath, FileMode.Create)))
{
spPixels pix = pics[ 0 ];
for (int y = 0; y < pix.m_height; y+=8)
{
for (int x = 0; x<pix.m_width; x+=8)
{
int offset = y * (pix.m_width>>1) + (x >> 1);
for (int idy = 0; idy < 8; ++idy)
{
int boffset = offset + (idy * (pix.m_width>>1));
for (int idx = 0; idx < 4; ++idx)
{
b.Write((byte)pix.m_pixels[ boffset + idx ]);
}
}
}
}
}
}
//
// Get a IIgs color
//
static UInt16 ToGSColor( Color pixel )
{
int red = pixel.R;
int green = pixel.G;
int blue = pixel.B;
// we want to round up if it's needed
red+=8;
green+=8;
blue+=8;
if (red > 255) red = 255;
if (green > 255) green = 255;
if (blue > 255) blue = 255;
red >>= 4;
green >>= 4;
blue >>= 4;
int color = (red << 8) |
(green << 4) |
(blue);
return (UInt16)color;
}
//
// Get the Closest Matching Palette Index
//
static int GetIndex(ref List<Color> pal, Color pixel)
{
byte result_index = 0;
if (pal.Count > 0)
{
List<float> dist = new List<float>();
for (int idx = 0; idx < pal.Count; ++idx)
{
float delta = ColorDelta(pal[idx], pixel);
dist.Add(delta);
// Make sure the result_index is the one
// with the least amount of error
if (dist[idx] < dist[result_index])
{
result_index = (byte)idx;
}
}
}
return result_index;
}
static float ColorDelta(Color c0, Color c1)
{
// Y=0.2126R+0.7152G+0.0722B
float r = (c0.R-c1.R);
r = r * r;
r *= 0.2126f;
float g = (c0.G-c1.G);
g = g * g;
g *= 0.7152f;
float b = (c0.B-c1.B);
b = b * b;
b *= 0.0722f;
return r + g + b;
}
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1 @@
dotnet run null_terminator.png

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,17 @@
//
// fun2gs linker file
//
; Stack, and Direct page space
; in Bank0
section DirectPage_Stack,BSS
ds.b 1024
incobj "start.x65"
incobj "dbgfnt.x65"
incobj "lz4.x65"
incobj "blit.x65"
incobj "background.x65"
; Get these things in the same bank
;Merge start,dbgfont

View File

@ -0,0 +1,161 @@
* Tool Locator macros
* by Dave Klimas
;
; Copyright Apple Computer, Inc. 1986, 1987
; and Roger Wagner Publishing, Inc. 1988
; All Rights Reserved
;
macro _TLBootInit
{
Tool $101
}
macro _TLStartUp
{
Tool $201
}
macro _TLShutDown
{
Tool $301
}
;~TLVersion MAC
; PHA
macro _TLVersion
{
Tool $401
}
macro _TLReset
{
Tool $501
}
;~TLStatus MAC
; PHA
macro _TLStatus
{
Tool $601
}
;~GetTSPtr MAC
; PHS 2
; PxW ]1;]2
macro _GetTSPtr
{
Tool $901
}
;~SetTSPtr MAC
; PxW ]1;]2
; PHL ]3
macro _SetTSPtr
{
Tool $A01
}
;~GetFuncPtr MAC
; PHS 2
; PxW ]1;]2
macro _GetFuncPtr
{
Tool $B01
}
;~GetWAP MAC
; PHS 2
; PxW ]1;]2
macro _GetWAP
{
Tool $C01
}
;~SetWAP MAC
; PxW ]1;]2
; PHL ]3
macro _SetWAP
{
Tool $D01
}
;~LoadTools MAC
; PHL ]1
macro _LoadTools
{
Tool $E01
}
;~LoadOneTool MAC
; PxW ]1;]2
macro _LoadOneTool
{
Tool $F01
}
;~UnloadOneTool MAC
; PHW ]1
macro _UnloadOneTool
{
Tool $1001
}
;~TLMountVolume MAC
; PHA
; PxW ]1;]2
; PxL ]3;]4;]5;]6
macro _TLMountVolume
{
Tool $1101
}
;~TLTextMountVolume MAC
; PHA
; PxL ]1;]2;]3;]4
macro _TLTextMountVolume
{
Tool $1201
}
;~SaveTextState MAC
; PHS 2
macro _SaveTextState
{
Tool $1301
}
;~RestoreTextState MAC
; PHL ]1
macro _RestoreTextState
{
Tool $1401
}
;~MessageCenter MAC
; PxW ]1;]2
; PHL ]3
macro _MessageCenter
{
Tool $1501
}
macro _SetDefaultTPT
{
Tool $1601
}
;~MessageByName MAC
; PHS 2
; PHWL ]1;]2
; PxW ]3;]4
macro _MessageByName
{
Tool $1701
}
;~StartUpTools MAC
; PHA
; PxW ]1;]2
; PxL ]3;]4
macro _StartUpTools
{
Tool $1801
}
;~ShutDownTools MAC
; PHWL ]1;]2
macro _ShutDownTools
{
Tool $1901
}
macro _GetMsgHandle
{
Tool $1A01
}
macro _AcceptRequests
{
Tool $1B01
}
macro _SendRequest
{
Tool $1C01
}

View File

@ -0,0 +1,214 @@
* Memory Manager macros
* by Dave Klimas
;
; Copyright Apple Computer, Inc. 1986, 1987
; and Roger Wagner Publishing, Inc. 1988
; All Rights Reserved
;
macro _MMBootInit
{
Tool $102
}
;~MMStartUp MAC
; PHA
macro _MMStartUp
{
Tool $202
}
;~MMShutDown MAC
; PHW ]1
macro _MMShutDown
{
Tool $302
}
;~MMVersion MAC
; PHA
macro _MMVersion
{
Tool $402
}
macro _MMReset
{
Tool $502
}
;~MMStatus MAC
; PHA
macro _MMStatus
{
Tool $602
}
;~NewHandle MAC
; P2SL ]1
; PxW ]2;]3
; PHL ]4
macro _NewHandle
{
Tool $902
}
;~ReallocHandle MAC
; PHLW ]1;]2
; PHWL ]3;]4
; PHL ]5
macro _ReallocHandle
{
Tool $A02
}
;~RestoreHandle MAC
; PHL ]1
macro _RestoreHandle
{
Tool $B02
}
;~AddToOOMQueue MAC
; PHL ]1
macro _AddToOOMQueue
{
Tool $C02
}
;~DeleteFromOOMQueue MAC
; PHL ]1
macro _DeleteFromOOMQueue
{
Tool $D02
}
;~DisposeHandle MAC
; PHL ]1
macro _DisposeHandle
{
Tool $1002
}
;~DisposeAll MAC
; PHW ]1
macro _DisposeAll
{
Tool $1102
}
;~PurgeHandle MAC
; PHL ]1
macro _PurgeHandle
{
Tool $1202
}
;~PurgeAll MAC
; PHW ]1
macro _PurgeAll
{
Tool $1302
}
;~GetHandleSize MAC
; P2SL ]1
macro _GetHandleSize
{
Tool $1802
}
;~SetHandleSize MAC
; PxL ]1;]2
macro _SetHandleSize
{
Tool $1902
}
;~FindHandle MAC
; P2SL ]1
macro _FindHandle
{
Tool $1A02
}
;~FreeMem MAC
; PHS 2
macro _FreeMem
{
Tool $1B02
}
;~MaxBlock MAC
; PHS 2
macro _MaxBlock
{
Tool $1C02
}
;~TotalMem MAC
; PHS 2
macro _TotalMem
{
Tool $1D02
}
;~CheckHandle MAC
; PHL ]1
macro _CheckHandle
{
Tool $1E02
}
macro _CompactMem
{
Tool $1F02
}
;~HLock MAC
; PHL ]1
macro _HLock
{
Tool $2002
}
;~HLockAll MAC
; PHW ]1
macro _HLockAll
{
Tool $2102
}
;~HUnlock MAC
; PHL ]1
macro _HUnlock
{
Tool $2202
}
;~HUnlockAll MAC
; PHW ]1
macro _HUnlockAll
{
Tool $2302
}
;~SetPurge MAC
; PHWL ]1;]2
macro _SetPurge
{
Tool $2402
}
;~SetPurgeAll MAC
; PxW ]1;]2
macro _SetPurgeAll
{
Tool $2502
}
;~PtrToHand MAC
; PxL ]1;]2;]3
macro _PtrToHand
{
Tool $2802
}
;~HandToPtr MAC
; PxL ]1;]2;]3
macro _HandToPtr
{
Tool $2902
}
;~HandToHand MAC
; PxL ]1;]2;3
macro _HandToHand
{
Tool $2A02
}
;~BlockMove MAC
; PxL ]1;]2;]3
macro _BlockMove
{
Tool $2B02
}
;~RealFreeMem MAC
; PHS 2
macro _RealFreeMem
{
Tool $2F02
}
macro _SetHandleID
{
Tool $3002
}

View File

@ -0,0 +1,338 @@
* Misc Tool macros
* by Dave Klimas
;
; Copyright Apple Computer, Inc. 1986, 1987
; and Roger Wagner Publishing, Inc. 1988
; All Rights Reserved
;
macro _MTBootInit
{
Tool $103
}
macro _MTStartUp
{
Tool $203
}
macro _MTShutDown
{
Tool $303
}
;~MTVersion MAC
; PHA
macro _MTVersion
{
Tool $403
}
macro _MTReset
{
Tool $503
}
;~MTStatus MAC
; PHA
macro _MTStatus
{
Tool $603
}
;~WriteBRam MAC
; PHL ]1
macro _WriteBRam
{
Tool $903
}
;~ReadBRam MAC
; PHL ]1
macro _ReadBRam
{
Tool $A03
}
;~WriteBParam MAC
; PxW ]1;]2
macro _WriteBParam
{
Tool $B03
}
;~ReadBParam MAC
; P1SW ]1
macro _ReadBParam
{
Tool $C03
}
;~ReadTimeHex MAC
; PHS 4
macro _ReadTimeHex
{
Tool $D03
}
;~WriteTimeHex MAC
; PxW ]1;]2;]3
macro _WriteTimeHex
{
Tool $E03
}
;~ReadAsciiTime MAC
; PHL ]1
macro _ReadAsciiTime
{
Tool $F03
}
;~SetVector MAC
; PHWL ]1;]2
macro _SetVector
{
Tool $1003
}
;~GetVector MAC
; P2SW ]1
macro _GetVector
{
Tool $1103
}
;~SetHeartBeat MAC
; PHL ]1
macro _SetHeartBeat
{
Tool $1203
}
;~DelHeartBeat MAC
; PHL ]1
macro _DelHeartBeat
{
Tool $1303
}
macro _ClrHeartBeat
{
Tool $1403
}
;~SysFailMgr MAC
; PHWL ]1;]2
macro _SysFailMgr
{
Tool $1503
}
;~GetAddr MAC
; P2SW ]1
macro _GetAddr
{
Tool $1603
}
;~ReadMouse MAC
; PHS 3
macro _ReadMouse
{
Tool $1703
}
;~InitMouse MAC
; PHW ]1
macro _InitMouse
{
Tool $1803
}
;~SetMouse MAC
; PHW ]1
macro _SetMouse
{
Tool $1903
}
macro _HomeMouse
{
Tool $1A03
}
macro _ClearMouse
{
Tool $1B03
}
;~ClampMouse MAC
; PxW ]1;]2;]3;]4
macro _ClampMouse
{
Tool $1C03
}
;~GetMouseClamp MAC
; PHS 4
macro _GetMouseClamp
{
Tool $1D03
}
;~PosMouse MAC
; PxW ]1;]2
macro _PosMouse
{
Tool $1E03
}
;~ServeMouse MAC
; PHA
macro _ServeMouse
{
Tool $1F03
}
;~GetNewID MAC
; P1SW ]1
macro _GetNewID
{
Tool $2003
}
;~DeleteID MAC
; PHW ]1
macro _DeleteID
{
Tool $2103
}
;~StatusID MAC
; PHW ]1
macro _StatusID
{
Tool $2203
}
;~IntSource MAC
; PHW ]1
macro _IntSource
{
Tool $2303
}
;~FWEntry MAC
; PHS 4
; PxW ]1;]2;]3;]4
macro _FWEntry
{
Tool $2403
}
;~GetTick MAC
; PHS 2
macro _GetTick
{
Tool $2503
}
;~PackBytes MAC
; P1SL ]1
; PxL ]2;]3
; PHW ]4
macro _PackBytes
{
Tool $2603
}
;~UnPackBytes MAC
; P1SL ]1
; PHW ]2
; PxL ]3;]4
macro _UnPackBytes
{
Tool $2703
}
;~Munger MAC
; P1SL ]1
; PxL ]2;]3
; PHWL ]4;]5
; PHWL ]6;]7
macro _Munger
{
Tool $2803
}
;~GetIRQEnable MAC
; PHA
macro _GetIRQEnable
{
Tool $2903
}
;~SetAbsClamp MAC
; PxW ]1;]2;]3;]4
macro _SetAbsClamp
{
Tool $2A03
}
;~GetAbsClamp MAC
; PHS 4
macro _GetAbsClamp
{
Tool $2B03
}
macro _SysBeep
{
Tool $2C03
}
;~AddToQueue MAC
; PxL ]1;]2
macro _AddToQueue
{
Tool $2E03
}
;~DeleteFromQueue MAC
; PxL ]1;]2
macro _DeleteFromQueue
{
Tool $2F03
}
;~SetInterruptState MAC
; PHLW ]1;]2
macro _SetInterruptState
{
Tool $3003
}
;~GetInterruptState MAC
; PHLW ]1;]2
macro _GetInterruptState
{
Tool $3103
}
;~GetIntStateRecSize MAC
; PHA
macro _GetIntStateRecSize
{
Tool $3203
}
;~ReadMouse2 MAC
; PHS 3
macro _ReadMouse2
{
Tool $3303
}
;~GetCodeResConverter MAC
; PHS 2
macro _GetCodeResConverter
{
Tool $3403
}
macro _GetROMResource
{
Tool $3503
}
macro _ReleaseROMResource
{
Tool $3603
}
macro _ConvSeconds
{
Tool $3703
}
macro _SysBeep2
{
Tool $3803
}
macro _VersionString
{
Tool $3903
}
macro _WaitUntil
{
Tool $3A03
}
macro _StringToText
{
Tool $3B03
}
macro _ShowBootInfo
{
Tool $3C03
}
macro _ScanDevices
{
Tool $3D03
}
macro _AlertMessage
{
Tool $3E03
}
macro _DoSysPrefs
{
Tool $3F03
}

View File

@ -0,0 +1,788 @@
*=================================================
* Utility Macros - from Merlin disk
* by Dave Klimas, et al
*
* Copyright Apple Computer, Inc. 1986, 1987
* and Roger Wagner Publishing, Inc. 1988
* All Rights Reserved
*-------------------------------------------------
if 0
;PHWL MAC
; PHW ]1
; PHL ]2
; <<<
;PHLW MAC
; PHL ]1
; PHW ]2
; <<<
;PxW MAC
; DO ]0/1
; PHW ]1
; DO ]0/2
; PHW ]2
; DO ]0/3
; PHW ]3
; DO ]0/4
; PHW ]4
; FIN
; FIN
; FIN
; FIN
; <<<
;PxL MAC
; DO ]0/1
; PHL ]1
; DO ]0/2
; PHL ]2
; DO ]0/3
; PHL ]3
; DO ]0/4
; PHL ]4
; FIN
; FIN
; FIN
; FIN
; <<<
;P2SL MAC
; PHA
;P1SL MAC
; PHA
;PHL MAC
; IF #=]1
; PEA ^]1
; ELSE
; PHW ]1+2
; FIN
; PHW ]1
; <<<
;P2SW MAC
; PHA
;P1SW MAC
; PHA
;PHW MAC
; IF #=]1
; PEA ]1
; ELSE
; IF MX/2
; LDA ]1+1
; PHA
; FIN
; LDA ]1
; PHA
; FIN
; <<<
;PushSpace MAC
;PHS MAC
; DO ]0
; LUP ]1
; PHA
; --^
; ELSE
; PHA
; FIN
; <<<
;
;********************************
;
;Push4 MAC
; PushLong #0
; PushLong #0
; <<<
;
;PushPtr MAC
; PEA ^]1
; PEA ]1
; EOM
endif
macro PushLong value
{
pea $value>>16
pea $value
}
macro PushWord value
{
lda value
pha
}
if 0
;PullLong MAC
; DO ]0
; PullWord ]1
; PullWord ]1+2
; ELSE
; PullWord
; PullWord
; FIN
; <<<
;
;PullWord MAC
; PLA
; DO ]0
; STA ]1
; FIN
; IF MX/2
; PLA
; DO ]0
; STA ]1+1
; FIN
; FIN
; <<<
;
;MoveLong MAC
; MoveWord ]1;]2
; MoveWord ]1+2;]2+2
; <<<
;
;MoveWord MAC
; LDA ]1
; STA ]2
; IF MX/2
; LDA ]1+1
; STA ]2+1
; FIN
; <<<
;
;MoveBlock MAC ;1st_byte;last_byte;dest
; DO ]2/]1
; DO ]3/]1
; LDX #]2
; LDY #]3+]2-]1
; LDA #]2-]1
; MVP ]1,]3
; ELSE
; LDX #]1
; LDY #]3
; LDA #]2-]1
; MVN ]1,]3
; FIN
; ELSE
; ERR 1 ;Last adrs < first adrs
; FIN
; <<<
;
;CmpLong MAC
; LDA ]1
; CMP ]2
; IF #=]1
; LDA ^]1
; ELSE
; LDA ]1+2
; FIN
; IF #=]2
; SBC ^]2
; ELSE
; SBC ]2+2
; FIN
; <<<
;
;LONGM MAC
;LONGACC MAC ;Assumes native mode
; IF MX&2 ;If A is now short
; REP %00100000
; FIN
; <<<
;
;LONGX MAC
;LONGXY MAC ;Assumes native mode
; IF MX&1 ;If X is now short
; REP %00010000
; FIN
; <<<
;
;LONG MAC
;LONGAX MAC ;Assumes native mode
; IF MX ;If not now in full 16
; REP %00110000
; FIN
; <<<
;
;SHORTM MAC
;SHORTACC MAC ;Assumes native mode
; IF MX&2 ;If A is now short,
; ELSE ; ignore
; SEP %00100000
; FIN
; <<<
;
;SHORTX MAC
;SHORTXY MAC ;Assumes native mode
; IF MX&1 ;If X is now short,
; ELSE ; ignore
; SEP %00010000
; FIN
; <<<
;
;SHORT MAC
;SHORTAX MAC ;Assumes native mode
; IF MX!%11 ;If not now in full 8
; SEP %00110000
; FIN
; <<<
;
;LONGI MAC ; Duplicates APW function
; LST OFF
; DO ]1 ; If arg = 1 = "on" = make long
;
; IF MX-3/-1 ; If M is short and X is long
;; Leave alone
; FIN ; End of this test
;
; IF MX/3 ; If M is short and X is short
; MX %10 ; Make X long, leave M short
; FIN ; End of this test
;
; IF MX!3/3 ; If M is long and X is long
; FIN ; Leave alone
;
; IF MX-2/-1 ; If M is long and X is short
; MX %00 ; Make X long, leave M long
; FIN ; End of this test
;
; ELSE ; If arg = 0 = "off" = make short
;
; IF MX/3 ; If M is short and X is short
; ; Leave alone
; FIN ; End of this test
;
; IF MX-3/-1 ; If M is short and X is long
; MX %11 ; Make X short, leave M short
; FIN ; End of this test
;
; IF MX-2/-1 ; If M is long and X is short
; ; Leave alone
; FIN ; End of this test
;
;
; IF MX!3/3 ; If M is long and X is long
; MX %01 ; Make X short, leave M long
; FIN ; Leave alone
;
; FIN ; End of macro tests
;
; LST RTN
; <<<
;
;LONGA MAC ; Duplicates APW function
; LST OFF
; DO ]1 ; If arg = 1 = "on" = make long
;
; IF MX-3/-1 ; If M is short and X is long
; MX %00 ; Make M long, leave X long
; FIN ; End of this test
;
; IF MX/3 ; If M is short and X is short
; MX %01 ; Make M long, leave X short
; FIN ; End of this test
;
; IF MX!3/3 ; If M is long and X is long
; FIN ; Leave alone
;
; IF MX-2/-1 ; If M is long and X is short
; ; Leave alone
; FIN ; End of this test
;
; ELSE ; If arg = 0 = "off" = make short
;
; IF MX/3 ; If M is short and X is short
; ; Leave alone
; FIN ; End of this test
;
; IF MX-3/-1 ; If M is short and X is long
; ; Leave alone
; FIN ; End of this test
;
; IF MX-2/-1 ; If M is long and X is short
; MX %11 ; Make M short, leave X short
; FIN ; End of this test
;
;
; IF MX!3/3 ; If M is long and X is long
; MX %10 ; Make M short, leave X long
; FIN ; Leave alone
;
; FIN ; End of macro tests
;
; LST RTN
; <<<
;
;M65816 MAC
; DO ]1
; XC
; XC ; Full 65816 mode for assembler
; MX %00
; ELSE
; MX %11 ; 8 bit mode for assembler
; FIN
; <<<
;
;Expmac MAC ; Replace APW GEN function
; DO ]1
; EXP ONLY ; Expand macros
; ELSE
; EXP OFF
; FIN
; <<<
endif
macro Tool _toolNum
{
LDX #_toolNum ; load tool call #
JSL $E10000 ; go to dispatcher
}
if 0
;**************************************************
;* Auto-menu item macros *
;* This is one alternative for defining a menu *
;* item. It has the advantage of letting you *
;* include specifiers for Bold, Italic, etc. *
;**************************************************
;
;*-------------------------------------------------
;* Syntax:
;* ]mnum = 0 ; initialize menu # at startvalue-1
;* Menu ' Menu 1 '
;*
;* (See Menu macro, defined later....)
;*
;* ]inum = 255 ; Menu item starts with #256
;* Item ' Choice 1 ';Kybd;'Bb';Check
;* Ch1 = ]inum ; Set label Ch1 if somewhere else
;* needs to use this item #.
;* Item ' Choice 2 ';Disable;'';Kybd;'Cc'
;* Item ' Choice 3 ';Divide;''
;*
;* Menu ' Menu 2 '
;*
;* Item ' Choice 4 ';Bold;'';Check
;* Item ' Choice 5 ';Italic;'';Blank
;* Item ' Choice 6 ';Underline';Kybd;'Dd'
;*
;* IMPORTANT: ALL items, except for Check and Blank, are followed by a second
;* value. For the Kybd item, the ASCII characters follow in single quotes, Ex:
;* Kybd;'Cc' (specifies Apple-C as an equivalent).
;* All other items use a null 2nd value, as in:
;* Italic;'' or Divide;'' etc.
;*
;* The variable ]inum MUST be initialized for the value of your first
;* menu item MINUS 1 before using the first Item macro.
;*
;* Check or Blank, if used, MUST be the last item in the macro line.
;*
;* There can be up to three parameter pairs after the item name.
;*-------------------------------------------------
;* The point of all this is that rather than hard-
;* code menu items values and subsequent references
;* to that number when disabling menus, etc., this
;* lets you add and delete menu items at will,
;* and have labels like Ch1, etc. above, auto-
;* matically set for the correct value during the
;* assembly.
;*-------------------------------------------------
;
;* Equates for Item macro:
;
;Bold = 'B' ; bold menu item
;Disable = 'D' ; disabled menu item
;Italic = 'I' ; italic menu item
;Underline = 'U' ; underlined menu item
;Divide = 'V' ; menu dividing line
;ColorHi = 'X' ; color hilite menu item
;Kybd = '*' ; keyboard menu equivalent
;Check = $1243 ; menu item with checkmark
;Blank = $2043 ; menu item with blank
;
;*-------------------------------------------------
;
;Item MAC ; Macro for creating a menu item
;
; ASC '--'
; ASC ]1 ; Text of menu item
; ASC '\H'
; DA ]inum ; Menu item #
;
; DO ]0/2 ; Only if more items to do... (>2)
;
; DO ]2-Check-1/-1 ; Only if Check item
; DA ]2 ; ]2 = Check
; ELSE ; otherwise kybd char or null
; DO ]2-Blank-1/-1 ; Only if Blank check item
; DA ]2 ; ]2 = Blank
; ELSE
; DB ]2 ; Function char value
; ASC ]3 ; ASCII argument, if any for Kybd
; FIN
; FIN
;
; FIN
;
; DO ]0/4 ; Only if more items to do... (>3)
;
; DO ]4-Check-1/-1 ; Only if Check item
; DA ]4 ; ]4 = Check
; ELSE ; otherwise kybd char or null
; DO ]4-Blank-1/-1 ; Only if Blank check item
; DA ]4 ; ]4 = Blank
; ELSE
; DB ]4 ; Function char value
; ASC ]5 ; ASCII argument, if any for Kybd
; FIN
; FIN
;
; FIN
;
; DO ]0/6 ; Only if more items to do... (>5)
;
; DO ]6-Check-1/-1 ; Only if Check item
; DA ]6 ; ]6 = Check
; ELSE ; otherwise kybd char or null
; DO ]6-Blank-1/-1 ; Only if Blank check item
; DA ]6 ; ]6 = Blank
; ELSE
; DB ]6 ; Function char value
; ASC ]7 ; ASCII argument, if any for Kybd
; FIN
; FIN
;
; FIN
;
; DB $00 ; End of menu item
;
;]inum = ]inum+1
; <<<
;
;**************************************************
;* This is another alternative macro for both *
;* menus and menu items. It is simpler, and *
;* more compact, but not as versatile. *
;**************************************************
;
;*===============================================
;* Variables ]mnum,]inum should be defined
;* prior to using these MenuMaker macros.
;*
;* They both should be starting value-1
;*
;* Syntax:
;*
;* ]mnum = 0 ; 1st menu number will be 1
;* ]inum = 255 ; 1st menu item number will be 256
;*
;* Menu ' @';X ; Apple menu, color highlighting.
;*
;* MItem ' About... ' ; "About" menu item
;*
;* Menu ' Menu Title 1' ; (this will be menu number 2)
;*
;* MItem ' Choice 1 '
;* MItem ' Choice 2 ';'D*Cc' ; Disabled, kybd char: Cc
;* ; Above will be menu item #'s 2&3
;*
;*
;
;
;Menu MAC
; ASC '>>'
; ASC ]1
; ASC '\H'
; DA ]mnum
; DO ]0>1
; ASC ]2
; FIN
; DB 0
;]mnum = ]mnum+1
; <<<
;
;MItem MAC
; ASC '--'
; ASC ]1
; ASC '\H'
; DA ]inum
; DO ]0>1
; ASC ]2
; FIN
; DB 0
;]inum = ]inum+1
; <<<
;
;*-----------------------------------------------------
;*
;* Native -- Processor is in LONG "native" mode.
;* Native Long -- Processor is in LONG "native" mode.
;* Native Short -- Processor is in SHORT "native" mode.
;*
;
;Native MAC
; CLC
; XCE
; IF 0=]0 ;If Native (Long)
; LONGAX
; FIN
;
; DO ]0
; IF L=]1 ;If Native Long
; LONGAX
;
; FIN ;If Native Short only
; FIN ; do CLC, XCE.
; EOM
;
;*--------------------------------------------------------
;*
;* Emulation -- Set Processor into "emulation" mode.
;*
;
;Emulation MAC
; SEC
; XCE
; EOM
;
;*-----------------------------------------------------
;*
;* WriteCh -- Print Character From Accumulator
;* WriteCh ADDR -- Print Character At Label
;* WriteCh ADDR,X -- Print Character At Label,X
;*
;
;WriteCh MAC
; DO ]0
; LDA ]1
; FIN
; PHA
; LDX #$180C
; JSL $E10000
; EOM
;
;*-----------------------------------------------------
;*
;* ReadCh -- Get Keypress in Accumulator
;* ReadCh ADDR -- Get Keypress in Label
;*
;
;ReadCh MAC
; PEA 0
; PEA 1
; LDX #$220C
; JSL $E10000
; PLA
; DO ]0
; STA ]1
; FIN
; EOM
;
;*-----------------------------------------------------
;*
;* WriteLn "STRING" -- Print Literal String with CR.
;* WriteLn ADDR -- Print String At Address with CR.
;* WriteLn -- Print CR.
;*
;
;WriteLn MAC
; DO ]0
; WriteStr ]1
; FIN
; WriteCh #$8D
; EOM
;
;*-----------------------------------------------------
;*
;* WriteStr "STRING" -- Print Literal String.
;* WriteStr ADDR -- Print String At Address.
;* WriteStr -- Print String At A (Lo),Y (Hi).
;*
;
;WriteStr MAC
; IF 0=]0 ;If No Label
; PHY
; PHA
;
; ELSE
;
; IF "=]1
; PEA ^]String
; PEA ]String
; BRL ]Skip
;]String STR ]1
;]Skip
; ELSE
;
; IF '=]1
; PEA ^]String
; PEA ]String
; BRL ]Skip
;]String STR ]1
;]Skip
; ELSE
;
; PEA ^]1
; PEA ]1
;
; FIN
; FIN
; FIN
; LDX #$1C0C
; JSL $E10000
; EOM
;
;*-----------------------------------------------------
;*
;* DrawStrHV 8;12;"STRING" Print Literal String on
;* DrawStr 8;12;ADDR Super Hi-Res Screen.
;*
;
;DrawStrHV MAC
; HtabVtab ]1;]2
; DrawStr ]3
; <<<
;
;*-----------------------------------------------------
;*
;* DrawStr "STRING" -- Print Literal String.
;* DrawStr ADDR -- Print String At Address.
;*
;
;DrawStr MAC
; IF "=]1
; PEA ^]String
; PEA ]String
; BRL ]Skip
;]String STR ]1
;]Skip
; ELSE
; IF '=]1
; PEA ^]String
; PEA ]String
; BRL ]Skip
;]String STR ]1
;]Skip
; ELSE
; PEA ^]1
; PEA ]1
; FIN
; FIN
; LDX #$A504 ;DrawString
; JSL $E10000
; <<<
;
;*-----------------------------------------------------
;*
;* HtabVtab #8;#12 -- Position at Htab 8, Vtab 12.
;* HtabVtab H;V on super hires screens.
;*
;
;HtabVtab MAC
; IF #=]1
; LDA ]1*8
; ELSE
; LDA ]1
; ASL
; ASL
; ASL
; FIN
; PHA
; IF #=]1
; LDA ]2*8
; ELSE
; LDA ]2
; ASL
; ASL
; ASL
; FIN
; PHA
; LDX #$3A04 ;MoveTo
; JSL $E10000
; <<<
;
;*-----------------------------------------------------
;*
;* Deref MyHandle;MyPtr -- Uses zero page 0-3 to
;* de-reference a handle.
;*
;
;Deref MAC
; LDA ]1
; LDX ]1+2
; STA 0
; STX 2
; LDA [0]
; STA ]2
; LDY #2
; LDA [0],Y
; STA ]2+2
; <<<
;
;*==================================================
;* The MLI16 macro assumes the CALLDOS file from the
;* SUBROUT.LIB is linked in. It provides an easy
;* way to make MLI calls. Example syntax:
;*
;* MLI16 close;CLSPARMS
;*--------------------------------------------------
;
;MLI16 MAC ;Uses CALLDOS file in the
; IF MX ; subroutine library
; REP %00110000 ;Force full 16-bit mode, if
; FIN ; not already there.
; LDX #]1 ;Call code (use MLI.CODES)
; LDA #]2 ;Low word of PARMS tbl adr
; JSR CALLDOS ;Returns CS if an error
; <<<
;
;*=================================================
;* The following macros are APW-equivalents for
;* compatibility with APW style listings.
;*
;* One difference between Merlin and APW here: Instead of
;* using the syntax PULL1 ADDRESS;X, Merlin can take
;* the raw statement PULL1 ADDRESS,X.
;*
;
;PULL1 MAC
; SEP #%00100000
; PLA
; REP #%00100000
; DO ]0/1 ;If 1 parm
; IF MX>0
; STA ]1
; FIN
; IF MX=0
; STAL ]1
; FIN
; FIN
; <<<
;
;PULL3 MAC
; SEP #%00100000
; PLA
; STA ]1
; REP #%00100000
; PLA
; STA ]1+1
; FIN
; <<<
;
;PUSH1 MAC
; SEP #%00100000
; IF ]0/1 ;if one parm
; LDA ]1
; FIN
; PHA
; REP #%00100000
; <<<
;
;PUSH3 MAC
; IF #=]1
; LDA #^]1 ;get two hi order bytes
; PHA
; PHB
; LDA #<]1
; STA 1,S
; ELSE
; LDA ]1+1
; PHA
; PHB
; LDA ]1
; STA 1,S
; FIN
; <<<
endif

View File

@ -0,0 +1,48 @@
;
; common.i
;
; merlin mx macro
macro mx mx
{
if (0 == (mx&%10))
A16
else
A8
endif
if (0 == (mx&%01))
I16
else
I8
endif
}
macro _shadowON
{
lda >$00C035
and #$FFF7
sta >$00C035
}
macro _shadowOFF
{
lda >$00C035
ora #$0008
sta >$00C035
}
macro _auxON
{
lda >$00C068
ora #$0030
sta >$00C068
}
macro _auxOFF
{
lda >$00C068
and #$FFCF
sta >$00C068
}

View File

@ -0,0 +1,11 @@
*
* Common Direct Page Equates
*
struct dp {
word source
word sourceHi
word dest
word destHi
}

View File

@ -504,7 +504,7 @@ enum AddrMode {
AM8_JML = AMM_REL_L | AMM_ABS_L,
AM8_BRL = AMM_BRANCH_L | AMM_ABS,
AM8_MVN = AMM_BLK_MOV,
AM8_PEI = AMM_ZP_REL,
AM8_PEI = AMM_ZP_REL | AMM_ZP,
AM8_PER = AMM_BRANCH_L | AMM_ABS,
AM8_REP = AMM_IMM | AMM_ZP, // Merlin allows this to look like a zp access
};
@ -808,7 +808,7 @@ struct mnem opcodes_65816[] = {
{ "mvp", AM8_MVN, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44 } },
{ "mvn", AM8_MVN, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54 } },
{ "pea", AMM_ABS, { 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ "pei", AMM_ZP, { 0x00, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ "pei", AM8_PEI, { 0x00, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ "per", AM8_PER, { 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ "rep", AM8_REP, { 0x00, 0xc2, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ "sep", AM8_REP, { 0x00, 0xe2, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
@ -7757,7 +7757,7 @@ StatusCode Asm::WriteA2GS_OMF(strref filename, bool full_collapse) {
// insert all SUPER_RELOC2 / SUPER_RELOC3
for (int b = 0; b <= 1; b++) {
int count_offs = -1;
int prev_page = 0;
int prev_page = -1;
int inst_curr = instruction_offs;
instructions[inst_curr++] = OMFR_SUPER;
int len_offs = inst_curr;