-
-
Save UAVXP/b1f5497c1bebfb5e82568861665ac149 to your computer and use it in GitHub Desktop.
This file contains 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
-- based on https://github.com/nanochess/fbird | |
return function(cpu) | |
local call=cpu.call | |
local int=cpu.int | |
local status=cpu.status | |
local r8=cpu.r8 | |
local r16=cpu.r16 | |
local data8=cpu.data8 | |
local data16=cpu.data16 | |
local stack8=cpu.stack8 | |
local stack16=cpu.stack16 | |
r16[0]=2 | |
int(16) | |
cpu.f_dir=1 | |
r16[0]=47104 | |
data.offset=r16[0]*16 | |
cpu.seg_e.offset=r16[0]*16 | |
::L7c0d:: | |
r16[7]=4000 | |
r16[0]=status(bit.bxor(r16[0],r16[0]),16) | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=160 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=96 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r16[7]=74 | |
r16[0]=3910 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=45 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=66 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=73 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=82 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=68 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r16[1]=80 | |
repeat | |
r16[4]=r16[4]-2 ; stack16[r16[4]] = r16[1] | |
call(0x7d31) | |
r16[1] = stack16[r16[4]] ; r16[4]=r16[4]+2 | |
r16[1]=r16[1]-1 | |
until not r16[1]~=0 | |
repeat | |
r8[4]=1 | |
int(22) | |
r16[4]=r16[4]-2 ; stack16[r16[4]] = cpu.get_flags() | |
r16[0]=status(bit.bxor(r16[0],r16[0]),16) | |
int(22) | |
cpu.set_flags(stack16[r16[4]]) ; r16[4]=r16[4]+2 | |
until not not cpu.f_zero | |
repeat | |
r8[0]=data8[4008] | |
r8[0]=status(r8[0]+data8[4004],8) | |
data8[4008]=r8[0] | |
r8[0]=status(bit.band(r8[0],248),8) | |
r8[4]=20 | |
r16[0]=r8[0]*r8[4] ; cpu.f_carry = bit.band(0xFF00,r16[0])~=0 ; cpu.f_overflow = cpu.f_carry | |
r16[0]=status(r16[0]+32,16) | |
do local tmp=r16[0] ; r16[0]=r16[7] ; r16[7]=tmp end | |
r8[0]=data8[4012] | |
r8[0]=status(bit.band(r8[0],4),8) | |
if cpu.f_zero then goto L7c76 end | |
r8[0]=data8[r16[7]+-160] | |
data16[r16[7]+-160]=3358 | |
r8[0]=status(r8[0]+data8[r16[7]],8) | |
r8[0]=status(bit.rshift(r8[0],1),8) | |
data16[r16[7]]=3348 | |
goto L7c7c | |
::L7c76:: | |
r8[0]=data8[r16[7]] | |
data16[r16[7]]=3359 | |
::L7c7c:: | |
r8[0]=status(r8[0]+data8[r16[7]+2],8) | |
data16[r16[7]+2]=3344 | |
status(r8[0]- 64,8) | |
if cpu.f_zero then goto L7caf end | |
data8[r16[7]]=42 | |
data8[r16[7]+2]=42 | |
r16[7]=1994 | |
r16[0]=3906 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=79 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=78 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=75 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r8[0]=33 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
r16[1]=100 | |
repeat | |
r16[4]=r16[4]-2 ; stack16[r16[4]] = r16[1] | |
call(0x7ddf) | |
r16[1] = stack16[r16[4]] ; r16[4]=r16[4]+2 | |
r16[1]=r16[1]-1 | |
until not r16[1]~=0 | |
goto L7c0d | |
::L7caf:: | |
call(0x7ddf) | |
r8[0]=data8[4012] | |
r8[0]=status(bit.band(r8[0],7),8) | |
if not cpu.f_zero then goto L7cbd end | |
do local tmp = cpu.f_carry ; data16[4004]=status(data16[4004]+1,16) ; cpu.f_carry = tmp end | |
::L7cbd:: | |
r8[0]=32 | |
data8[r16[7]+-160]=r8[0] | |
data8[r16[7]+2]=r8[0] | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+cpu.f_dir | |
call(0x7d31) | |
call(0x7d31) | |
status(data8[160]- -80,8) | |
if cpu.f_zero then goto L7cd9 end | |
status(data8[162]- -80,8) | |
::L7cd9:: | |
if not cpu.f_zero then goto L7cfc end | |
do local tmp = cpu.f_carry ; data16[4002]=status(data16[4002]+1,16) ; cpu.f_carry = tmp end | |
r16[0]=data16[4002] | |
r16[7]=142 | |
repeat | |
r16[2]=status(bit.bxor(r16[2],r16[2]),16) | |
r16[3]=10 | |
do local tmp1=r16[0]+r16[2]*256 ; local tmp2=r16[3] ; r16[0]=math.floor(tmp1/tmp2) ; r16[2]=tmp1%tmp2 end | |
r16[2]=status(r16[2]+3120,16) | |
do local tmp=r16[0] ; r16[0]=r16[2] ; r16[2]=tmp end | |
cpu.f_dir=-1 | |
cpu.seg_e[r16[7]]=r16[0] ; r16[7]=r16[7]+2*cpu.f_dir | |
data8[r16[7]]=32 | |
cpu.f_dir=1 | |
do local tmp=r16[0] ; r16[0]=r16[2] ; r16[2]=tmp end | |
r16[0]=status(bit.bor(r16[0],r16[0]),16) | |
until not not cpu.f_zero | |
::L7cfc:: | |
r8[4]=1 | |
int(22) | |
if cpu.f_zero then goto L7d31 end | |
r8[4]=0 | |
int(22) | |
status(r8[0]- 27,8) | |
if not cpu.f_zero then goto L7d0c end | |
int(32) | |
::L7d0c:: | |
r16[0]=data16[4008] | |
r16[0]=status(r16[0]- 16,16) | |
status(r16[0]- 8,16) | |
if cpu.f_carry then goto L7d1a end | |
data16[4008]=r16[0] | |
::L7d1a:: | |
data8[4004]=0 | |
r8[0]=182 | |
cpu.output(67,r8[0]) | |
r8[0]=144 | |
cpu.output(66,r8[0]) | |
r8[0]=74 | |
cpu.output(66,r8[0]) | |
r8[0]=cpu.input(97) | |
r8[0]=status(bit.bor(r8[0],3),8) | |
cpu.output(97,r8[0]) | |
::L7d31:: | |
until false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment