Skip to content

Instantly share code, notes, and snippets.

@nurpax
nurpax / sprite_array_clear_loop.asm
Last active October 28, 2018 23:19
sprite array clear loop
; Note: optimized to rely on dst ptr to be 64-byte aligned (as sprites are)
clear_writer_sprite_row: {
+mov16($30, zp_sprite_dst)
ldx #num_writer_sprites
sprite_loop:
lda $31
sta dstp0-1
sta dstp1-1
sta dstp2-1
export interface Node {
loc: SourceLoc;
}
export type Expr = any | Ident | Literal
export type Stmt =
StmtInsn
| StmtSetPC
| StmtAlign
| StmtData
const CW = 6;
const CH = 7;
function readSprites({readFileSync, resolveRelative}, filename) {
const buf = readFileSync(resolveRelative(filename.lit));
const numSprites = buf.readUInt8(4);
const data = [];
for (let i = 0; i < numSprites; i++) {
const offs = i*64+9;
const bytes = [];
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "c64jasm build & run",
"type": "shell",
"command": "c64jasm main.asm --out main.prg && x64 main.prg",
"problemMatcher": "$c64jasm"
@nurpax
nurpax / irq.asm
Last active September 17, 2018 22:41
FALSE=0
TRUE=1
irq0_line = 100
irq1_line = 150
!macro basic_start(addr) {
* = $801
!byte $0c
!byte $08
!macro basic_start(addr) {
* = $801
!byte $0c
!byte $08
!byte $00
!byte $00
!byte $9e
!if (addr >= 10000) {
!byte $30 + (addr/10000)%10
}
.const zptmp0 = $60
.const zptmp1 = $62
.const zptmp2 = $64
.const zptmp3 = $68
.const zp_dstptr = zptmp0
.const zp_srcptr = zptmp1
.const zp_nlines = zptmp2
@nurpax
nurpax / sprite_macros.s
Created August 19, 2018 21:53
spd sprite loading in kickassembler
.var spdDataTemplate = "Magic=$0,Version=$3,NumSprites=$4,NumAnims=$5,Bg=$6,Multicol1=$7,Multicol2=$8"
.var iiro = LoadBinary("sprites/iiro.spd", spdDataTemplate)
.macro setupSprites(spd, data, dblw, dblh) {
.const numSprites = spd.getNumSprites()+1
.const spriteMask = ((1 << numSprites)-1)
.var xScale = 1
.var yScale = 1
lda #spriteMask
@nurpax
nurpax / brush.js
Last active August 3, 2018 22:19
smart flip vertical/horizontal
const reverseBits = (b) => {
const b0 = (b & 1) >> 0
const b1 = (b & 2) >> 1
const b2 = (b & 4) >> 2
const b3 = (b & 8) >> 3
const b4 = (b & 16) >> 4
const b5 = (b & 32) >> 5
const b6 = (b & 64) >> 6
const b7 = (b & 128) >> 7
@nurpax
nurpax / noprofanity.c
Last active May 23, 2018 08:25
remove effings from bintris
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, const char **argv)
{
FILE* fpi = fopen(argv[1], "rb");
FILE* fpo = fopen(argv[2], "wb");