Created
June 16, 2024 21:07
-
-
Save kdrnic/0beebab5aca2931bd305eaebb11f6f3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int sinetbl[255] = { | |
130 ,133 ,136 ,139 ,143 ,146 ,149 ,152 ,155 ,158 ,161 ,164 ,167 ,170 ,173 ,176 , | |
179 ,182 ,184 ,187 ,190 ,193 ,195 ,198 ,200 ,203 ,205 ,208 ,210 ,213 ,215 ,217 , | |
219 ,221 ,224 ,226 ,228 ,229 ,231 ,233 ,235 ,236 ,238 ,239 ,241 ,242 ,244 ,245 , | |
246 ,247 ,248 ,249 ,250 ,251 ,251 ,252 ,253 ,253 ,254 ,254 ,254 , | |
254 ,254 ,255 ,254 ,254 ,254 ,254 ,254 ,253 ,253 ,252 ,251 ,251 ,250 ,249 ,248 , | |
247 ,246 ,245 ,244 ,242 ,241 ,239 ,238 ,236 ,235 ,233 ,231 ,229 ,228 ,226 ,224 , | |
221 ,219 ,217 ,215 ,213 ,210 ,208 ,205 ,203 ,200 ,198 ,195 ,193 ,190 ,187 ,184 , | |
182 ,179 ,176 ,173 ,170 ,167 ,164 ,161 ,158 ,155 ,152 ,149 ,146 ,143 ,139 ,136 , | |
133 ,130 ,127 ,124 ,121 ,118 ,115 ,111 ,108 ,105 ,102 ,99 ,96 ,93 ,90 ,87 , | |
84 ,81 ,78 ,75 ,72 ,70 ,67 ,64 ,61 ,59 ,56 ,54 ,51 ,49 ,46 ,44 , | |
41 ,39 ,37 ,35 ,33 ,30 ,28 ,26 ,25 ,23 ,21 ,19 ,18 ,16 ,15 ,13 , | |
12 ,10 ,9 ,8 ,7 ,6 ,5 ,4 ,3 ,3 ,2 ,1 ,1 ,0 ,0 ,0 , | |
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,2 ,3 ,3 ,4 ,5 ,6 , | |
7 ,8 ,9 ,10 ,12 ,13 ,15 ,16 ,18 ,19 ,21 ,23 ,25 ,26 ,28 ,30 , | |
33 ,35 ,37 ,39 ,41 ,44 ,46 ,49 ,51 ,54 ,56 ,59 ,61 ,64 ,67 ,70 , | |
72 ,75 ,78 ,81 ,84 ,87 ,90 ,93 ,96 ,99 ,102 ,105 ,108 ,111 ,115 ,118 , | |
121 ,124 , | |
}; | |
void printhello(void) | |
{ | |
char *hello = "Hello World!\r\n$"; | |
_asm { | |
mov ah, 9 | |
mov dx, hello | |
int 0x21 | |
} | |
} | |
#pragma aux mode13h =\ | |
"mov ax, 13h"\ | |
"int 10h"\ | |
modify [ ax ]; | |
#pragma aux modetext =\ | |
"mov ax, 03h"\ | |
"int 10h"\ | |
modify [ ax ]; | |
#pragma aux palstart =\ | |
"mov dx,3C8h"\ | |
"xor al,al"\ | |
"out dx,al"\ | |
modify [dx ax]; | |
#pragma aux palup =\ | |
"mov dx,3C9h"\ | |
"out dx,al"\ | |
modify [dx]\ | |
parm caller [ax]; | |
#pragma aux cpp =\ | |
"push A000h"\ | |
"pop es"\ | |
"mov di,bx"\ | |
"stosb " \ | |
parm caller [ax bx]\ | |
modify [ax bx es di]; | |
void mode13h(void); | |
void modetext(void); | |
void palstart(void); | |
void palup(int); | |
void cpp(unsigned,unsigned); | |
int __watcall asmkp(void); | |
void __watcall asmpp(unsigned, unsigned); | |
int main(void) | |
{ | |
mode13h(); | |
palstart(); | |
for(int i=0; i < 256; i++){ | |
palup((i>>2)&0); | |
palup((i>>2)&0); | |
palup((i>>2)); | |
} | |
for(unsigned int j = 0; !asmkp(); j+=9){ | |
for(unsigned int y=0; y<200; y++){ | |
for(unsigned int x=0; x<320; x++){ | |
unsigned int col = y; | |
asmpp(col,x+y*320); | |
} | |
} | |
} | |
modetext(); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC = wcc | |
AS = nasm | |
#-0 8086 instructions | |
#-1 186 instructions | |
#-2 286 instructions | |
#-3 386 instructions | |
#-4 386 instructions, optimize for 486 | |
#-5 386 instructions, optimize for Pentium | |
#-6 386 instructions, optimize for Pentium Pro | |
CFLAGS += -3 | |
#-b{c,d,g,m,w} Application type | |
# c - build target is a console application | |
# d - build target is a dynamic link library (DLL) | |
# g - build target is a GUI application | |
# m - build target is a multi-thread environment | |
# w - build target is a default windowing application | |
CFLAGS += -bc | |
#-bt[=<os>] build target is operating system <os> | |
CFLAGS += -bt=dos | |
#-o{a,b,c,d,e[=<num>],f,f+,h,i,k,l,l+,m,n,o,p,r,s,t,u,x,z} | |
# a - relax aliasing constraints | |
# b - enable branch prediction | |
# c - disable <call followed by return> to <jump> optimization | |
# d - disable all optimizations | |
# e[=<num>] - expand user functions inline (<num> controls max size) | |
# f - generate traceable stack frames as needed | |
# f+ - always generate traceable stack frames | |
# h - enable expensive optimizations (longer compiles) | |
# i - expand intrinsic functions inline | |
# k - include prologue/epilogue in flow graph | |
# l - enable loop optimizations | |
# l+ - enable loop unrolling optimizations | |
# m - generate inline code for math functions | |
# n - allow numerically unstable optimizations | |
# o - continue compilation if low on memory | |
# p - generate consistent floating-point results | |
# r - reorder instructions for best pipeline usage | |
# s - favor code size over execution time in optimizations | |
# t - favor execution time over code size in optimizations | |
# u - all functions must have unique addresses | |
# x - equivalent to -obmiler -s | |
# z - NULL points to valid memory in the target environment | |
CFLAGS += -obe9hmil+t | |
#-q operate quietly (display only error messages) | |
CFLAGS += -q | |
#-s remove stack overflow checks | |
CFLAGS += -s | |
#-w{=<num>,cd=<num>,ce=<num>,e,o,x} | |
# =<num> - set warning level number | |
# cd=<num> - disable warning message <num> | |
# ce=<num> - enable warning message <num> | |
# e - treat all warnings as errors | |
# o - warn about problems with overlaid code | |
# x - set warning level to maximum setting | |
CFLAGS += -wx | |
#-zl remove default library information | |
#CFLAGS += -zl | |
#-m{c,h,l,m,s} Memory model | |
# c - compact - small code/large data | |
# h - huge - large code/huge data | |
# l - large - large code/large data | |
# m - medium - large code/small data | |
# s - small - small code/small data (defaul) | |
CFLAGS += -ms | |
#-aa allow non const initializers for local aggregates or unions | |
CFLAGS += -aa | |
CFLAGS += -za99 | |
OBJDIR=obj | |
H__FILES=$(wildcard src/*.h) | |
ASMFILES = $(wildcard src/*.asm) | |
C__FILES = $(wildcard src/*.c) | |
ASMOBJ = $(patsubst src/%,$(OBJDIR)/%,$(patsubst %.asm,%.obj,$(ASMFILES))) | |
C__OBJ = $(patsubst src/%,$(OBJDIR)/%,$(patsubst %.c,%.obj,$(C__FILES))) | |
OBJECTS = $(ASMOBJ) $(C__OBJ) | |
LINK_FLAGS += system dos | |
LINK_FLAGS += option map | |
#LINK_FLAGS += option nodefaultlibs | |
LINK_FLAGS += option quiet | |
all: game.exe | |
$(OBJDIR)/%.obj: src/%.c $(H__FILES) | |
#$(CC) $(CFLAGS) -fo=$@ $< | |
#Fix slash issue | |
$(CC) $(CFLAGS) -fo=$(subst /,\,$@) $(subst /,\,$<) | |
$(OBJDIR)/%.obj: src/%.asm | |
$(AS) -f obj -o $@ $< | |
$(OBJDIR): | |
mkdir $(OBJDIR) | |
game.exe: $(OBJDIR) $(OBJECTS) | |
wlink $(LINK_FLAGS) name $@ $(foreach f,$(OBJECTS),file $(f)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global asmkp_ | |
global asmpp_ | |
; Code Segment (16-bit code) | |
segment _TEXT use16 class=CODE | |
asmkp_: | |
push bx | |
push cx | |
push dx | |
mov ax,0 | |
mov ah,0Bh | |
int 21h | |
or al,al | |
mov ax,0 | |
jz .ret | |
mov ax,1 | |
.ret: | |
pop bx | |
pop cx | |
pop dx | |
ret | |
asmpp_: | |
push ebp | |
mov ebp, esp | |
pushf | |
push eax | |
push ebx | |
push ecx | |
push edx | |
push edi | |
push es | |
push 0xA000 | |
pop es | |
mov di,bx | |
stosb | |
pop es | |
pop edi | |
pop edx | |
pop ecx | |
pop ebx | |
pop eax | |
popf | |
pop ebp | |
ret | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment