Skip to content

Instantly share code, notes, and snippets.

@kg68k
kg68k / pth_errno.c
Created November 4, 2025 15:45
errnoがスレッド独立か確認する
// print errno
//
// build: m68k-xelf-gcc -Wall -Wextra -O2 pth_errno.c -lpthread
#include <errno.h>
#include <stdio.h>
#include <pthread.h>
static void* thread_start_routine(__attribute__((unused)) void* data) {
errno = 0;
@kg68k
kg68k / print_reent.c
Created November 4, 2025 15:28
print newlib struct _reent address
// print newlib struct _reent address
//
// build: m68k-xelf-gcc -Wall -Wextra -O2 print_reent.c -lpthread
#include <reent.h>
#include <stdio.h>
#include <pthread.h>
#define S(x) #x
#define T(x) S(x)
@kg68k
kg68k / mpo.opm
Created September 21, 2025 19:02
OPMDRV3.X チャンネルの割り当てモードの違いで鳴る音が違う
(i)
(/MPO)
(m1,1000)
(a18,1)
(t1) @1 [DO] crdrerfr [LOOP]
(p)
@kg68k
kg68k / iasm.c
Created September 13, 2025 11:22
GCCインラインアセンブラの引数渡しの方法による出力コードの違いの検証
int A_iocs_b_intvcs (int vector, int addr)
{
register unsigned int reg_d0 __asm ("d0");
__asm __volatile (
"move.l %1,d1\n\t"
"movea.l %2,a1\n\t"
"moveq.l #0x80,%0\n\t"
"trap #15"
: "=d" (reg_d0)
@kg68k
kg68k / c4.c
Created August 9, 2025 17:35
GVRAM fast clear sample based on Inside X68000 p.245 C4.C
// GVRAM fast clear sample
//
// based on Inside X68000 p.245 C4.C
#define __IOCS_INLINE__
#include <stdio.h>
#include <sys/iocs.h>
short *vram;
@kg68k
kg68k / killmouse.s
Created July 31, 2025 17:04
X68000のマウスにデータ送信を指示しないようにする(Kamadaさん作)
;https://x.com/kamadox/status/1950514362780991943
.include doscall.mac
clr.l -(sp)
DOS _SUPER
move.l d0,(sp)
lea $00FF0000,a0
@@: cmpi.w #$4E75,(a0)+ ;rtsを探す
bne @b
subq.l #2,a0
@kg68k
kg68k / isf0.c
Created July 18, 2025 17:38
IOCS _OPMDRVが有効になっているか調べる
#include <stdio.h>
#define __DOS_INLINE__
#include <sys/dos.h>
#define IOCS_OPMDRV 0xf0
int is_opmdrv_installed(void* vec) {
unsigned int v = (unsigned int)vec;
@kg68k
kg68k / pth_mutex.c
Created July 12, 2025 21:48
pthread mutex init/lock/unlock benchmark
// pthread mutex init/lock/unlock benchmark
// by TcbnErik
// Last-modified: 2025-07-13
// Copying and distribution of this file, with or without modification,
// are permitted in any medium without royalty provided the copyright
// notice and this notice are preserved. This file is offered as-is,
// without any warranty.
@kg68k
kg68k / must_err.py
Created May 29, 2025 15:25
micropython-x68k v1.21.0-x68k-1.5 インラインアセンブラ機能のテストケース
import x68k
@micropython.asm_m68k
def bras_00():
bras(skip) # must be an error
label(skip)
nop()
@micropython.asm_m68k
def btstl_dn_ea():
@kg68k
kg68k / ryusan.bas
Created May 9, 2025 15:07
ワイヤーフレームの星が回転
dim int polyX(1000), polyY(1000)
dim float tblSin(359),tblCos(359)
for i=0 to 359:tblSin(i)=sin(pi(i/180#)):tblCos(i)=cos(pi(i/180#)):next
screen 1,1,1,1
count=0:apg=0:vpg=0:sz=100:sizePls=1
while 1
apg=((count+1) mod 2)
vpg=(1+((count+1) mod 2))
sz=sz+sizePls: if sz<10 or sz>200 then sizePls=sizePls*-1
polyCalc(count mod 360,sz)