Add NES emulator

It's now possible to play classic video game roms with teletypewriters.
https://justine.storage.googleapis.com/nesemu.png
This commit is contained in:
Justine Tunney 2020-07-02 13:46:08 -07:00
parent 4918121810
commit 72b654cb6c
28 changed files with 1888 additions and 79 deletions

29
libc/tinymath/cbrt.S Normal file
View file

@ -0,0 +1,29 @@
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
/ Returns cube root of 𝑥.
/
/ @param %xmm0 holds binary64 number
/ @return %xmm0 holds binary64 result
tinymath_cbrt:
jmp __cbrt
.endfn tinymath_cbrt,globl
.alias tinymath_cbrt,cbrt

View file

@ -11,9 +11,6 @@
*
* Optimized by Bruce D. Evans.
*/
/* cbrt(x)
* Return cube root of x
*/
#include "libc/math.h"
asm(".ident\t\"\\n\\n\
@ -32,7 +29,10 @@ static const double P0 = 1.87595182427177009643, /* 0x3ffe03e6, 0x0f61e692 */
P3 = -0.758397934778766047437, /* 0xbfe844cb, 0xbee751d9 */
P4 = 0.145996192886612446982; /* 0x3fc2b000, 0xd4e4edd7 */
double(cbrt)(double x) {
/**
* Returns cube root of 𝑥.
*/
double __cbrt(double x) {
union {
double f;
uint64_t i;

35
libc/tinymath/cbrtf.S Normal file
View file

@ -0,0 +1,35 @@
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
/ Returns cube root of 𝑥.
/
/ @param %xmm0 holds binary32 number
/ @return %xmm0 holds binary32 result
tinymath_cbrtf:
pushq %rbp
mov %rsp,%rbp
cvtss2sd %xmm0,%xmm0
call __cbrt
cvtsd2ss %xmm0,%xmm0
popq %rbp
ret
.endfn tinymath_cbrtf,globl
.alias tinymath_cbrtf,cbrtf

39
libc/tinymath/cbrtl.S Normal file
View file

@ -0,0 +1,39 @@
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
/ Returns cube root of 𝑥.
/
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result of computation on FPU stack in %st
tinymath_cbrtl:
pushq %rbp
mov %rsp,%rbp
sub $16,%rsp
fldt 16(%rbp)
fstpl -8(%rbp)
movsd -8(%rbp),%xmm0
call __cbrt
movsd %xmm0,-8(%rbp)
fldl -8(%rbp)
leave
ret
.endfn tinymath_cbrtl,globl
.alias tinymath_cbrtl,cbrtl