mirror of
https://github.com/weiju/amiga-stuff
synced 2025-11-21 09:19:45 +00:00
initial version
This commit is contained in:
29
os13/Makefile
Normal file
29
os13/Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
#CC=vc +aos68k
|
||||
CC=vc +kick13
|
||||
CFLAGS=-c99 -I$(NDK_INC) -L$(NDK_LIB)
|
||||
|
||||
all: intuition1 graphics1 copper1 dualplayfield1 ham1 ostest openwin
|
||||
|
||||
clean:
|
||||
rm -f intuition1 graphics1 copper1 dualplayfield1 ham1 ostest openwin
|
||||
|
||||
ostest: ostest.c
|
||||
$(CC) ostest.c -o ostest
|
||||
|
||||
intuition1: intuition1.c
|
||||
$(CC) $(CFLAGS) intuition1.c -lamiga -o intuition1
|
||||
|
||||
openwin: openwin.c
|
||||
$(CC) $(CFLAGS) openwin.c -lamiga -o openwin
|
||||
|
||||
graphics1: graphics1.c
|
||||
$(CC) $(CFLAGS) graphics1.c -lamiga -o graphics1
|
||||
|
||||
copper1: copper1.c
|
||||
$(CC) $(CFLAGS) copper1.c -lamiga -o copper1
|
||||
|
||||
dualplayfield1: dualplayfield1.c
|
||||
$(CC) $(CFLAGS) dualplayfield1.c -lamiga -o dualplayfield1
|
||||
|
||||
ham1: ham1.c
|
||||
$(CC) $(CFLAGS) ham1.c -lamiga -o ham1
|
||||
5
os13/README.md
Normal file
5
os13/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# AmigaOS examples
|
||||
|
||||
## Description
|
||||
|
||||
These are some AmigaOS example programs that are targeted for OS 1.3
|
||||
80
os13/copper1.c
Normal file
80
os13/copper1.c
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* User-Copper-Lists Demo Program.
|
||||
* ROM Kernel Reference Manual, Libraries and Devices
|
||||
*/
|
||||
#include <exec/types.h>
|
||||
#include <exec/memory.h>
|
||||
#include <graphics/gfxmacros.h>
|
||||
#include <graphics/copper.h>
|
||||
#include <intuition/intuition.h>
|
||||
#include <hardware/custom.h>
|
||||
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/dos_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <clib/graphics_protos.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define WINDOWGADGETS (WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE)
|
||||
#define WWIDTH 120
|
||||
#define WHEIGHT 90
|
||||
|
||||
#ifndef MAXINT
|
||||
#define MAXINT 0xffffffff
|
||||
#endif
|
||||
|
||||
extern struct Window *OpenWindow();
|
||||
extern struct Screen *OpenScreen();
|
||||
|
||||
struct Library *IntuitionBase = 0;
|
||||
struct Library *GfxBase = 0;
|
||||
|
||||
struct TextAttr TestFont = {
|
||||
"topaz.font", 8, 0, 0
|
||||
};
|
||||
|
||||
struct NewScreen ns = {
|
||||
0, 0, 320, 200, 4, 0, 1, 0, CUSTOMSCREEN, &TestFont, "Test Screen", NULL
|
||||
};
|
||||
|
||||
extern struct Custom custom;
|
||||
|
||||
int main()
|
||||
{
|
||||
struct Window *w;
|
||||
struct RastPort *rp;
|
||||
struct ViewPort *vp;
|
||||
struct UCopList *cl;
|
||||
struct Screen *screen;
|
||||
|
||||
GfxBase = OpenLibrary("graphics.library", 0);
|
||||
if (GfxBase == NULL) exit(1000);
|
||||
IntuitionBase = OpenLibrary("intuition.library", 0);
|
||||
if (IntuitionBase == NULL) {
|
||||
CloseLibrary(GfxBase);
|
||||
exit(2000);
|
||||
}
|
||||
screen = OpenScreen(&ns);
|
||||
if (!screen) {
|
||||
goto cleanup;
|
||||
} else {
|
||||
vp = &screen->ViewPort;
|
||||
rp = &screen->RastPort;
|
||||
}
|
||||
/* init copper list in V1.1 we need to do the following, for >= 1.2, we can use CINIT */
|
||||
cl = (struct UCopList *) AllocMem(sizeof(struct UCopList), MEMF_PUBLIC|MEMF_CLEAR);
|
||||
CWAIT(cl, 100, 0);
|
||||
CMOVE(cl, custom.color[0], 0xfff);
|
||||
CEND(cl);
|
||||
|
||||
vp->UCopIns = cl;
|
||||
Delay(50);
|
||||
RethinkDisplay();
|
||||
Delay(100);
|
||||
CloseScreen(screen);
|
||||
|
||||
cleanup:
|
||||
CloseLibrary(IntuitionBase);
|
||||
CloseLibrary(GfxBase);
|
||||
}
|
||||
|
||||
142
os13/dualplayfield1.c
Normal file
142
os13/dualplayfield1.c
Normal file
@ -0,0 +1,142 @@
|
||||
/**********************************************************************
|
||||
* Dual Playfield Demo
|
||||
* ROM Kernel Reference Manual - Libraries and Devices
|
||||
**********************************************************************/
|
||||
#include <exec/types.h>
|
||||
#include <hardware/dmabits.h>
|
||||
#include <hardware/custom.h>
|
||||
#include <graphics/gfx.h>
|
||||
#include <graphics/gfxbase.h>
|
||||
#include <graphics/gfxmacros.h>
|
||||
#include <graphics/rastport.h>
|
||||
#include <graphics/view.h>
|
||||
#include <exec/exec.h>
|
||||
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/dos_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <clib/graphics_protos.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#define DEPTH 2
|
||||
#define WIDTH 320
|
||||
#define HEIGHT 200
|
||||
#define NOT_ENOUGH_MEMORY -1000
|
||||
|
||||
struct View v;
|
||||
struct ViewPort vp;
|
||||
struct ColorMap *cm;
|
||||
struct RasInfo ri;
|
||||
struct BitMap b;
|
||||
|
||||
struct RasInfo ri2;
|
||||
struct BitMap b2;
|
||||
|
||||
short i, j, k, n;
|
||||
struct ColorMap *GetColorMap();
|
||||
struct GfxBase *GfxBase;
|
||||
|
||||
USHORT colortable[] = {
|
||||
0x000, 0xf00, 0x0f0, 0x00f,
|
||||
0, 0, 0, 0,
|
||||
0, 0x495, 0x62a, 0xf9c
|
||||
};
|
||||
|
||||
UWORD *colorpalette;
|
||||
struct RastPort rp, rp2;
|
||||
struct View *oldview;
|
||||
|
||||
int FreeMemory();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0);
|
||||
if (GfxBase == NULL) exit(1);
|
||||
|
||||
InitView(&v);
|
||||
v.ViewPort = &vp;
|
||||
InitVPort(&vp);
|
||||
|
||||
vp.DWidth = WIDTH;
|
||||
vp.DHeight = HEIGHT;
|
||||
vp.RasInfo = &ri;
|
||||
vp.Modes = DUALPF | PFBA;
|
||||
|
||||
InitBitMap(&b, DEPTH, WIDTH, HEIGHT);
|
||||
ri.BitMap = &b;
|
||||
ri.RxOffset = 0;
|
||||
ri.RyOffset = 0;
|
||||
|
||||
InitBitMap(&b2, DEPTH, WIDTH, HEIGHT);
|
||||
ri.Next = &ri2;
|
||||
ri2.BitMap = &b2;
|
||||
ri2.RxOffset = 0;
|
||||
ri2.RyOffset = 0;
|
||||
ri2.Next = NULL;
|
||||
|
||||
cm = GetColorMap(12);
|
||||
colorpalette = cm->ColorTable;
|
||||
for (i = 0; i < 12; i++) *colorpalette++ = colortable[i];
|
||||
vp.ColorMap = cm;
|
||||
|
||||
for (i = 0; i < DEPTH; i++) {
|
||||
b.Planes[i] = (PLANEPTR) AllocRaster(WIDTH, HEIGHT);
|
||||
if (b.Planes[i] == NULL) exit(NOT_ENOUGH_MEMORY);
|
||||
b2.Planes[i] = (PLANEPTR) AllocRaster(WIDTH, HEIGHT);
|
||||
if (b2.Planes[i] == NULL) exit(NOT_ENOUGH_MEMORY);
|
||||
}
|
||||
InitRastPort(&rp);
|
||||
InitRastPort(&rp2);
|
||||
rp.BitMap = &b;
|
||||
rp2.BitMap = &b2;
|
||||
MakeVPort(&v, &vp);
|
||||
MrgCop(&v);
|
||||
|
||||
SetRast(&rp, 0);
|
||||
SetRast(&rp2, 0);
|
||||
|
||||
oldview = GfxBase->ActiView;
|
||||
LoadView(&v);
|
||||
|
||||
/* draw to first playfield */
|
||||
SetAPen(&rp, 1);
|
||||
RectFill(&rp, 20, 20, 200, 100);
|
||||
SetAPen(&rp, 2);
|
||||
RectFill(&rp, 40, 40, 220, 120);
|
||||
SetAPen(&rp, 3);
|
||||
RectFill(&rp, 60, 60, 240, 140);
|
||||
|
||||
/* draw to second playfield */
|
||||
SetAPen(&rp2, 1);
|
||||
RectFill(&rp2, 50, 90, 245, 180);
|
||||
SetAPen(&rp2, 2);
|
||||
RectFill(&rp2, 70, 70, 265, 160);
|
||||
SetAPen(&rp2, 3);
|
||||
RectFill(&rp2, 90, 10, 285, 148);
|
||||
|
||||
/* Poke some holes in the playfield */
|
||||
SetAPen(&rp2, 0);
|
||||
RectFill(&rp2, 110, 15, 130, 175);
|
||||
RectFill(&rp2, 175, 15, 200, 175);
|
||||
Delay(300);
|
||||
LoadView(oldview);
|
||||
WaitTOF();
|
||||
FreeMemory();
|
||||
CloseLibrary((struct Library *) GfxBase);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FreeMemory()
|
||||
{
|
||||
for (i = 0; i < DEPTH; i++) {
|
||||
FreeRaster(b.Planes[i], WIDTH, HEIGHT);
|
||||
FreeRaster(b2.Planes[i], WIDTH, HEIGHT);
|
||||
}
|
||||
FreeColorMap(cm);
|
||||
FreeVPortCopLists(&vp);
|
||||
FreeCprList(v.LOFCprList);
|
||||
return 0;
|
||||
}
|
||||
124
os13/graphics1.c
Normal file
124
os13/graphics1.c
Normal file
@ -0,0 +1,124 @@
|
||||
/**********************************************************************
|
||||
**** Single Playfield example program from Amiga Rom Kernel Manual
|
||||
**** This program temporarily hides the Intuition viewport and draws
|
||||
**** to its own viewport.
|
||||
**** On exit, it cleans up and returns to Intuition again.
|
||||
**********************************************************************/
|
||||
#include <exec/types.h>
|
||||
#include <exec/exec.h>
|
||||
#include <hardware/dmabits.h>
|
||||
#include <hardware/custom.h>
|
||||
#include <hardware/blit.h>
|
||||
#include <graphics/gfx.h>
|
||||
#include <graphics/gfxmacros.h>
|
||||
#include <graphics/copper.h>
|
||||
#include <graphics/view.h>
|
||||
#include <graphics/gels.h>
|
||||
#include <graphics/regions.h>
|
||||
#include <graphics/clip.h>
|
||||
#include <graphics/text.h>
|
||||
#include <graphics/gfxbase.h>
|
||||
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/dos_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <clib/graphics_protos.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define DEPTH 2
|
||||
#define WIDTH 320
|
||||
#define HEIGHT 256
|
||||
#define NOT_ENOUGH_MEMORY -1000
|
||||
|
||||
struct View v;
|
||||
struct ViewPort vp;
|
||||
struct ColorMap *cm;
|
||||
struct RasInfo ri;
|
||||
struct BitMap b;
|
||||
struct RastPort rp;
|
||||
|
||||
LONG i;
|
||||
SHORT j, k, n;
|
||||
extern struct ColorMap *GetColorMap();
|
||||
struct GfxBase *GfxBase;
|
||||
struct View *oldview;
|
||||
|
||||
USHORT colortable[] = { 0x000, 0xf00, 0x0f0, 0x00f };
|
||||
SHORT boxoffsets[] = { 802, 2010, 3218 };
|
||||
|
||||
UBYTE *displaymem;
|
||||
UWORD *colorpalette;
|
||||
|
||||
int DrawFilledBox(SHORT fillcolor, SHORT plane);
|
||||
int FreeMemory();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0);
|
||||
if (GfxBase == NULL) exit(1);
|
||||
oldview = GfxBase->ActiView;
|
||||
|
||||
InitView(&v);
|
||||
InitVPort(&vp);
|
||||
v.ViewPort = &vp;
|
||||
InitBitMap(&b, DEPTH, WIDTH, HEIGHT);
|
||||
ri.BitMap = &b;
|
||||
ri.RxOffset = 0;
|
||||
ri.RyOffset = 0;
|
||||
ri.Next = NULL;
|
||||
vp.DWidth = WIDTH;
|
||||
vp.DHeight = HEIGHT;
|
||||
vp.RasInfo = &ri;
|
||||
cm = GetColorMap(4);
|
||||
colorpalette = (UWORD *) cm->ColorTable;
|
||||
for (i = 0; i < 4; i++) {
|
||||
*colorpalette++ = colortable[i];
|
||||
}
|
||||
vp.ColorMap = cm;
|
||||
for (i = 0; i < DEPTH; i++) {
|
||||
b.Planes[i] = (PLANEPTR) AllocRaster(WIDTH, HEIGHT);
|
||||
if (b.Planes[i] == NULL) exit(NOT_ENOUGH_MEMORY);
|
||||
}
|
||||
MakeVPort(&v, &vp);
|
||||
MrgCop(&v);
|
||||
for (i = 0; i < 2; i++) {
|
||||
displaymem = (UBYTE *) b.Planes[i];
|
||||
BltClear(displaymem, RASSIZE(WIDTH, HEIGHT), 0);
|
||||
}
|
||||
LoadView(&v);
|
||||
for (n = 1; n < 4; n++) {
|
||||
for (k = 0; k < 2; k++) {
|
||||
displaymem = b.Planes[k] + boxoffsets[n - 1];
|
||||
DrawFilledBox(n, k);
|
||||
}
|
||||
}
|
||||
Delay(50 * 10);
|
||||
LoadView(oldview);
|
||||
FreeMemory();
|
||||
CloseLibrary((struct Library *) GfxBase);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FreeMemory()
|
||||
{
|
||||
for (i = 0; i < DEPTH; i++) {
|
||||
FreeRaster(b.Planes[i], WIDTH, HEIGHT);
|
||||
}
|
||||
FreeColorMap(cm);
|
||||
FreeVPortCopLists(&vp);
|
||||
FreeCprList(v.LOFCprList);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrawFilledBox(SHORT fillcolor, SHORT plane)
|
||||
{
|
||||
UBYTE value;
|
||||
for (j = 0; j < 100; j++) {
|
||||
if ((fillcolor & (1 << plane)) != 0) value = 0xff;
|
||||
else value = 0;
|
||||
for (i = 0; i < 20; i++) *displaymem++ = value;
|
||||
displaymem += (b.BytesPerRow - 20);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
249
os13/ham1.c
Normal file
249
os13/ham1.c
Normal file
@ -0,0 +1,249 @@
|
||||
/*********************************************************************
|
||||
* HAM Mode Demo
|
||||
* ROM Kernel Reference Manual - Libraries and Devices
|
||||
**********************************************************************/
|
||||
#include <exec/types.h>
|
||||
#include <intuition/intuition.h>
|
||||
#include <intuition/intuitionbase.h>
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <clib/graphics_protos.h>
|
||||
#include <clib/alib_protos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define XSIZE 11
|
||||
#define YSIZE 6
|
||||
|
||||
struct GfxBase *GfxBase;
|
||||
struct IntuitionBase *IntuitionBase;
|
||||
|
||||
struct RastPort *rp;
|
||||
struct ViewPort *vp;
|
||||
|
||||
struct TextAttr TestFont = {
|
||||
"topaz.font", 8, 0, 0
|
||||
};
|
||||
|
||||
struct Window *w;
|
||||
struct Screen *screen;
|
||||
struct IntuiMessage *message;
|
||||
|
||||
struct NewScreen ns = {
|
||||
0, 0, 320, 200, 6, 0, 1, HAM, CUSTOMSCREEN, &TestFont,
|
||||
" 256 different out of 4096", NULL
|
||||
};
|
||||
|
||||
struct NewWindow nw = {
|
||||
0, 11, 320, 186, -1, -1, MOUSEBUTTONS | CLOSEWINDOW,
|
||||
ACTIVATE | WINDOWCLOSE,
|
||||
NULL, NULL,
|
||||
"colors at any given moment",
|
||||
NULL, NULL, 0, 0, 320, 186, CUSTOMSCREEN
|
||||
};
|
||||
|
||||
LONG squarecolor[16 * 16], freecolors[4096 - (16 * 16)];
|
||||
SHORT squares[16 * 16];
|
||||
SHORT xpos[16], ypos[16];
|
||||
|
||||
char *number[] = {
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||
"A", "B", "C", "D", "E", "F"
|
||||
};
|
||||
|
||||
SHORT sStop, cStop, sequence;
|
||||
BOOL textneeded;
|
||||
|
||||
int prompt();
|
||||
int hamBox(LONG color, LONG x, LONG y);
|
||||
int colorWheel();
|
||||
int colorFull();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ULONG class;
|
||||
USHORT code, i;
|
||||
BOOL wheelmode;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
xpos[i] = (XSIZE + 4) * i + 20;
|
||||
ypos[i] = (YSIZE + 3) * i + 21;
|
||||
}
|
||||
GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0);
|
||||
if (GfxBase == NULL) exit(100);
|
||||
IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0);
|
||||
if (IntuitionBase == NULL) {
|
||||
CloseLibrary((struct Library *) GfxBase);
|
||||
exit(200);
|
||||
}
|
||||
|
||||
screen = (struct Screen *) OpenScreen(&ns);
|
||||
if (screen == NULL) {
|
||||
CloseLibrary((struct Library *) IntuitionBase);
|
||||
CloseLibrary((struct Library *) GfxBase);
|
||||
exit(300);
|
||||
}
|
||||
nw.Screen = screen;
|
||||
w = (struct Window *) OpenWindow(&nw);
|
||||
if (w == NULL) {
|
||||
CloseScreen(screen);
|
||||
CloseLibrary((struct Library *) IntuitionBase);
|
||||
CloseLibrary((struct Library *) GfxBase);
|
||||
exit(400);
|
||||
}
|
||||
|
||||
vp = &screen->ViewPort;
|
||||
rp = w->RPort;
|
||||
|
||||
SetRGB4(vp, 0, 0, 0, 0);
|
||||
SetRGB4(vp, 1, 15, 0, 0);
|
||||
SetRGB4(vp, 2, 0, 15, 0);
|
||||
SetRGB4(vp, 3, 0, 0, 15);
|
||||
SetRGB4(vp, 4, 15, 15, 15);
|
||||
|
||||
SetBPen(rp, 0);
|
||||
textneeded = TRUE;
|
||||
wheelmode = TRUE;
|
||||
|
||||
for (;;) {
|
||||
Wait(1 << w->UserPort->mp_SigBit);
|
||||
while ((message = (struct IntuiMessage *)GetMsg(w->UserPort)) != NULL) {
|
||||
class = message->Class;
|
||||
code = message->Code;
|
||||
ReplyMsg((struct Message *) message);
|
||||
|
||||
if (class == CLOSEWINDOW) {
|
||||
CloseWindow(w);
|
||||
CloseScreen(screen);
|
||||
CloseLibrary((struct Library *) IntuitionBase);
|
||||
CloseLibrary((struct Library *) GfxBase);
|
||||
exit(0);
|
||||
}
|
||||
if (class == MOUSEBUTTONS && code == SELECTDOWN) {
|
||||
wheelmode = NOT wheelmode;
|
||||
SetAPen(rp, 0);
|
||||
SetDrMd(rp, JAM1);
|
||||
RectFill(rp, 3, 12, 318, 183);
|
||||
textneeded = TRUE;
|
||||
}
|
||||
}
|
||||
if (wheelmode) colorWheel(); else colorFull();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int colorFull()
|
||||
{
|
||||
SHORT sChoice, cChoice, usesquare;
|
||||
LONG usecolor;
|
||||
|
||||
if (textneeded) {
|
||||
prompt();
|
||||
sStop = 255;
|
||||
cStop = 4095 - 256;
|
||||
|
||||
for (usecolor = 0; usecolor < 256; usecolor++) {
|
||||
usesquare = usecolor;
|
||||
squares[usesquare] = usesquare;
|
||||
squarecolor[usesquare] = usecolor;
|
||||
hamBox(usecolor, xpos[usesquare % 16], ypos[usesquare / 16]);
|
||||
}
|
||||
for (usecolor = 256; usecolor < 4095; usecolor++) {
|
||||
freecolors[usecolor - 256] = usecolor;
|
||||
}
|
||||
}
|
||||
|
||||
/* randomly choose next square */
|
||||
sChoice = RangeRand(sStop + 1);
|
||||
usesquare = squares[sChoice];
|
||||
squares[sChoice] = squares[sStop];
|
||||
squares[sStop] = usesquare;
|
||||
|
||||
if (NOT sStop--) sStop = 255;
|
||||
|
||||
/* randomly choose new color */
|
||||
cChoice = RangeRand(cStop + 1);
|
||||
usecolor = freecolors[cChoice];
|
||||
freecolors[cChoice] = freecolors[cStop];
|
||||
freecolors[cStop] = squarecolor[usesquare];
|
||||
squarecolor[usesquare] = usecolor;
|
||||
|
||||
if (NOT cStop--) cStop = 4095 - 256;
|
||||
|
||||
hamBox(usecolor, xpos[usesquare % 16], ypos[usesquare / 16]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int colorWheel()
|
||||
{
|
||||
SHORT i, j;
|
||||
if (textneeded) {
|
||||
prompt();
|
||||
SetAPen(rp, 2); /* green pen for green color numbers */
|
||||
Move(rp, 260, ypos[15] + 17);
|
||||
Text(rp, "Green", 5);
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
Move(rp, xpos[i] + 3, ypos[15] + 17);
|
||||
Text(rp, number[i], 1);
|
||||
}
|
||||
|
||||
SetAPen(rp, 3); /* blue pen for blue color numbers */
|
||||
Move(rp, 4, 18);
|
||||
Text(rp, "Blue", 4);
|
||||
for (i = 0; i < 16; i++) {
|
||||
Move(rp, 7, ypos[i] + 6);
|
||||
Text(rp, number[i], 1);
|
||||
}
|
||||
|
||||
SetAPen(rp, 1); /* red pen for red color numbers */
|
||||
Move(rp, 271, 100);
|
||||
Text(rp, "Red", 3);
|
||||
|
||||
sequence = 0;
|
||||
}
|
||||
|
||||
SetAPen(rp, 1); /* Identify the red color in use */
|
||||
SetDrMd(rp, JAM2);
|
||||
Move(rp, 280, 115);
|
||||
Text(rp, number[sequence], 1);
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
for (i = 0; i < 16; i++)
|
||||
hamBox((sequence << 8 | i << 4 | j), xpos[i], ypos[j]);
|
||||
|
||||
if (++sequence == 16) sequence = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int prompt()
|
||||
{
|
||||
SetDrMd(rp, JAM2);
|
||||
SetAPen(rp, 4);
|
||||
Move(rp, 23, 183);
|
||||
Text(rp, "[left mouse button = new mode]", 30);
|
||||
textneeded = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hamBox(LONG color, LONG x, LONG y)
|
||||
{
|
||||
SHORT c;
|
||||
SetDrMd(rp, JAM1);
|
||||
c = ((color & 0xf00) >> 8); /* extract red color component */
|
||||
SetAPen(rp, c + 0x20); /* Hold G, B from previous pixel. Set R = n */
|
||||
Move(rp, x, y);
|
||||
Draw(rp, x, y + YSIZE);
|
||||
|
||||
x++;
|
||||
c = ((color & 0x0f0) >> 4); /* extract green color component */
|
||||
SetAPen(rp, c + 0x30); /* Hold R, B from previous pixel. Set G = n */
|
||||
Move(rp, x, y);
|
||||
Draw(rp, x, y + YSIZE);
|
||||
|
||||
x++;
|
||||
c = color & 0x0f; /* extract blue color component */
|
||||
SetAPen(rp, c + 0x10); /* Hold R, G from previous pixel. Set B = n */
|
||||
RectFill(rp, x, y, x + XSIZE - 2, y + YSIZE);
|
||||
return 0;
|
||||
}
|
||||
83
os13/intuition1.c
Normal file
83
os13/intuition1.c
Normal file
@ -0,0 +1,83 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <exec/types.h>
|
||||
#include <intuition/intuition.h>
|
||||
#include <libraries/dos.h>
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <clib/graphics_protos.h>
|
||||
|
||||
#define INTUITION_REV 33L
|
||||
#define GRAPHICS_REV 33L
|
||||
|
||||
struct TextAttr MyFont = {
|
||||
"topaz.font",
|
||||
TOPAZ_SIXTY,
|
||||
FS_NORMAL,
|
||||
FPF_ROMFONT
|
||||
};
|
||||
|
||||
struct Library *IntuitionBase;
|
||||
struct Library *GfxBase;
|
||||
|
||||
struct NewScreen NewScreen = {
|
||||
0, 0, 320, 200, 2, 0, 1, 0, CUSTOMSCREEN, &MyFont,
|
||||
"My Own Screen", NULL, NULL,
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct Screen *Screen;
|
||||
struct NewWindow NewWindow;
|
||||
struct Window *Window;
|
||||
LONG i;
|
||||
|
||||
IntuitionBase = OpenLibrary("intuition.library", INTUITION_REV);
|
||||
if (IntuitionBase == NULL) {
|
||||
printf("Intuition could not be opened\n");
|
||||
exit(FALSE);
|
||||
}
|
||||
GfxBase = OpenLibrary("graphics.library", GRAPHICS_REV);
|
||||
if (GfxBase == NULL) {
|
||||
printf("Graphics could not be opened\n");
|
||||
exit(FALSE);
|
||||
}
|
||||
if ((Screen = (struct Screen *) OpenScreen(&NewScreen)) == NULL) {
|
||||
printf("could not open screen\n");
|
||||
exit(FALSE);
|
||||
}
|
||||
|
||||
NewWindow.LeftEdge = 20;
|
||||
NewWindow.TopEdge = 20;
|
||||
NewWindow.Width = 300;
|
||||
NewWindow.Height = 100;
|
||||
NewWindow.DetailPen = 0;
|
||||
NewWindow.BlockPen = 1;
|
||||
NewWindow.Title = "A Simple Window";
|
||||
NewWindow.Flags = WINDOWCLOSE | SMART_REFRESH | ACTIVATE |
|
||||
WINDOWSIZING | WINDOWDRAG | WINDOWDEPTH | NOCAREREFRESH;
|
||||
NewWindow.IDCMPFlags = CLOSEWINDOW;
|
||||
NewWindow.Type = CUSTOMSCREEN;
|
||||
NewWindow.FirstGadget = NULL;
|
||||
NewWindow.CheckMark = NULL;
|
||||
NewWindow.Screen = Screen;
|
||||
NewWindow.BitMap = NULL;
|
||||
NewWindow.MinWidth = 100;
|
||||
NewWindow.MinHeight = 25;
|
||||
NewWindow.MaxWidth = 640;
|
||||
NewWindow.MaxHeight = 200;
|
||||
|
||||
if ((Window = (struct Window *) OpenWindow(&NewWindow)) == NULL) {
|
||||
printf("could not open window");
|
||||
exit(FALSE);
|
||||
}
|
||||
Move(Window->RPort, 20, 20);
|
||||
Text(Window->RPort, "Hello World", 11);
|
||||
|
||||
Wait(1 << Window->UserPort->mp_SigBit);
|
||||
CloseWindow(Window);
|
||||
CloseScreen(Screen);
|
||||
CloseLibrary(GfxBase);
|
||||
CloseLibrary(IntuitionBase);
|
||||
return 0;
|
||||
}
|
||||
48
os13/openwin.c
Normal file
48
os13/openwin.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include <exec/types.h>
|
||||
#include <intuition/intuition.h>
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define INTUITION_REV 0
|
||||
#define MILLION 1000000
|
||||
|
||||
struct Library *IntuitionBase;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct NewWindow NewWindow;
|
||||
struct Window *Window;
|
||||
LONG i;
|
||||
|
||||
IntuitionBase = (struct Library *) OpenLibrary("intuition.library", INTUITION_REV);
|
||||
if (IntuitionBase == NULL) exit(FALSE);
|
||||
|
||||
NewWindow.LeftEdge = 20;
|
||||
NewWindow.TopEdge = 20;
|
||||
NewWindow.Width = 300;
|
||||
NewWindow.Height = 100;
|
||||
NewWindow.DetailPen = 0;
|
||||
NewWindow.BlockPen = 1;
|
||||
NewWindow.Title = "A Simple Window";
|
||||
NewWindow.Flags = WINDOWCLOSE | SMART_REFRESH | ACTIVATE |
|
||||
WINDOWSIZING | WINDOWDRAG | WINDOWDEPTH | NOCAREREFRESH;
|
||||
NewWindow.IDCMPFlags = CLOSEWINDOW;
|
||||
NewWindow.Type = WBENCHSCREEN;
|
||||
NewWindow.FirstGadget = NULL;
|
||||
NewWindow.CheckMark = NULL;
|
||||
NewWindow.Screen = NULL;
|
||||
NewWindow.BitMap = NULL;
|
||||
NewWindow.MinWidth = 0;
|
||||
NewWindow.MinHeight = 0;
|
||||
NewWindow.MaxWidth = 0;
|
||||
NewWindow.MaxHeight = 0;
|
||||
|
||||
if ((Window = (struct Window *) OpenWindow(&NewWindow)) == NULL) {
|
||||
exit(FALSE);
|
||||
}
|
||||
Wait(1 << Window->UserPort->mp_SigBit);
|
||||
CloseWindow(Window);
|
||||
CloseLibrary(IntuitionBase);
|
||||
return 0;
|
||||
}
|
||||
9
os13/ostest.c
Normal file
9
os13/ostest.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("hello\n");
|
||||
printf("exec base is: shit\n");
|
||||
printf("hello: %04x\n", *((unsigned int *) 4));
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user