Skip to content

Instantly share code, notes, and snippets.

@Palmr
Palmr / gist:4526839
Last active September 3, 2022 16:12
Subtract A, r instruction for the z80 in a gameboy
void Instructions::do8bitSubRegToA(CPU* cpu, BYTE (Registers::*getRegFunc)()){
BYTE lInitialValue = cpu->reg->getA();
BYTE lToSub = (cpu->reg->*getRegFunc)();
WORD lTotal = lInitialValue - lToSub;
// If the lower nibble of the original value is less than the lower nibble of what we're subtracting, it'll need a half carry
cpu->reg->setFlagH((lInitialValue & 0x0f) < (lToSub & 0x0f)? 1 : 0);
// If the original value is less than we're subtracting it'll carry
cpu->reg->setFlagC(lInitialValue < lToSub ? 1 : 0);
/opt/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_C_COMPILER_WORKS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CROSSCOMPILING=ON /tmp/msvc-wine_issue-41_repro
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/msvc-wine_issue-41_repro/cmake-build-release-docker-wine
Cannot get compiler information:
Compiler exited with error code 2: /opt/msvc/bin/x86/cl @/tmp/misc/response-file12954642806412015051 /tmp/misc/compiler-file7185106763504052988 | @response-file12954642806412015051=/TP /DIssueRepro_EXPORTS /DNDEBUG /DWIN32 /D_MBCS /D_USRDLL /D_WINDOWS /EHsc /EHsc -MD /GL /Oi /GF /Gy /W3 /Zi /EHsc /FI/tmp/msvc-wine_issue-41_repro/cmake-build-release-docker-wine/IssueRepro/CMakeFiles/IssueRepro.dir/cmake_pch.hxx /Be /Bd /EP
0012:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x80004002
0012:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, 80004002
0012:err:ole:get_local_serve
/opt/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_C_COMPILER_WORKS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CROSSCOMPILING=ON /tmp/project
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/project/cmake-build-release-docker-wine
Cannot get compiler information:
Compiler exited with error code 2: /opt/msvc/bin/x86/cl @/tmp/misc/response-file15603522667233498293 /tmp/misc/compiler-file16351311352593759053 | @response-file15603522667233498293=/TP /DPROJECT_EXPORTS /DProject_EXPORTS /DNDEBUG /DWIN32 /D_MBCS /D_USRDLL /D_WINDOWS /EHsc /EHsc -MD /GL /Oi /GF /Gy /W3 /Zi /EHsc /FI/tmp/project/cmake-build-release-docker-wine/Project/CMakeFiles/Project.dir/cmake_pch.hxx /Be /Bd /EP
0012:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x80004002
0012:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, 80004002
0012:err:ole:get_local_server_stream Failed: 80004002
package com.lmax.disruptor;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
Index: src/main/java/org/example/questionn/csv/CsvRenderer.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/org/example/questionn/csv/CsvRenderer.java (revision 13e0a8fb07a40e89c39ea8f8176f4c2e6b590774)
+++ src/main/java/org/example/questionn/csv/CsvRenderer.java (date 1592660439551)
@@ -3,11 +3,13 @@
import ratpack.handling.Context;
import ratpack.render.RendererSupport;
function derEncodeECDSASignatureToUinit8Array(signatureUint8Array) {
let out_sigder = new ArrayBuffer(72);
let out_sigder_DV = new DataView(out_sigder);
let out_sigder_BA = new Uint8Array(out_sigder);
// Need to caress into dumb der format ..
let i;
let lead_s = 0; // leading zeros
let lead_r = 0;
#!/usr/bin/env python3
## Highly advise running `setserial /dev/ttyUSB0 low_latency` before flashing
from spidriver import SPIDriver
import struct
import time
import sys
import getopt
@Palmr
Palmr / ascii.php
Created November 4, 2011 15:57
Image to ascii art converter (not great)
<?php
if(!isset($_GET['pure'])){
?>
<style>
pre {
line-height: 11px;
font-family:"Courier New", Courier, monospace;
}
#error {
font-family: Arial, Helvetica, sans-serif;
@Palmr
Palmr / gist:7643101
Created November 25, 2013 15:32
VBA to deal with some stock control stuff
Attribute VB_Name = "Module1"
Sub Stockreport1()
Attribute Stockreport1.VB_ProcData.VB_Invoke_Func = " \n14"
' Comments start with apostrophes :)
' Select a bunch of columns, then remove them
Range("F:F,I:I,X:X,AD:AD,AE:AE,AA:AC,AH:AP").Select
Selection.Delete Shift:=xlToLeft
' Insert a new column and put "Stores OOS" in the first item to be the title