Skip to content

Commit

Permalink
Merge pull request #2193 from toncho11/master
Browse files Browse the repository at this point in the history
Added support for circle for CGA / IBM PC.
  • Loading branch information
ghaerr authored Jan 20, 2025
2 parents 678dd4e + 8b16e96 commit 21d5845
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion elkscmd/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ MODE number (set graphics mode, e.g MODE 1 to use PLOT/DRAW/CIRCLE)
COLOR fg,bg
PLOT x,y
DRAW x,y
CIRCLE x,y,r (PC-98 only for now)
CIRCLE x,y,r
INPB(port) (IO read byte from `port`)
INPW(port) (IO read word from `port`)
OUTB port, value (IO write byte `value` from `port`)
Expand Down
25 changes: 24 additions & 1 deletion elkscmd/basic/host-ibmpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,30 @@ void host_draw(int x, int y) {
}
}

void host_circle(int x, int y, int r) {
//using midpoint circle algorithm
void host_circle(int xc, int yc, int r) {
int x = 0;
int y = r;
int d = 1 - r;

while (x <= y) {
host_plot(xc + x, yc + y);
host_plot(xc - x, yc + y);
host_plot(xc + x, yc - y);
host_plot(xc - x, yc - y);
host_plot(xc + y, yc + x);
host_plot(xc - y, yc + x);
host_plot(xc + y, yc - x);
host_plot(xc - y, yc - x);

if (d < 0) {
d += 2 * x + 3;
} else {
d += 2 * (x - y) + 5;
y--;
}
x++;
}
}

void host_outb(int port, int value) {
Expand Down
2 changes: 1 addition & 1 deletion elkscmd/basic/snake.bas → elkscmd/basic/snake98.bas
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
100 REM port from www.quitebasic.com/prj/games/snake
100 REM port from www.quitebasic.com/prj/games/snake The version below is specific to PC 98 computers.
200 MODE 1
300 CLS
400 PRINT "=== Snake and Dots ==="
Expand Down
2 changes: 1 addition & 1 deletion elkscmd/basic/snakecga.bas
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
100 REM port from www.quitebasic.com/prj/games/snake
100 REM port from www.quitebasic.com/prj/games/snake This version below is for CGA video mode and IBM PC
200 MODE 0
300 CLS
400 PRINT "=== Snake and Dots ==="
Expand Down

0 comments on commit 21d5845

Please sign in to comment.