mirror of
https://github.com/irmen/prog8.git
synced 2026-10-22 05:02:58 +00:00
rename amiga_gfx to easygfx
This commit is contained in:
1 parent
4d0a7ff8bf
commit
fd3add76e4
8 files changed
+71
-71
No files matched your search
@@ -1,5 +0,0 @@
|
||||
%import shared_amiga_gfx
|
||||
|
||||
amiga_gfx {
|
||||
%option ignore_unused
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
%import shared_amiga_easygfx
|
||||
|
||||
easygfx {
|
||||
%option ignore_unused
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
%import shared_amiga_gfx
|
||||
|
||||
amiga_gfx {
|
||||
%option ignore_unused
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
%import shared_amiga_easygfx
|
||||
|
||||
easygfx {
|
||||
%option ignore_unused
|
||||
}
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
; amiga_gfx - friendly OS graphics wrapper, shared by the amiga500 and amiga1200 targets.
|
||||
; easygfx - friendly OS graphics wrapper, shared by the amiga500 and amiga1200 targets.
|
||||
;
|
||||
; Hides NewScreen/NewWindow boilerplate behind a gfx_lores-style API:
|
||||
; per-call pen, client-relative word coordinates, explicit open/close.
|
||||
@@ -15,7 +15,7 @@
|
||||
%import strings
|
||||
%import exec
|
||||
|
||||
amiga_gfx {
|
||||
easygfx {
|
||||
%option merge, ignore_unused
|
||||
|
||||
uword width ; drawable client size, set by fullscreen()/windowed()
|
||||
@@ -255,7 +255,7 @@ amiga_gfx {
|
||||
|
||||
inline sub drawmode(ubyte mode) {
|
||||
; graphics.RP_JAM1, RP_JAM2, RP_COMPLEMENT, RP_INVERSVID
|
||||
graphics.SetDrMd(amiga_gfx.rastport, mode)
|
||||
graphics.SetDrMd(easygfx.rastport, mode)
|
||||
}
|
||||
|
||||
sub palette(pointer colors, uword count) {
|
||||
@@ -282,12 +282,12 @@ amiga_gfx {
|
||||
|
||||
inline sub readpixel(word x, word y) -> long {
|
||||
; pen number at the pixel, or -1 when outside
|
||||
return graphics.ReadPixel(amiga_gfx.rastport, amiga_gfx.origin_x+x, amiga_gfx.origin_y+y)
|
||||
return graphics.ReadPixel(easygfx.rastport, easygfx.origin_x+x, easygfx.origin_y+y)
|
||||
}
|
||||
|
||||
inline sub textwidth(str s) -> word {
|
||||
; raster width of the string in the current font, e.g. to center text
|
||||
return graphics.TextLength(amiga_gfx.rastport, s, strings.length(s))
|
||||
return graphics.TextLength(easygfx.rastport, s, strings.length(s))
|
||||
}
|
||||
|
||||
sub mouse_xy(^^intuition.IntuiMessage msg) -> word, word {
|
||||
@@ -526,7 +526,7 @@ modules. Import them the same way as any other library::
|
||||
``copper``
|
||||
Copper list builder and manager.
|
||||
|
||||
``amiga_gfx``
|
||||
``easygfx``
|
||||
Friendly OS graphics wrapper in the style of the ``gfx_*`` pixel modules:
|
||||
per-call pen, client-relative coordinates, no structs or tag lists to manage.
|
||||
``fullscreen()`` opens a custom screen with a backdrop window (an empty title
|
||||
|
||||
+32
-32
@@ -1,8 +1,8 @@
|
||||
; amiga_gfx interactive demo: fullscreen drawing with the mouse.
|
||||
; gfx interactive demo: fullscreen drawing with the mouse.
|
||||
; Left click draws a small circle, right click a small rectangle, ESC quits.
|
||||
; Runs on Kickstart 1.3 and up, on amiga500 and amiga1200.
|
||||
|
||||
%import amiga_gfx
|
||||
%import easygfx
|
||||
%import graphics
|
||||
%import intuition
|
||||
|
||||
@@ -10,34 +10,34 @@ main {
|
||||
uword[8] palette = [$0112, $0f00, $00f0, $000f, $0ff0, $0f0f, $00ff, $0fff]
|
||||
|
||||
sub start() {
|
||||
if amiga_gfx.fullscreen(320, 256, 3, graphics.LORES, "amiga_gfx Demo") {
|
||||
defer amiga_gfx.close()
|
||||
if easygfx.fullscreen(320, 256, 3, graphics.LORES, "amiga_gfx Demo") {
|
||||
defer easygfx.close()
|
||||
draw_all()
|
||||
interact()
|
||||
}
|
||||
}
|
||||
|
||||
sub draw_all() {
|
||||
amiga_gfx.palette(palette, len(palette))
|
||||
amiga_gfx.clear(0)
|
||||
amiga_gfx.rect(5, 5, 310, 246, 1)
|
||||
amiga_gfx.fillrect(10, 10, 60, 40, 2)
|
||||
amiga_gfx.line(0, 0, 319, 255, 3)
|
||||
amiga_gfx.circle(160, 128, 60, 4)
|
||||
amiga_gfx.line(160, 68, 160, 188, 4)
|
||||
amiga_gfx.fill(190, 128, 5)
|
||||
amiga_gfx.disc(80, 200, 30, 5)
|
||||
amiga_gfx.oval(240, 200, 50, 20, 6)
|
||||
amiga_gfx.filled_oval(40, 60, 30, 12, 5)
|
||||
amiga_gfx.plot(160, 128, 7)
|
||||
amiga_gfx.text(160, 30, "amiga_gfx demo", 5)
|
||||
word tw = amiga_gfx.textwidth("click to draw, arrows scroll")
|
||||
amiga_gfx.text(160 - tw/2, 60, "click to draw, arrows scroll", 6)
|
||||
tw = amiga_gfx.textwidth("ESC=quit")
|
||||
amiga_gfx.text(160 - tw/2, 70, "ESC=quit", 7)
|
||||
amiga_gfx.setcolor(7, $f, $f, $f)
|
||||
easygfx.palette(palette, len(palette))
|
||||
easygfx.clear(0)
|
||||
easygfx.rect(5, 5, 310, 246, 1)
|
||||
easygfx.fillrect(10, 10, 60, 40, 2)
|
||||
easygfx.line(0, 0, 319, 255, 3)
|
||||
easygfx.circle(160, 128, 60, 4)
|
||||
easygfx.line(160, 68, 160, 188, 4)
|
||||
easygfx.fill(190, 128, 5)
|
||||
easygfx.disc(80, 200, 30, 5)
|
||||
easygfx.oval(240, 200, 50, 20, 6)
|
||||
easygfx.filled_oval(40, 60, 30, 12, 5)
|
||||
easygfx.plot(160, 128, 7)
|
||||
easygfx.text(160, 30, "amiga_gfx demo", 5)
|
||||
word tw = easygfx.textwidth("click to draw, arrows scroll")
|
||||
easygfx.text(160 - tw/2, 60, "click to draw, arrows scroll", 6)
|
||||
tw = easygfx.textwidth("ESC=quit")
|
||||
easygfx.text(160 - tw/2, 70, "ESC=quit", 7)
|
||||
easygfx.setcolor(7, $f, $f, $f)
|
||||
; direct library escape hatch via the exposed RastPort:
|
||||
^^graphics.RastPort rp = amiga_gfx.rastport
|
||||
^^graphics.RastPort rp = easygfx.rastport
|
||||
graphics.SetAPen(rp, 3)
|
||||
graphics.Move(rp, 10, 240)
|
||||
graphics.Draw(rp, 310, 240)
|
||||
@@ -46,16 +46,16 @@ main {
|
||||
sub interact() {
|
||||
bool done = false
|
||||
while not done {
|
||||
^^intuition.IntuiMessage msg = amiga_gfx.imsg_wait()
|
||||
^^intuition.IntuiMessage msg = easygfx.imsg_wait()
|
||||
while msg != 0 {
|
||||
when msg.Class {
|
||||
intuition.IDCMP_CLOSEWINDOW -> done = true
|
||||
intuition.IDCMP_MOUSEBUTTONS -> {
|
||||
word mx, my = amiga_gfx.mouse_xy(msg)
|
||||
word mx, my = easygfx.mouse_xy(msg)
|
||||
if msg.Code == intuition.SELECTDOWN
|
||||
amiga_gfx.circle(mx, my, 8, 6)
|
||||
easygfx.circle(mx, my, 8, 6)
|
||||
if msg.Code == intuition.MENUDOWN
|
||||
amiga_gfx.fillrect(mx-10, my-6, 20, 12, 2)
|
||||
easygfx.fillrect(mx-10, my-6, 20, 12, 2)
|
||||
}
|
||||
intuition.IDCMP_RAWKEY -> {
|
||||
; keyboard arrives as rawkey only: cursor keys scroll (key repeat
|
||||
@@ -74,15 +74,15 @@ main {
|
||||
when (msg.Code & $7f) {
|
||||
; note: ScrollRaster moves bits towards (0,0), so the signs are flipped
|
||||
$45 -> done = true ; ESC
|
||||
$4c -> amiga_gfx.scrollrect(0, 8, 80, 88, 160, 120) ; up
|
||||
$4d -> amiga_gfx.scrollrect(0, -8, 80, 88, 160, 120) ; down
|
||||
$4e -> amiga_gfx.scrollrect(-8, 0, 80, 88, 160, 120) ; right
|
||||
$4f -> amiga_gfx.scrollrect(8, 0, 80, 88, 160, 120) ; left
|
||||
$4c -> easygfx.scrollrect(0, 8, 80, 88, 160, 120) ; up
|
||||
$4d -> easygfx.scrollrect(0, -8, 80, 88, 160, 120) ; down
|
||||
$4e -> easygfx.scrollrect(-8, 0, 80, 88, 160, 120) ; right
|
||||
$4f -> easygfx.scrollrect(8, 0, 80, 88, 160, 120) ; left
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
msg = amiga_gfx.imsg_reply(msg)
|
||||
msg = easygfx.imsg_reply(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-23
@@ -1,8 +1,8 @@
|
||||
; tic tac toe via the amiga_gfx library: click squares to play X and O.
|
||||
; tic tac toe via the easygfx library: click squares to play X and O.
|
||||
; Left click places a mark, R restarts, ESC quits.
|
||||
; Runs on Kickstart 1.3 and up, on amiga500 and amiga1200.
|
||||
|
||||
%import amiga_gfx
|
||||
%import easygfx
|
||||
%import diskfont
|
||||
%import graphics
|
||||
%import intuition
|
||||
@@ -31,8 +31,8 @@ main {
|
||||
}
|
||||
|
||||
sub start() {
|
||||
if amiga_gfx.fullscreen(320, 256, 2, graphics.LORES, "Tic Tac Toe") {
|
||||
defer amiga_gfx.close()
|
||||
if easygfx.fullscreen(320, 256, 2, graphics.LORES, "Tic Tac Toe") {
|
||||
defer easygfx.close()
|
||||
; try to set custom font, silently keeps Topaz 8 when unavailable
|
||||
^^graphics.TextFont font = 0
|
||||
if diskfont.openlib() {
|
||||
@@ -40,7 +40,7 @@ main {
|
||||
diskfont.closelib()
|
||||
}
|
||||
if font != 0 {
|
||||
^^graphics.RastPort rp = amiga_gfx.rastport
|
||||
^^graphics.RastPort rp = easygfx.rastport
|
||||
void graphics.SetFont(rp, font)
|
||||
}
|
||||
new_game()
|
||||
@@ -55,7 +55,7 @@ main {
|
||||
obits = 0
|
||||
turn = Player::X
|
||||
over = false
|
||||
amiga_gfx.clear(0)
|
||||
easygfx.clear(0)
|
||||
draw_grid()
|
||||
status("X to move - click a square")
|
||||
}
|
||||
@@ -63,8 +63,8 @@ main {
|
||||
sub draw_grid() {
|
||||
ubyte i
|
||||
for i in 1 to 2 {
|
||||
amiga_gfx.line(BX + i*CELL, BY, BX + i*CELL, BY + 3*CELL, 1)
|
||||
amiga_gfx.line(BX, BY + i*CELL, BX + 3*CELL, BY + i*CELL, 1)
|
||||
easygfx.line(BX + i*CELL, BY, BX + i*CELL, BY + 3*CELL, 1)
|
||||
easygfx.line(BX, BY + i*CELL, BX + 3*CELL, BY + i*CELL, 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ main {
|
||||
word cx = BX + (col as word) * CELL
|
||||
word cy = BY + (row as word) * CELL
|
||||
if player == Player::X {
|
||||
amiga_gfx.line(cx+10, cy+10, cx+CELL-10, cy+CELL-10, 2)
|
||||
amiga_gfx.line(cx+CELL-10, cy+10, cx+10, cy+CELL-10, 2)
|
||||
amiga_gfx.line(cx+11, cy+10, cx+CELL-9, cy+CELL-10, 2)
|
||||
amiga_gfx.line(cx+CELL-9, cy+10, cx+11, cy+CELL-10, 2)
|
||||
easygfx.line(cx+10, cy+10, cx+CELL-10, cy+CELL-10, 2)
|
||||
easygfx.line(cx+CELL-10, cy+10, cx+10, cy+CELL-10, 2)
|
||||
easygfx.line(cx+11, cy+10, cx+CELL-9, cy+CELL-10, 2)
|
||||
easygfx.line(cx+CELL-9, cy+10, cx+11, cy+CELL-10, 2)
|
||||
} else {
|
||||
amiga_gfx.circle(cx+CELL/2, cy+CELL/2, CELL/2-10, 3)
|
||||
amiga_gfx.circle(cx+CELL/2, cy+CELL/2, CELL/2-11, 3)
|
||||
easygfx.circle(cx+CELL/2, cy+CELL/2, CELL/2-10, 3)
|
||||
easygfx.circle(cx+CELL/2, cy+CELL/2, CELL/2-11, 3)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,27 +126,27 @@ main {
|
||||
sub status(str msg) {
|
||||
; JAM2 so the text background overwrites the previous line;
|
||||
; with the default JAM1 black pixels are transparent and text ghosts.
|
||||
; amiga_gfx.fillrect(0, BY + 3*CELL + 16, 320, 12, 3)
|
||||
^^graphics.RastPort rp = amiga_gfx.rastport
|
||||
; easygfx.fillrect(0, BY + 3*CELL + 16, 320, 12, 3)
|
||||
^^graphics.RastPort rp = easygfx.rastport
|
||||
graphics.SetBPen(rp, 3)
|
||||
amiga_gfx.drawmode(graphics.RP_JAM2)
|
||||
word tw = amiga_gfx.textwidth(msg)
|
||||
amiga_gfx.text(160 - tw/2, BY + 3*CELL + 16, msg, 1)
|
||||
amiga_gfx.drawmode(graphics.RP_JAM1)
|
||||
easygfx.drawmode(graphics.RP_JAM2)
|
||||
word tw = easygfx.textwidth(msg)
|
||||
easygfx.text(160 - tw/2, BY + 3*CELL + 16, msg, 1)
|
||||
easygfx.drawmode(graphics.RP_JAM1)
|
||||
}
|
||||
|
||||
sub interact() {
|
||||
^^intuition.IntuiMessage msg
|
||||
bool done = false
|
||||
while not done {
|
||||
msg = amiga_gfx.imsg_wait()
|
||||
msg = easygfx.imsg_wait()
|
||||
while msg != 0 {
|
||||
when msg.Class {
|
||||
intuition.IDCMP_CLOSEWINDOW -> done = true
|
||||
intuition.IDCMP_MOUSEBUTTONS -> handle_click()
|
||||
intuition.IDCMP_RAWKEY -> handle_key()
|
||||
}
|
||||
msg = amiga_gfx.imsg_reply(msg)
|
||||
msg = easygfx.imsg_reply(msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ main {
|
||||
new_game()
|
||||
return
|
||||
}
|
||||
word mx, my = amiga_gfx.mouse_xy(msg)
|
||||
word mx, my = easygfx.mouse_xy(msg)
|
||||
byte col, row = cell_at(mx, my)
|
||||
if col >= 0
|
||||
play_at(col as ubyte, row as ubyte)
|
||||
|
||||
Reference in new issue
Block a user