More bug fixes.
This commit is contained in:
parent
322943af7d
commit
f6f5d4163c
7 changed files with 284 additions and 4 deletions
|
@ -27,8 +27,11 @@ fi
|
|||
cp -Rf llvm-mos-sdk-patches/* llvm-mos-sdk-source/.
|
||||
|
||||
pushd llvm-mos-sdk-source
|
||||
mkdir -p build
|
||||
pushd build
|
||||
if [[ -d .builddir ]]; then
|
||||
rm -rf .builddir
|
||||
fi
|
||||
mkdir -p .builddir
|
||||
pushd .builddir
|
||||
cmake \
|
||||
-G Ninja \
|
||||
-DCMAKE_INSTALL_PREFIX=${INSTALL} \
|
||||
|
|
|
@ -9,11 +9,12 @@ START=0x2000
|
|||
|
||||
echo "__f256_start = ${START};" > ${SETTINGS}
|
||||
mos-f256k-clang \
|
||||
-I../f256 \
|
||||
-I${F256}/include \
|
||||
-I${F256}/f256lib \
|
||||
-o pgztest \
|
||||
-Os \
|
||||
pgztest.c \
|
||||
../f256/f256.c
|
||||
${F256}/f256lib/f256.c
|
||||
mv -f pgztest pgztest.bin
|
||||
|
||||
${F256}/header/header \
|
||||
|
|
95
f256lib/f256.c
Normal file
95
f256lib/f256.c
Normal file
|
@ -0,0 +1,95 @@
|
|||
#include "f256.h"
|
||||
|
||||
|
||||
char error;
|
||||
|
||||
|
||||
#define MAX_COL 80
|
||||
#define MAX_ROW 60
|
||||
|
||||
|
||||
static char row = 0;
|
||||
static char col = 0;
|
||||
static char *line = (char *)TEXT_MATRIX;
|
||||
|
||||
|
||||
void cls(void) {
|
||||
int i;
|
||||
char *vram = (char *)TEXT_MATRIX;
|
||||
unsigned char mmu;
|
||||
|
||||
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
|
||||
POKE(MMU_IO_CTRL, 2); // Swap I/O page 2 into bank 6.
|
||||
|
||||
for (i = 0; i < 80*60; i++) {
|
||||
*vram++ = 32;
|
||||
}
|
||||
|
||||
row = col = 0;
|
||||
line = (char *)TEXT_MATRIX;
|
||||
|
||||
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
|
||||
|
||||
POKE(CURSOR_SETTINGS, 9); // Disable cursor flash.
|
||||
POKE(CURSOR_CHARACTER, '_'); // Set cursor shape.
|
||||
|
||||
POKE(CURSOR_X_LOW, col); // Set cursor X position.
|
||||
POKE(CURSOR_X_HIGH, 0);
|
||||
|
||||
POKE(CURSOR_Y_LOW, row); // Set cursor Y position.
|
||||
POKE(CURSOR_Y_HIGH, 0);
|
||||
|
||||
POKE(0xd011, 0);
|
||||
}
|
||||
|
||||
|
||||
static void scroll() {
|
||||
int i;
|
||||
char *vram = (char *)TEXT_MATRIX;
|
||||
|
||||
for (i = 0; i < 80*59; i++) {
|
||||
vram[i] = vram[i+80];
|
||||
}
|
||||
vram += i;
|
||||
for (i = 0; i < 80; i++) {
|
||||
*vram++ = 32;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void print(char *message) {
|
||||
int x = 0;
|
||||
unsigned char mmu;
|
||||
|
||||
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
|
||||
POKE(MMU_IO_CTRL, 2); // Swap I/O page 2 into bank 6.
|
||||
|
||||
while (message[x] != 0) {
|
||||
switch (message[x]) {
|
||||
default:
|
||||
line[col] = message[x];
|
||||
col++;
|
||||
if (col != MAX_COL) {
|
||||
break;
|
||||
}
|
||||
// Fall through.
|
||||
case 10:
|
||||
case 13:
|
||||
col = 0;
|
||||
row++;
|
||||
if (row == MAX_ROW) {
|
||||
scroll();
|
||||
row--;
|
||||
break;
|
||||
}
|
||||
line += 80;
|
||||
break;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
|
||||
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
|
||||
|
||||
POKE(CURSOR_X_LOW, col);
|
||||
POKE(CURSOR_Y_LOW, row);
|
||||
}
|
79
f256lib/f256.h
Normal file
79
f256lib/f256.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
#ifndef F256_H
|
||||
#define F256_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "stddclmr.h"
|
||||
|
||||
#include "api.h"
|
||||
#include "f256_dma.h"
|
||||
#include "f256_intmath.h"
|
||||
#include "f256_irq.h"
|
||||
#include "f256jr.h"
|
||||
#include "f256_rtc.h"
|
||||
#include "f256_sprites.h"
|
||||
#include "f256_tiles.h"
|
||||
#include "f256_timers.h"
|
||||
#include "f256_via.h"
|
||||
#include "f256_xymath.h"
|
||||
|
||||
/*
|
||||
#define MMU_MEM_CTRL 0x0000
|
||||
#define MMU_IO_CTRL 0x0001
|
||||
|
||||
#define VICKY_MASTER_0 0xd000
|
||||
#define VICKY_MASTER_1 0xd001
|
||||
#define VICKY_GR_CLUT_0 0xd000 // I/O Page 1
|
||||
#define VICKY_GR_CLUT_1 0xd400 // I/O Page 1
|
||||
#define VICKY_GR_CLUT_2 0xd800 // I/O Page 1
|
||||
#define VICKY_GR_CLUT_3 0xdc00 // I/O Page 1
|
||||
*/
|
||||
|
||||
#define TEXT_MATRIX 0xc000 // I/O Page 2
|
||||
#define TEXT_COLOR_MATRIX 0xc000 // I/O Page 3
|
||||
#define TEXT_LUT_FOREGROUND 0xd800 // I/O Page 0
|
||||
#define TEXT_LUT_BACKGROUND 0xd840 // I/O Page 0
|
||||
#define TEXT_FONT_0 0xc000 // I/O Page 1
|
||||
#define TEXT_FONT_1 0xc800 // I/O Page 1
|
||||
|
||||
#define CURSOR_SETTINGS 0xd010
|
||||
#define CURSOR_CHARACTER 0xd012
|
||||
#define CURSOR_X_LOW 0xd014
|
||||
#define CURSOR_X_HIGH 0xd015
|
||||
#define CURSOR_Y_LOW 0xd016
|
||||
#define CURSOR_Y_HIGH 0xd017
|
||||
|
||||
#define PEEK(addy) ((unsigned char)*(volatile unsigned char *)(addy))
|
||||
#define POKE(addy, value) (*(volatile unsigned char *)(addy) = (value))
|
||||
#define VECTOR(member) (size_t)(&((struct call *)0xff00)->member)
|
||||
#define EVENT(member) (size_t)(&((struct events *)0)->member)
|
||||
#define CALL(fn) \
|
||||
asm("jsr %[addy] \n" \
|
||||
"stz %[err] \n" \
|
||||
"ror %[err]" \
|
||||
: [err] "+m"(error) \
|
||||
: [addy] "i"(VECTOR(fn)) \
|
||||
: "a", "x", "y", "c", "v");
|
||||
|
||||
|
||||
|
||||
extern struct event_t event; // The event struct is allocated in crt0.
|
||||
extern char error;
|
||||
|
||||
|
||||
void cls(void);
|
||||
void print(char *message);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // F256_H
|
95
f256lib/stddclmr.h
Normal file
95
f256lib/stddclmr.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
#ifndef STDDCLMR_H
|
||||
#define STDDCLMR_H
|
||||
|
||||
/*
|
||||
Action figures sold separately. Add toner. All models over 18 years of age.
|
||||
All rights reserved. Allow four to six weeks for delivery. An equal
|
||||
opportunity employer. Any resemblance to actual persons, living or dead, is
|
||||
unintentional and purely coincidental. Apply only to affected area. Approved
|
||||
for veterans. As seen on TV. At participating locations only. Avoid contact
|
||||
with mucous membranes. Avoid contact with skin. Avoid extreme temperatures
|
||||
and store in a cool dry place. Batteries not included. Be sure each item is
|
||||
properly endorsed. Beware of dog. Booths for two or more. Breaking seal
|
||||
constitutes acceptance of agreement. Call toll free number before digging.
|
||||
Caveat emptor. Check here if tax deductible. Close cover before striking
|
||||
Colors may fade. Contains a substantial amount of non-tobacco ingredients.
|
||||
Contents may settle during shipment. Contestants have been briefed on some
|
||||
questions before the show. Copyright 1995 Joker's Wild. Disclaimer does
|
||||
not cover hurricane, lightning, tornado, tsunami, volcanic eruption,
|
||||
earthquake, flood, and other Acts of God, misuse, neglect, unauthorized
|
||||
repair, damage from improper installation, broken antenna or marred cabinet,
|
||||
incorrect line voltage, missing or altered serial numbers, sonic boom
|
||||
vibrations, electromagnetic radiation from nuclear blasts, customer
|
||||
adjustments that are not covered in the joke list, and incidents owing to
|
||||
airplane crash, ship sinking, motor vehicle accidents, leaky roof, broken
|
||||
glass, falling rocks, mud slides, forest fire, flying projectiles, or
|
||||
dropping the item. Do not bend, fold, mutilate, or spindle. Do not place
|
||||
near flammable or magnetic source. Do not puncture, incinerate, or store
|
||||
above 120 degrees Fahrenheit. Do not stamp. Use other side for additional
|
||||
listings. Do not use while operating a motor vehicle or heavy equipment. Do
|
||||
not write below this line. Documents are provided "as is" without any
|
||||
warranties expressed or implied. Don't quote me on anything. Don't quote me
|
||||
on that. Driver does not carry cash. Drop in any mailbox. Edited for
|
||||
television. Employees and their families are not eligible. Falling rock.
|
||||
First pull up, then pull down. Flames redirected to /dev/null. For a
|
||||
limited time only. For external use only. For off-road use only. For office
|
||||
use only. For recreational use only. Do not disturb. Freshest if eaten
|
||||
before date on carton. Hand wash only, tumble dry on low heat. If a rash,
|
||||
redness, irritation, or swelling develops, discontinue use. If condition
|
||||
persists, consult your physician. If defects are discovered, do not attempt
|
||||
to fix them yourself, but return to an authorized service center. If
|
||||
ingested, do not induce vomiting, if symptoms persist, consult a doctor.
|
||||
Keep away from open flames and avoid inhaling fumes. Keep away from
|
||||
sunlight, pets, and small children. Keep cool; process promptly. Limit
|
||||
one-per-family please. Limited time offer, call now to ensure prompt
|
||||
delivery. List at least two alternate dates. List each check separately by
|
||||
bank number. List was current at time of printing. Lost ticket pays maximum
|
||||
rate. May be too intense for some viewers. Must be 18 to enter. No Canadian
|
||||
coins. No alcohol, dogs or horses. No anchovies unless otherwise specified.
|
||||
No animals were harmed in the production of these documents. No money down.
|
||||
No other warranty expressed or implied. No passes accepted for this
|
||||
engagement. No postage necessary if mailed in the United States. No
|
||||
preservatives added. No purchase necessary. No salt, MSG, artificial color
|
||||
or flavor added. No shoes, no shirt, no service, no kidding. No solicitors.
|
||||
No substitutions allowed. No transfers issued until the bus comes to a
|
||||
complete stop. No user-serviceable parts inside. Not affiliated with the
|
||||
American Red Cross. Not liable for damages due to use or misuse. Not
|
||||
recommended for children. Not responsible for direct, indirect, incidental
|
||||
or consequential damages resulting from any defect, error or failure to
|
||||
perform. Not the Beatles. Objects in mirror may be closer than they appear.
|
||||
One size fits all. Many suitcases look alike. Other copyright laws for
|
||||
specific entries apply wherever noted. Other restrictions may apply. Package
|
||||
sold by weight, not volume. Parental advisory - explicit lyrics. Penalty for
|
||||
private use. Place stamp here. Please remain seated until the ride has come
|
||||
to a complete stop. Possible penalties for early withdrawal. Post office will
|
||||
not deliver without postage. Postage will be paid by addressee. Prerecorded
|
||||
for this time zone. Price does not include taxes. Processed at location
|
||||
stamped in code at top of carton. Quantities are limited while supplies last.
|
||||
Read at your own risk. Record additional transactions on back of previous
|
||||
stub. Replace with same type. Reproduction strictly prohibited. Restaurant
|
||||
package, not for resale. Return to sender, no forwarding order on file,
|
||||
unable to forward. Safety goggles may be required during use. Sanitized for
|
||||
your protection. Sealed for your protection, do not use if the safety seal is
|
||||
broken. See label for sequence. Shading within a garment may occur. Sign here
|
||||
without admitting guilt. Simulated picture. Slightly enlarged to show detail.
|
||||
Slightly higher west of the Rockies. Slippery when wet. Smoking these may be
|
||||
hazardous to your health. Some assembly required. Some equipment shown is
|
||||
optional. Some of the trademarks mentioned in this product appear for
|
||||
identification purposes only. Subject to FCC approval. Subject to change
|
||||
without notice. Substantial penalty for early withdrawal. Text may contain
|
||||
material some readers may find objectionable, parental guidance is advised.
|
||||
Text used in these documents is made from 100% recycled electrons and magnetic
|
||||
particles. These documents do not reflect the thoughts or opinions of either
|
||||
myself, my company, my friends, or my rabbit. This is not an offer to sell
|
||||
securities. This offer is void where prohibited, taxed, or otherwise
|
||||
restricted. This product is meant for educational purposes only. Times
|
||||
approximate. Unix is a registered trademark of AT&T. Use only as directed. Use
|
||||
only in a well-ventilated are. User assumes full liabilities. Void where
|
||||
prohibited. We have sent the forms which seem right for you. You must be
|
||||
present to win. You need not be present to win. Your canceled check is your
|
||||
receipt. Your mileage may vary. I didn't do it. You can't prove anything.
|
||||
|
||||
This supersedes all previous notices.
|
||||
*/
|
||||
|
||||
#endif // STDDCLMR_H
|
|
@ -4,6 +4,13 @@ if(NOT CMAKE_CROSSCOMPILING)
|
|||
return()
|
||||
endif()
|
||||
|
||||
file(READ clang.cfg CONFIG)
|
||||
|
||||
install(FILES
|
||||
link.ld
|
||||
settings.ld
|
||||
TYPE LIB)
|
||||
|
||||
add_platform_library(f256k-crt0)
|
||||
merge_libraries(f256k-crt0
|
||||
common-crt0
|
||||
|
|
Loading…
Add table
Reference in a new issue