Fixed bug in heap manager - forgot to initialise freeptr

This commit is contained in:
Adam Greenwood-Byrne 2021-03-09 22:16:25 +00:00
parent a5fdf22a1d
commit 0c55d05177
2 changed files with 35 additions and 31 deletions

View file

@ -1,4 +1,5 @@
#include "wgt.h" #include "wgt.h"
#include "include/mem.h"
// ######## REQUIRED FUNCTIONS ######## // ######## REQUIRED FUNCTIONS ########
@ -51,47 +52,48 @@ void getch(void) {
void wgt08() void wgt08()
{ {
short x; short x;
vga256 (); mem_init();
wcls (vgapal[0]); vga256 ();
wcls (vgapal[0]);
wsetcolor (vgapal[1]); wsetcolor (vgapal[1]);
wcircle (960, 540, 270); /* try filling a circle */ wcircle (960, 540, 270); /* try filling a circle */
getch (); getch ();
wsetcolor (vgapal[40]); wsetcolor (vgapal[40]);
wregionfill (960, 540); wregionfill (960, 540);
wsetcolor (vgapal[170]); wsetcolor (vgapal[170]);
wregionfill (0, 0); wregionfill (0, 0);
getch (); getch ();
wcls (0); wcls (0);
for (x = 1; x < 10000; x++) /* try filling 10,000 random pixels */ for (x = 1; x < 10000; x++) /* try filling 10,000 random pixels */
{ {
wsetcolor (vgapal[rand() % 255]); wsetcolor (vgapal[rand() % 255]);
wputpixel (rand() % 1920, rand() % 1080); wputpixel (rand() % 1920, rand() % 1080);
} }
getch (); getch ();
wsetcolor (vgapal[40]); wsetcolor (vgapal[40]);
wclip (300, 270, 1500, 810); /* fill works with clipping too! */ wclip (300, 270, 1500, 810); /* fill works with clipping too! */
wregionfill (960, 540); wregionfill (960, 540);
wsetcolor (vgapal[7]); wsetcolor (vgapal[7]);
wclip (60, 54, 240, 216); wclip (60, 54, 240, 216);
wregionfill (120, 108); wregionfill (120, 108);
wsetcolor (vgapal[9]); wsetcolor (vgapal[9]);
wclip (1560, 864, 1800, 1026); wclip (1560, 864, 1800, 1026);
wregionfill (1620, 918); wregionfill (1620, 918);
wsetcolor (vgapal[10]); wsetcolor (vgapal[10]);
wclip (0, 0, 1919, 1079); wclip (0, 0, 1919, 1079);
wregionfill (0, 0); wregionfill (0, 0);
getch (); getch ();
} }
void main() void main()

View file

@ -19,6 +19,8 @@ void mem_init()
HEAP_START += 8 - ((long)&HEAP_START % 8); HEAP_START += 8 - ((long)&HEAP_START % 8);
} }
HEAP_END = (unsigned char *)(HEAP_START + HEAP_SIZE); HEAP_END = (unsigned char *)(HEAP_START + HEAP_SIZE);
freeptr = HEAP_START;
} }
void *malloc(unsigned int size) void *malloc(unsigned int size)