From: sparky4 Date: Thu, 11 Dec 2014 19:06:45 +0000 (-0600) Subject: i do not know how to allocate and move variables to EMS X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=commitdiff_plain;h=8f435c884a38d1d14b3b95940156245da755872f i do not know how to allocate and move variables to EMS modified: scroll.exe modified: src/lib/ems.c modified: src/lib/xms.c modified: src/scroll.c --- diff --git a/scroll.exe b/scroll.exe index c6813446..c2c6c3fc 100644 Binary files a/scroll.exe and b/scroll.exe differ diff --git a/src/lib/ems.c b/src/lib/ems.c index 9883f60c..52658e56 100644 --- a/src/lib/ems.c +++ b/src/lib/ems.c @@ -287,3 +287,33 @@ int mem_emem(unsigned int *total, unsigned int *freeall) return( 1 ); } + +void emmmove(int page, short *str, int n) + { + /* + Move 'n' bytes from conventional memory to the specified + expanded memory + page + */ + + char far *ptr; + + ptr = pageframeEMS() + page * 16384; + while(n-- > 0) + *ptr++ = *str++; + } + + void emmget(int page, short *str, int n) + { + /* + Move 'n' bytes from the specified expanded memory page into + conventional + memory + */ + + char far *ptr; + + ptr = pageframeEMS() + page * 16384; + while(n-- > 0) + *str++ = *ptr++; + } diff --git a/src/lib/xms.c b/src/lib/xms.c index 09797210..1781754f 100644 --- a/src/lib/xms.c +++ b/src/lib/xms.c @@ -82,7 +82,7 @@ void huge * xmsmalloc(long unsigned int size) call [XMSControl] mov [XMSStatus], ax - mov word ptr [XMSPointer], bx + mov word ptr [XMSPointer], bx mov word ptr [XMSPointer+2],dx } diff --git a/src/scroll.c b/src/scroll.c index 45c705ee..68683202 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -75,7 +75,8 @@ void main() { bitmap_t ptmp;//, npctmp; // player sprite const char *cpus; static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */ - int emmhandle; + int emmhandle; + XMOVE mm; page_t screen, screen2, screen3; map_t map; map_view_t mv, mv2, mv3; @@ -88,10 +89,11 @@ void main() { if(isEMS()) printf("%d\n", coretotalEMS()); if(isEMS()) { - emmhandle = alloc_emem(1024); + emmhandle = mallocEMS(coretotalEMS()); mapEMS(emmhandle, 0, 0); - move_emem((XMOVE *)&map); -// printf("%d\n", emmhandle); + //halp! + //move_emem((XMOVE *)&map); + //printf("%d\n", emmhandle); printf("%d\n", coretotalEMS()); } @@ -105,7 +107,8 @@ void main() { /* draw the tiles */ ptr = map.data; /* data */ - ptmp = bitmapLoadPcx("ptmp.pcx"); // load sprite + ptmp = bitmapLoadPcx("ptmp.pcx"); // load sprite + //if(isEMS()) emmmove(emmhandle,ptmp,sizeof(ptmp)+ 1); //npctmp = bitmapLoadPcx("ptmp1.pcx"); // load sprite /* save the palette */ @@ -495,8 +498,10 @@ void main() { //xmsreport(); if(isEMS()) { + printf("%d\n", get_emem()); printf("%d\n", coretotalEMS()); dealloc_emem(emmhandle); + //freeEMS(emmtotal); printf("%d\n", coretotalEMS()); } switch(detectcpu())