public Pause(Func <Label, U8> handlerListAdd, LiveQueue queue, Label _, Label execBreak) { _liveQueue = queue; _executeLoopBreak = execBreak; _pauseCount = VByte.New(NES.ram, "VRamQueue_pauseCount"); _opPause = handlerListAdd(LabelFor(Handler)); }
public static void Clamp(VByte v, U8 low, U8 high) { If.Block(c => c .True(() => A.Set(v).LessThan(low), () => v.Set(low)) .True(() => A.GreaterThan(high), () => v.Set(high)) ); }
private void Dependencies() { PPUAddress = VWord.New(Ram, $"{nameof(ShadowAttributeTable_v1)}_{nameof(PPUAddress)}"); Table = Array <VByte> .New(64, Ram, $"{nameof(ShadowAttributeTable_v1)}_{nameof(Table)}"); _temp = VByte.New(Ram, $"{nameof(ShadowAttributeTable_v1)}{nameof(_temp)}"); }
public void GoSub(VByte index) { if (_stackJumpHelperFunc == null) { throw new Exception("Stack jump list not written for this label list"); } X.Set(index); AL.GoSub(_stackJumpHelperFunc); //GoTo_Indirect(this[X.Set(index)]); }
public void Push(VByte v) { X.Set(0); Loop.AscendWhile(X, () => X.NotEquals(Values.Length), loop => { If.True(() => Values[X].Equals(_clearVal), () => { Comment("Add action to the end of the queue"); Values[X].Set(v); loop.Break(); }); }); }
private void Dependencies() { _ptr = Ptr.New(Zp, $"{nameof(AnimUtil)}{nameof(_ptr)}"); _animData = Struct.New <AnimationData>(Zp, $"{nameof(AnimUtil)}{nameof(_animData)}"); _numTiles = VByte.New(Zp, $"{nameof(AnimUtil)}{nameof(_numTiles)}"); _tileIndex = VByte.New(Zp, $"{nameof(AnimUtil)}{nameof(_tileIndex)}"); _stateLength = VByte.New(Zp, $"{nameof(AnimUtil)}{nameof(_stateLength)}"); _stateLoop = VByte.New(Zp, $"{nameof(AnimUtil)}{nameof(_stateLoop)}"); _stateNext = VByte.New(Zp, $"{nameof(AnimUtil)}{nameof(_stateNext)}"); _frames = new Dictionary <string, Label>(); }
public VByte Index; //Used as a cursor for grid cell access via Y public static ByteGrid New(RAMRange ram, U8 length, string name) { var grid = new ByteGrid(); grid.Values = Array <VByte> .New(length, ram, name + "_grid"); grid.Width = VByte.New(ram, name + "_width"); grid.Height = VByte.New(ram, name + "_height"); grid.Max = VByte.New(ram, name + "_max"); grid.Index = VByte.New(ram, name + "_index"); return(grid); }
//TODO: this doesn't really enforce length. Implement wrap if length != 0 (0 would indicate 256--full page) public static LiveQueue New(RAMRange Zp, RAMRange Ram, RAMRange valuesRam, int length, string name, U8 stopVal) { var bq = new LiveQueue(); bq.Values = Array <VByte> .New(length, valuesRam, name + "_values"); bq._stopVal = stopVal; bq.WriteIndex = VByte.New(Zp, name + "_write"); bq.ReadIndex = VByte.New(Zp, name + "_read"); //bq._done = Var8.New(ram, name + "_done"); return(bq); }
//TODO: this doesn't have to be aligned to a page, so allow scenes to use this directly with their ram refs public void Setup(U16 pageStart, U8 length) { _done = VByte.New(Ram, $"{nameof(VRamQueue)}{nameof(_done)}"); _executeLoopContinue = Labels.New(); _executeLoopBreak = Labels.New(); var VRAM = Ram.Allocate(Addr(pageStart), Addr((U16)(pageStart + 0xFF)), "VRAM"); _ops = new List <VRamQueueOp>(); _ops.Add(new NOP()); _opHandlers = new List <Label>(); _liveQueue = LiveQueue.New(Zp, Ram, VRAM, length, $"{nameof(VRamQueue)}{nameof(_liveQueue)}", Op <Stop>()?.Id ?? 255); }
public void Setup(int length, params Option[] options) { _done = VByte.New(Ram, $"{nameof(VRamQueue)}{nameof(_done)}"); //_handlerAddress = VWord.New(ram, "VRamQueue_handlerAddress"); _executeLoopContinue = Labels.New(); _executeLoopBreak = Labels.New(); _liveQueue = LiveQueue.New(Zp, Ram, Ram, length, $"{nameof(VRamQueue)}{nameof(_liveQueue)}", Op.Stop); _options = options ?? Array.Empty <Option>(); OptionModules(); }
public void Declarations() { VRamQueue = Module <VRamQueue>(); _gamepad = Module <Gamepads>()[0]; _charX = VByte.New(Ram, $"{nameof(FlickerTest)}{nameof(_charX)}"); _charY = VByte.New(Ram, $"{nameof(FlickerTest)}{nameof(_charY)}"); _processed = VByte.New(Zp, $"{nameof(FlickerTest)}{nameof(_processed)}"); _index = VByte.New(Zp, $"{nameof(FlickerTest)}{nameof(_index)}"); _pattern = VByte.New(Zp, $"{nameof(FlickerTest)}{nameof(_pattern)}"); _skipOptionIndex = VByte.New(Zp, $"{nameof(FlickerTest)}{nameof(_skipOptionIndex)}"); _scatterSprites = StructOfArrays <ScatterSprite> .New($"{nameof(FlickerTest)}{nameof(_scatterSprites)}", 16).Dim(Ram); Include.Module(_scatterSprites[0]); }
private void Dependencies() { PPUAddress = VWord.New(Ram, $"{nameof(ShadowAttributeTable_v2)}_{nameof(PPUAddress)}"); Table = Array <VByte> .New(64, Ram, $"{nameof(ShadowAttributeTable_v2)}_{nameof(Table)}"); _temp = VByte.New(Ram, $"{nameof(ShadowAttributeTable_v2)}{nameof(_temp)}"); _attrMaskIdHoriz = VByte.New(Ram, $"{nameof(ShadowAttributeTable_v2)}{nameof(_attrMaskIdHoriz)}"); _attrMaskIdVert = VByte.New(Ram, $"{nameof(ShadowAttributeTable_v2)}{nameof(_attrMaskIdVert)}"); _attrOffsetLoStart = VByte.New(Ram, $"{nameof(ShadowAttributeTable_v2)}{nameof(_attrOffsetLoStart)}"); _attrOffsetLo = VByte.New(Ram, $"{nameof(ShadowAttributeTable_v2)}{nameof(_attrOffsetLo)}"); _attrOffsetLoRowStart = VByte.New(Ram, $"{nameof(ShadowAttributeTable_v2)}{nameof(_attrOffsetLoRowStart)}"); _lastAttrMask = VByte.New(Ram, $"{nameof(ShadowAttributeTable_v2)}{nameof(_lastAttrMask)}"); _currentAttrMask = VByte.New(Ram, $"{nameof(ShadowAttributeTable_v2)}{nameof(_currentAttrMask)}"); }
//TODO: this doesn't have to be aligned to a page, so allow scenes to use this directly with their ram refs public void SetupAligned(U16 pageStart, U8 length, params Option[] options) { _done = VByte.New(Ram, $"{nameof(VRamQueue)}{nameof(_done)}"); //_handlerAddress = VWord.New(ram, "VRamQueue_handlerAddress"); _executeLoopContinue = Labels.New(); _executeLoopBreak = Labels.New(); var VRAM = Ram.Allocate(Addr(pageStart), Addr((U16)(pageStart + 0xFF)), "VRAM"); _liveQueue = LiveQueue.New(Zp, Ram, VRAM, length, $"{nameof(VRamQueue)}{nameof(_liveQueue)}", Op.Stop); _options = options ?? Array.Empty <Option>(); OptionModules(); }
public static void RLEDecompress(/*Action dataAction,*/ VByte temp, Action <RegisterA> block) { //var lbl = LabelFor(dataAction); //TempPtr0.PointTo(lbl); byte compressionIndicator = 255; var length = temp.Set(TempPtr0[Y.Set(0)]); Loop.AscendWhile(Y.Increment(), () => Y.LessThan(length), _ => { If.Block(c => c .True(() => A.Set(TempPtr0[Y]).Equals(compressionIndicator), () => { Y.State.Unsafe(() => { Y.Increment(); X.Set(A.Set(TempPtr0[Y])); Y.Increment(); Loop.Descend_Post(X, _ => block(A.Set(TempPtr0[Y]))); }); }) .Else(() => block(A.Set(TempPtr0[Y]))) ); }); }
public static RegisterA GetTVSystem(VByte nmis) { X.Set(0); Y.Set(0); A.Set(nmis); Loop.Do_old().While(() => A.Equals(nmis)); A.Set(nmis); Loop.Do_old(_ => { //Each iteration takes 11 cycles. //NTSC NES: 29780 cycles or 2707 = $A93 iterations //PAL NES: 33247 cycles or 3022 = $BCE iterations //Dendy: 35464 cycles or 3224 = $C98 iterations //so we can divide by $100 (rounding down), subtract ten, //and end up with 0=ntsc, 1=pal, 2=dendy, 3=unknown X.Inc(); If.True(() => X.Equals(0), () => Y.Increment()); }).While(() => A.Equals(nmis)); If.True(() => A.Set(Y).Subtract(10).GreaterThanOrEqualTo(3), () => A.Set(3)); return(A); }
public VByte UpdateSingleTile(Func <IOperand> x, Func <IOperand> y, Func <IOperand> color, VByte temp) { CPU6502.CLD(); CPU6502.CLD(); CPU6502.CLD(); CPU6502.CLD(); CPU6502.CLD(); temp.Set(A.Set(x()).Divide(32)); temp.Set(z => A.Set(y()).Divide(4).And(0b00111000).Or(z)); Stack.Preserve(A, () => { //preserve attr index, wait to put into X, because X is needed as an index to X() and Y() values Comment("temp = attr tile mask index"); temp.Set(A.Set(x()).Divide(16).And(1)); temp.Set(z => A.Set(y()).Divide(8).And(0b10).Or(z)); });
public BankSwitcher() { Bank = VByte.New(NES.zp, "bank_current"); }
public void Dependencies() { _bankSelect = VByte.Ref(0x8000, nameof(_bankSelect)); _bankData = VByte.Ref(0x8001, nameof(_bankData)); _mirroring = VByte.Ref(0xA000, nameof(_mirroring)); }
private void Dependencies() { _temp = VByte.New(Ram, $"{nameof(RLEVariance)}{nameof(_temp)}"); }
private void Dependencies() { _index = VByte.New(Ram, "gamepad_index"); _gamepads = StructOfArrays <Gamepad> .New("gamepadData", _numPlayers).Dim(Ram); }
static BankSwitching() { Bank = VByte.New(NES.zp, "bank_current"); }
public void Dependencies() { _length = VByte.New(Zp, $"{nameof(SequentialIterator)}{nameof(_length)}"); _index = VByte.New(Zp, $"{nameof(SequentialIterator)}{nameof(_index)}"); }
public void Push(VByte val) { _liveQueue.Push(val); }
public Pause() { _pauseCount = VByte.New(NES.ram, "VRamQueue_pauseCount"); }
public void Variables() { //Variables nmiCount = VByte.New(Zp, "NMI_Count"); }
public static RegisterA Negate(VByte v) { A.Set(v).Xor(0xFF); Carry.Set(); return(A.ADC(0)); }
public void Draw_Manual(VByte len) { _liveQueue.PushStart(Y); _liveQueue.Push(_opTileArray); _liveQueue.Push(len); }
public static RegisterA Multiply(this VByte v, U8 n) { return(A.Set(v).Multiply(n)); }