Further compilation fix to 2013/cable3
Whereas in earlier versions of macOS my previous changes let it compile
in at least the most recent version, macOS 14 (Sonoma), it did not due
to the same problem of localtime(). The prototype has been removed
entirely to solve the problem.
The runme script no longer assumes that the program was compiled,
running first:
make clobber all || exit 1
I partly formatted the README.md file. I will have to finish this file
and continue to the rest of 2013 another time.
One thing of importance (I feel) that I did add is that I put at the top
that to quit the emulator one should type QUITEMU as this was buried
deep in the remarks.
This commit is contained in:
1 parent
b893db6bc2
commit
88d566e985
4 files changed
+125
-41
No files matched your search
+110
-37
@@ -24,6 +24,8 @@ make
|
||||
./runme
|
||||
```
|
||||
|
||||
NOTE: to quit the program type `QUITEMU`.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
@@ -35,96 +37,167 @@ transistors used to implement the original 8086 CPU.
|
||||
If you are using macOS, the included sc-ioccc.terminal configuration file will
|
||||
correctly display console applications that use ANSI graphics.
|
||||
|
||||
Update: This entry now has its own web page <http://www.megalith.co.uk/8086tiny>
|
||||
Update: This entry now has its own website:
|
||||
<https://github.com/adriancable/8086tiny>
|
||||
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
### A tiny but highly functional PC emulator/virtual machine
|
||||
|
||||
The author hereby presents, for the delectation (?) of the judges, a portable PC emulator/VM written specifically for the IOCCC which runs DOS, Windows 3.0, Excel, MS Flight Simulator, AutoCAD, Lotus 1-2-3 ...
|
||||
The author hereby presents, for the delectation (?) of the judges, a portable PC
|
||||
emulator/VM written specifically for the IOCCC which runs DOS, Windows 3.0,
|
||||
Excel, MS Flight Simulator, AutoCAD, Lotus 1-2-3 ...
|
||||
|
||||
In just 4043 bytes of C source, you get a complete mid-late 1980s-era IBM-compatible PC, consisting of:
|
||||
In just 4043 bytes of C source, you get a complete mid-late 1980s-era
|
||||
IBM-compatible PC, consisting of:
|
||||
|
||||
- Intel 8086/186 CPU
|
||||
- 1MB RAM
|
||||
- 8072A 3.5" floppy disk controller (1.44MB/720KB)
|
||||
- Fixed disk controller (supports a single hard drive up to 528MB)
|
||||
- Hercules graphics card with 720x348 2-color graphics (64KB video RAM), and CGA 80x25 16-color text mode support
|
||||
- Hercules graphics card with 720x348 2-color graphics (64KB video RAM), and CGA
|
||||
80x25 16-color text mode support
|
||||
- 8253 programmable interval timer (PIT)
|
||||
- 8259 programmable interrupt controller (PIC)
|
||||
- 8042 keyboard controller with 83-key XT-style keyboard
|
||||
- MC146818 real-time clock
|
||||
- PC speaker
|
||||
|
||||
The emulator uses the SDL graphics library for portability, and compiles for Windows, Mac OS X, Linux and probably most other 32-bit/64-bit systems too.
|
||||
The emulator uses the SDL graphics library for portability, and compiles for
|
||||
Windows, macOS, Linux and probably most other 32-bit/64-bit systems too.
|
||||
|
||||
If you like living on the edge you can try building the emulator on a big endian machine, and you will get an emulation of a big endian 8086, a rather bizarre and somewhat useless beast. For everyone else, please run the emulator on a little endian machine.
|
||||
If you like living on the edge you can try building the emulator on a big endian
|
||||
machine, and you will get an emulation of a big endian 8086, a rather bizarre
|
||||
and somewhat useless beast. For everyone else, please run the emulator on a
|
||||
little endian machine.
|
||||
|
||||
*RULE 2 ABUSE DISCLAIMER*
|
||||
|
||||
- cable3.c is 4043 bytes in length (half an 8086)
|
||||
- iocccsize -i < cable3.c returns 1977 (the year the 4.77 MHz 8086 CPU was announced)
|
||||
- `cable3.c` is 4043 bytes in length (half an 8086)
|
||||
- `iocccsize -i < cable3.c` returns 1977 (the year the 4.77 MHz 8086 CPU was announced)
|
||||
- Therefore, any suspicions the judges may have regarding rule 2 non-compliance may be well-intentioned but are groundless.
|
||||
- Nonetheless, the author would like to apologise to the judges for the one-big-block-of-code nature of this entry, which turned out to be unavoidable. Hopefully the joys of this entry will make up for its shortcomings.
|
||||
- Nonetheless, the author would like to apologise to the judges for the
|
||||
one-big-block-of-code nature of this entry, which turned out to be unavoidable.
|
||||
Hopefully the joys of this entry will make up for its shortcomings.
|
||||
|
||||
*/RULE 2 ABUSE DISCLAIMER*
|
||||
|
||||
### Why is this entry obfuscated/interesting?
|
||||
|
||||
- First of all the 8086 is a nightmare processor to emulate. Instruction codings are complex and irregular in size and structure, with multiple addressing modes and no consistent memory placement for operands, very often multiple possible encodings for the same instruction, and the bizarre segment:offset memory model. In addition, the 8086 has a number of bugs (e.g. PUSH SP), undocumented behaviours and instructions (e.g. AAM/AAD + imm8, SALC, flag behaviour for MUL/DIV, etc. etc.), and archaic features (e.g. parity/auxiliary flags) which all need to be emulated properly. Here we emulate every feature of the CPU pretty exactly (in fact better than most commercial clones of the processor e.g. the NEC V30), with the exception of the trap flag which no real software uses except for debuggers (although support for the TF can be added if deemed important, without exceeding the IOCCC size limit).
|
||||
- In addition to the CPU we also emulate all the standard PC peripheral hardware. Parts of it are somewhat complete, much is rather dysfunctional (like the 8253/8259) but enough to support most real software.
|
||||
- Nonetheless the source, while large for the IOCCC, is rather tiny for a functional PC emulator - around 2% of the size of the source of other open-source 8086 PC emulators with comparable functionality.
|
||||
- In fact, this entry is just like happy hour - at 4043 bytes long, you pay for half the 8086, but you get served the whole one.
|
||||
- Getting the code down to <= 4096 characters to meet the IOCCC rule 2 overall size limit required a good deal of effort (and appreciable risk of divorce), with obfuscation being a pretty unavoidable consequence in most places ... for the rest, I use short circuit operators whenever possible, mix x[y] and y[x], don't use any flow control keywords except for for, use K&R-style declarations to honor the C language's rich cultural heritage (plus it saves a byte), and occasionally go overboard with nasty nested indexes to give things like this: --64[T=1[O=32[L=(X=*Y&7)&1,o=X/2&1,l]=0,t=(c=y)&7,a=c/8&7,Y]>>6,g=~-T?y:(n)y,d=BX=y,l]
|
||||
- First of all the 8086 is a nightmare processor to emulate. Instruction codings
|
||||
are complex and irregular in size and structure, with multiple addressing modes
|
||||
and no consistent memory placement for operands, very often multiple possible
|
||||
encodings for the same instruction, and the bizarre segment:offset memory model.
|
||||
In addition, the 8086 has a number of bugs (e.g. PUSH SP), undocumented
|
||||
behaviours and instructions (e.g. AAM/AAD + imm8, SALC, flag behaviour for
|
||||
MUL/DIV, etc. etc.), and archaic features (e.g. parity/auxiliary flags) which
|
||||
all need to be emulated properly. Here we emulate every feature of the CPU
|
||||
pretty exactly (in fact better than most commercial clones of the processor e.g.
|
||||
the NEC V30), with the exception of the trap flag which no real software uses
|
||||
except for debuggers (although support for the TF can be added if deemed
|
||||
important, without exceeding the IOCCC size limit).
|
||||
- In addition to the CPU we also emulate all the standard PC peripheral
|
||||
hardware. Parts of it are somewhat complete, much is rather dysfunctional (like
|
||||
the 8253/8259) but enough to support most real software.
|
||||
- Nonetheless the source, while large for the IOCCC, is rather tiny for a
|
||||
functional PC emulator - around 2% of the size of the source of other
|
||||
open-source 8086 PC emulators with comparable functionality.
|
||||
- In fact, this entry is just like happy hour - at 4043 bytes long, you pay for
|
||||
half the 8086, but you get served the whole one.
|
||||
- Getting the code down to <= 4096 characters to meet the IOCCC rule 2 overall
|
||||
size limit required a good deal of effort (and appreciable risk of divorce),
|
||||
with obfuscation being a pretty unavoidable consequence in most places ... for
|
||||
the rest, I use short circuit operators whenever possible, mix `x[y]` and `y[x]`,
|
||||
don't use any flow control keywords except for `for`, use K&R-style declarations
|
||||
to honor the C language's rich cultural heritage (plus it saves a byte), and
|
||||
occasionally go overboard with nasty nested indexes to give things like this:
|
||||
`--64[T=1[O=32[L=(X=*Y&7)&1,o=X/2&1,l]=0,t=(c=y)&7,a=c/8&7,Y]>>6,g=~-T?y:(n)y,d=BX=y,l]`.
|
||||
- This entry highlights the importance of comments in C.
|
||||
- This entry might result in an adjustment to the IOCCC size tool for the 2014 competition (see above).
|
||||
- This entry might result in an adjustment to the IOCCC size tool for the 2014
|
||||
competition (see above).
|
||||
|
||||
### Compiling on different platforms
|
||||
|
||||
This entry has been tested on Windows (compiled with MS Visual Studio 2010 and 2013), Mac OS X (clang and gcc), and Linux (clang and gcc). The Makefile supplied is good for Mac OS X, Linux and probably other UNIXes. I have received reports that the emulator works on Raspberry Pi/Android/ARM (you will need to compile with -fsigned-char) and iOS. You will need to adjust the Makefile if your system lacks sdl-config to correctly point to the SDL libraries and header files.
|
||||
This entry has been tested on Windows (compiled with MS Visual Studio 2010 and
|
||||
2013), Mac OS X (clang and gcc), and Linux (clang and gcc). The Makefile
|
||||
supplied is good for Mac OS X, Linux and probably other UNIXes. I have received
|
||||
reports that the emulator works on Raspberry Pi/Android/ARM (you will need to
|
||||
compile with -fsigned-char) and iOS. You will need to adjust the Makefile if
|
||||
your system lacks sdl-config to correctly point to the SDL libraries and header
|
||||
files.
|
||||
|
||||
On UNIX-based systems we can get raw keystrokes using stty. However Windows has no stty. Therefore the Makefile includes a -D entry to define a "keyboard driver" KB which as it stands is suitable for UNIXes, but maybe not non-UNIX platforms. For example, for Windows/MS Visual Studio, instead of the Makefile definition of KB, use something slightly different - add the following entry to the Preprocessor Definitions list in the Project Properties page:
|
||||
On UNIX-based systems we can get raw keystrokes using `stty`. However Windows
|
||||
has no `stty`. Therefore the Makefile includes a `-D` option to define a
|
||||
`"keyboard driver"` KB which as it stands is suitable for UNIXes, but maybe not
|
||||
non-UNIX platforms. For example, for Windows/MS Visual Studio, instead of the
|
||||
Makefile definition of KB, use something slightly different - add the following
|
||||
entry to the Preprocessor Definitions list in the Project Properties page:
|
||||
|
||||
KB=(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
|
||||
```c
|
||||
KB=(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
|
||||
```
|
||||
|
||||
### POSIX portability note
|
||||
|
||||
The code as supplied uses implicit function declarations for POSIX file I/O and in doing so assumes that file offsets are the same bit width as your architecture. For some systems (e.g. 32-bit Mac OS X, which uses 64-bit file offsets) this is not the case, and to run successfully on these systems, you will need to explicitly declare these functions by adding the appropriate include to the top of the source:
|
||||
The code as supplied uses implicit function declarations for POSIX file I/O and
|
||||
in doing so assumes that file offsets are the same bit width as your
|
||||
architecture. For some systems (e.g. 32-bit Mac OS X, which uses 64-bit file
|
||||
offsets) this is not the case, and to run successfully on these systems, you
|
||||
will need to explicitly declare these functions by adding the appropriate
|
||||
include to the top of the source:
|
||||
|
||||
#include <unistd.h>
|
||||
```c
|
||||
#include <unistd.h>
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
||||
```sh
|
||||
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
||||
```
|
||||
|
||||
PLEASE NOTE that under UNIXes the keyboard must be in raw mode for the emulator to work properly. Therefore the emulator is best run from a shell script that looks something like:
|
||||
PLEASE NOTE that under UNIXes the keyboard must be in raw mode for the emulator
|
||||
to work properly. Therefore the emulator is best run from a shell script that
|
||||
looks something like:
|
||||
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios floppy.img harddisk.img
|
||||
stty cooked echo
|
||||
```sh
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios floppy.img harddisk.img
|
||||
stty cooked echo
|
||||
```
|
||||
|
||||
See the [runme](runme) script.
|
||||
|
||||
## To run the emulator - floppy mode only
|
||||
|
||||
The simplest use of the emulator is with a single floppy boot disk image, like the fd.img provided, which is a FreeDOS boot disk.
|
||||
The simplest use of the emulator is with a single floppy boot disk image, like
|
||||
the fd.img provided, which is a FreeDOS boot disk.
|
||||
|
||||
Before running the emulator on a Unix-type system, stty needs to be used to put the keyboard into raw mode (and afterwards it needs to be put back to cooked). So, run the emulator using something like this script (provided as "runme"):
|
||||
Before running the emulator on a Unix-type system, `stty` needs to be used to
|
||||
put the keyboard into raw mode (and afterwards it needs to be put back to
|
||||
cooked). So, run the emulator using something like this script (provided as
|
||||
[runme](runme)):
|
||||
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img
|
||||
stty cooked echo
|
||||
```sh
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img
|
||||
stty cooked echo
|
||||
```
|
||||
|
||||
## To run the emulator - floppy + HD mode
|
||||
|
||||
Easiest to start with is to try a ready-made 40MB hard disk image containing a whole bunch of software:
|
||||
Easiest to start with is to try a ready-made 40MB hard disk image containing a
|
||||
whole bunch of software: <http://bitly.com/1bU8URK>
|
||||
|
||||
<http://bitly.com/1bU8URK>
|
||||
For the more adventurous, you can start off with (for example) a blank 40MB
|
||||
image file called hd.img made using e.g. mkfile. Then use:
|
||||
|
||||
For the more adventurous, you can start off with (for example) a blank 40MB image file called hd.img made using e.g. mkfile. Then use:
|
||||
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img hd.img
|
||||
stty cooked echo
|
||||
```sh
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img hd.img
|
||||
stty cooked echo
|
||||
```
|
||||
|
||||
Preparing the hard disk for use in the emulator is done just like a real PC. Boot the emulator, and use FDISK to partition the hard disk. When it's done FDISK will reboot the emulator. Then you can use FORMAT C: and you are done. The resulting disk image is in the right format to be mounted on a real Windows PC using e.g. OSFMount, on a Mac using hdiutil, or on Linux using mount, providing an easy way to copy files and programs to and from the disk image. Or, you can install programs from regular floppy disk images (see "Floppy disk support" below).
|
||||
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
#define n char
|
||||
#define e(_)v(F(40[L(_##=40[E]+),E]&N==S|_ N<_(int)S))
|
||||
|
||||
I n t,e,l[80186],*E,m,u,L,a,T,o,r[1<<21],X,*Y,b,Q,R;I Z*i,M,p,q=3;I*localtime(),f,S,kb,h,W,U,c,g,d,V,A;N,O,P=983040,j[5];SDL_Surface*k;i(F,40[E]=!!o)i(z,42[E]=!!o)i(D,r[a(I)E[259+4*o]+O])i(w,i[o]+=~(-2*47[E])*~L)i(v,G(N-S&&1&(40[z((f^=S^N)&16),E]^f>>C-1)))J(){V=61442;$;O--;)V+=40[E+O]<<D(25);}i(H,(46[u=76,J(),T(V),T(9[i]),T(M),M(P+18,=,4*o+2),R(M,=,r[4*o]),E]=0))s(o){$;O--;)40[E+O]=1&&1<<D(25)&o;}i(BP,(*i+=262*o*z(F((*E&15)>9|42[E])),*E&=15))i(SP,(w(7),R&&--1[i]&&o?R++,Q&&Q++,M--:0))DX(){$,O*=27840;O--;)O[(I*)k->pixels]=-!!(1<<7-O%8&r[O/2880*90+O%720/8+(88+952[l]/128*4+O/720%4<<13)]);SDL_Flip(k);}main(BX,nE)n**nE;{9[i=E=r+P]=P>>4;$;q;)j[--q]=*++nE?open(*nE,32898):0;read(2[a(I)*i=*j?lseek(*j,0,2)>>9:0,j],E+(M=256),P);$;Y=r+16*9[i]+M,Y-r;Q|R||kb&46[E]&&KB)--64[T=1[O=32[L=(X=*Y&7)&1,o=X/2&1,l]=0,t=(c=y)&7,a=c/8&7,Y]>>6,g=~-T?y:(n)y,d=BX=y,l],!T*t-6&&T-2?T-1?d=g:0:(d=y),Q&&Q--,R&&R--x(O=*Y,O=u=D(51),e=D(8),m=D(14)_ O=*Y/2&7,M+=(n)c*(L^(D(m)[E]|D(22)[E]|D(23)[E]^D(24)[E]))_ L=*Y&8,R(K(X)[r],=,c)_ L=e+=3,o=0,a=X x a=m _ T(X[i])_ A(X[i])_ a<2?M(U,+=1-2*a+,P+24),v(f=1),G(S+1-a==1<<C-1),u=u&4?19:57:a-6?CX+2,a-3||T(9[i]),a&2&&T(M),a&1&&M(P+18,=,U+2),R(M,=,U[r]),u=67:T(h[r])_(W=U B u=m,M-=~L,R(W[r],&,d)B 0 B L(=~)B L(=-),S=0,u=22,F(N>S)B L?c(I Z,i):c(I n,E)B/**/L?c(Z,i):c(n,E)B L?V(I Z,I,i):V(I n,I Z,E)B L?V(Z,int,i):V(n,Z,E))_++e,h=P,d=c,T=3,a=m,M--_++e,13[W=h,i]=(o|=!L)?(n)d:d,U=P+26,M-=~!o,u=17+(m=a)_(a=m B L(+=),F(N<S)B L(|=)B e(+)B e(-)B L(&=)B L(-=),F(N>S)B L(^=)B L(-),F(N>S)B L(=))_!L?L=a+=8 x L(=):!o?Q=1,R(r[p=m x V],=,h):A(h[r])_ T=a=0,t=6,g=c x M(U,=,W)_(A=h(h[r]),V=m?++M,(n)g:o?31&2[E]:1)&&(a<4?V%=a/2+C,R(A,=,h[r]):0,a&1?R(h[r],>>=,V):R(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(Q?p:m,3,*E+)]_ m[E]^=1 _ E[m/2]=m&1 _ R(*E,&,c)_(a=c B write(1,E,1)B time(j+3),memcpy(r+u(8,3,),localtime(j+3),m)),a<2?*E=~lseek(O=4[E][j],a(I)5[i]<<9,0)?((I(*)())(a?write:read))(O,r+u(8,3,),*i):0:0),O=u,D(16)?v(0):D(17)&&G(F(0)),CX*D(20)+D(18)-D(19)*~!!L,D(15)?O=m=N,41[43[44[E]=h(N),E]=!N,E]=D(50):0,!++q?kb=1,*l?SDL_PumpEvents(),k=k?k:SDL_SetVideoMode(720,348,32,0),DX():k?SDL_Quit(),k=0:0:0;}i(G,48[E]=o)i(K,P+(L?2*o:2*o+o/4&7))
|
||||
I n t,e,l[80186],*E,m,u,L,a,T,o,r[1<<21],X,*Y,b,Q,R;I Z*i,M,p,q=3;I f,S,kb,h,W,U,c,g,d,V,A;N,O,P=983040,j[5];SDL_Surface*k;i(F,40[E]=!!o)i(z,42[E]=!!o)i(D,r[a(I)E[259+4*o]+O])i(w,i[o]+=~(-2*47[E])*~L)i(v,G(N-S&&1&(40[z((f^=S^N)&16),E]^f>>C-1)))J(){V=61442;$;O--;)V+=40[E+O]<<D(25);}i(H,(46[u=76,J(),T(V),T(9[i]),T(M),M(P+18,=,4*o+2),R(M,=,r[4*o]),E]=0))s(o){$;O--;)40[E+O]=1&&1<<D(25)&o;}i(BP,(*i+=262*o*z(F((*E&15)>9|42[E])),*E&=15))i(SP,(w(7),R&&--1[i]&&o?R++,Q&&Q++,M--:0))DX(){$,O*=27840;O--;)O[(I*)k->pixels]=-!!(1<<7-O%8&r[O/2880*90+O%720/8+(88+952[l]/128*4+O/720%4<<13)]);SDL_Flip(k);}main(BX,nE)n**nE;{9[i=E=r+P]=P>>4;$;q;)j[--q]=*++nE?open(*nE,32898):0;read(2[a(I)*i=*j?lseek(*j,0,2)>>9:0,j],E+(M=256),P);$;Y=r+16*9[i]+M,Y-r;Q|R||kb&46[E]&&KB)--64[T=1[O=32[L=(X=*Y&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^F(h(S<<V-1)))B G(h(S))B 0 B V<C||F(A),G(0),R(h[r],+=,A*=~((1<<C)-1>>V)))_(V=!!--1[a=X,i]B V&=!m[E]B V&=m[E]B 0 B V=!++1[i]),M+=V*(n)c _ M+=3-o,L?0:o?9[M=0,i]=BX:T(M),M+=o*L?(n)c:c _ M(U,&,W)_ L=e+=8,W=P,U=K(X)_!R||1[i]?M(m<2?u(8,7,):P,=,m&1?P:u(Q?p:11,6,)),m&1||w(6),m&2||SP(1):0 _!R||1[i]?M(m?P:u(Q?p:11,6,),-,u(8,7,)),43[u=92,E]=!N,F(N>S),m||w(6),SP(!N==b):0 _ o=L,A(M),m&&A(9[i]),m&2?s(A(V)):o||(4[i]+=c)_ R(U[r],=,d)_ 986[l]^=9,R(*E,=,l[m?2[i]:(n)c])_ R(l[m?2[i]:(n)c],=,*E)_ R=2,b=L,Q&&Q++_ W-U?L(^=),M(U,^=,W),L(^=):0 _ T(m[i])_ A(m[i])_ Q=2,p=m,R&&R++_ L=0,O=*E,F(D(m+=3*42[E]+6*40[E])),z(D(1+m)),N=*E=D(m-1)_ N=BP(m-1)_ 1[E]=-h(*E)_ 2[i]=-h(*i)_ 9[T(9[i]),T(M+5),i]=BX,M=c _ J(),T(V)_ s(A(V))_ J(),s((V&~m)+1[E])_ J(),1[E]=V _ L=o=1 x L(=),M(P+m,=,h+2)_++M,H(3)_ M+=2,H(c&m)_++M,m[E]&&H(4)_(c&=m)?1[E]=*E/c,N=*E%=c:H(0)_*i=N=m&E[L=0]+c*1[E]_*E=-m[E]_*E=r[u(Q?p:m,3,*E+)]_ m[E]^=1 _ E[m/2]=m&1 _ R(*E,&,c)_(a=c B write(1,E,1)B time(j+3),memcpy(r+u(8,3,),localtime(j+3),m)),a<2?*E=~lseek(O=4[E][j],a(I)5[i]<<9,0)?((I(*)())(a?write:read))(O,r+u(8,3,),*i):0:0),O=u,D(16)?v(0):D(17)&&G(F(0)),CX*D(20)+D(18)-D(19)*~!!L,D(15)?O=m=N,41[43[44[E]=h(N),E]=!N,E]=D(50):0,!++q?kb=1,*l?SDL_PumpEvents(),k=k?k:SDL_SetVideoMode(720,348,32,0),DX():k?SDL_Quit(),k=0:0:0;}i(G,48[E]=o)i(K,P+(L?2*o:2*o+o/4&7))
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
make clobber all || exit 1
|
||||
clear
|
||||
stty cbreak raw -echo min 0
|
||||
if [ -f hd.img ]
|
||||
|
||||
+13
-3
@@ -1584,10 +1584,20 @@ Cody fixed this to compile with modern systems. The problems were that
|
||||
`localtime()` is used differently and `time.h` being included (with SDL2 in
|
||||
macOS - but see below) there was a conflicting function type. This appeared to
|
||||
be a problem with macOS and only when SDL2 was included (but which as noted next
|
||||
it cannot be). The other problem is that this entry uses SDL functions that were
|
||||
it cannot be).
|
||||
|
||||
The other problem is that this entry uses SDL functions that were
|
||||
removed from SDL2 so the Makefile has to use `sdl-config` and not `sdl2-config`.
|
||||
This means that to be strictly technical, the removal of `localtime()` is not
|
||||
necessary but this change was left in place anyway.
|
||||
This meant that at one point to be strictly technical, the removal of
|
||||
`localtime()` wasn't necessary but this change was left in place anyway.
|
||||
|
||||
Later on in an updated macOS (problem discovered in macOS Sonoma) the entry
|
||||
failed to compile again also due to `localtime()` so the prototype was
|
||||
completely removed to solve the problem.
|
||||
|
||||
He also slightly improved the `runme` script to not assume that the program has
|
||||
been compiled by running `make clobber all || exit 1`.
|
||||
|
||||
|
||||
## [2013/hou](2013/hou/hou.c) ([README.md](2013/hou/README.md))
|
||||
|
||||
|
||||
Reference in new issue
Block a user